1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-07-13 20:09:11 +08:00

整理代码

This commit is contained in:
xiaochong0302 2020-05-08 21:31:23 +08:00
parent d34d73721a
commit f602c39d2d
54 changed files with 750 additions and 722 deletions

View File

@ -2,43 +2,64 @@
namespace App\Builders; namespace App\Builders;
use App\Models\Category as CategoryModel;
use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface;
class CategoryTreeList extends Builder class CategoryTreeList extends Builder
{ {
public function handleTreeList($categories) public function handle()
{ {
$list = []; $topCategories = $this->findChildCategories(0);
foreach ($categories as $category) { if ($topCategories->count() == 0) {
if ($category['parent_id'] == 0) { return [];
$key = $category['id'];
$list[$key] = [
'id' => $category['id'],
'name' => $category['name'],
'priority' => $category['priority'],
'children' => [],
];
} else {
$key = $category['parent_id'];
$list[$key]['children'][] = [
'id' => $category['id'],
'name' => $category['name'],
'priority' => $category['priority'],
];
}
} }
usort($list, function ($a, $b) { $list = [];
return $a['priority'] > $b['priority'];
});
foreach ($list as $key => $value) { foreach ($topCategories as $category) {
usort($list[$key]['children'], function ($a, $b) { $list[] = [
return $a['priority'] > $b['priority']; 'id' => $category->id,
}); 'name' => $category->name,
'children' => $this->handleChildren($category),
];
} }
return $list; return $list;
} }
protected function handleChildren(CategoryModel $category)
{
$subCategories = $this->findChildCategories($category->id);
if ($subCategories->count() == 0) {
return [];
}
$list = [];
foreach ($subCategories as $category) {
$list[] = [
'id' => $category->id,
'name' => $category->name,
];
}
return $list;
}
/**
* @param int $categoryId
* @return ResultsetInterface|Resultset|CategoryModel[]
*/
protected function findChildCategories($categoryId = 0)
{
return CategoryModel::query()
->where('parent_id = :parent_id:', ['parent_id' => $categoryId])
->andWhere('deleted = 0')
->execute();
}
} }

View File

@ -1,19 +0,0 @@
<?php
namespace App\Builders;
use App\Models\Chapter as ChapterModel;
class Chapter extends Builder
{
/**
* @param ChapterModel $chapter
* @return ChapterModel
*/
public function handleChapter(ChapterModel $chapter)
{
return $chapter;
}
}

View File

@ -2,68 +2,102 @@
namespace App\Builders; namespace App\Builders;
use App\Models\Chapter as ChapterModel;
use App\Models\Course as CourseModel; use App\Models\Course as CourseModel;
use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface;
class ChapterTreeList extends Builder class ChapterTreeList extends Builder
{ {
/** /**
* @param array $chapters * @param int $courseId
* @return array * @return array
*/ */
public function handleTreeList($chapters) public function handle($courseId)
{ {
$list = []; $list = [];
foreach ($chapters as $chapter) { $chapters = $this->findChapters($courseId);
if ($chapter['parent_id'] == 0) {
$key = $chapter['id']; if ($chapters->count() == 0) {
$list[$key] = [ return [];
'id' => $chapter['id'],
'title' => $chapter['title'],
'summary' => $chapter['summary'],
'priority' => $chapter['priority'],
'children' => [],
];
} else {
$key = $chapter['parent_id'];
$list[$key]['children'][] = $this->handleChapter($chapter);
}
} }
usort($list, function ($a, $b) { foreach ($chapters as $chapter) {
return $a['priority'] > $b['priority']; $list[] = [
}); 'id' => $chapter->id,
'title' => $chapter->title,
foreach ($list as $key => $value) { 'summary' => $chapter->summary,
usort($list[$key]['children'], function ($a, $b) { 'priority' => $chapter->priority,
return $a['priority'] > $b['priority']; 'children' => $this->handleChildren($chapter),
}); ];
} }
return $list; return $list;
} }
/** /**
* @param array $chapter * @param ChapterModel $chapter
* @return array * @return array
*/ */
protected function handleChapter($chapter) protected function handleChildren(ChapterModel $chapter)
{ {
$attrs = json_decode($chapter['attrs'], true); $lessons = $this->findLessons($chapter->id);
if ($attrs['model'] == CourseModel::MODEL_VOD) { if ($lessons->count() == 0) {
unset($attrs['file_id'], $attrs['file_status']); return [];
} }
return [ $list = [];
'id' => $chapter['id'],
'title' => $chapter['title'], foreach ($lessons as $lesson) {
'summary' => $chapter['summary'],
'priority' => $chapter['priority'], /**
'free' => $chapter['free'], * @var $attrs array
'attrs' => $attrs, */
]; $attrs = $lesson->attrs;
if ($attrs['model'] == CourseModel::MODEL_VOD) {
unset($attrs['file_id'], $attrs['file_status']);
}
$list[] = [
'id' => $lesson->id,
'title' => $lesson->title,
'summary' => $lesson->summary,
'free' => $lesson->free,
'attrs' => $attrs,
];
}
return $list;
}
/**
* @param int $courseId
* @return ResultsetInterface|Resultset|ChapterModel[]
*/
protected function findChapters($courseId)
{
return ChapterModel::query()
->where('course_id = :course_id:', ['course_id' => $courseId])
->andWhere('parent_id = 0 AND deleted = 0')
->orderBy('priority ASC, id ASC')
->execute();
}
/**
* @param int $chapterId
* @return ResultsetInterface|Resultset|ChapterModel[]
*/
protected function findLessons($chapterId)
{
return ChapterModel::query()
->where('parent_id = :parent_id:', ['parent_id' => $chapterId])
->andWhere('deleted = 0')
->orderBy('priority ASC, id ASC')
->execute();
} }
} }

View File

@ -9,40 +9,40 @@ use App\Repos\User as UserRepo;
class CommentList extends Builder class CommentList extends Builder
{ {
public function handleCourses($comments) public function handleCourses(array $comments)
{ {
$courses = $this->getCourses($comments); $courses = $this->getCourses($comments);
foreach ($comments as $key => $comment) { foreach ($comments as $key => $comment) {
$comments[$key]['course'] = $courses[$comment['course_id']] ?? []; $comments[$key]['course'] = $courses[$comment['course_id']] ?? new \stdClass();
} }
return $comments; return $comments;
} }
public function handleChapters($comments) public function handleChapters(array $comments)
{ {
$chapters = $this->getChapters($comments); $chapters = $this->getChapters($comments);
foreach ($comments as $key => $comment) { foreach ($comments as $key => $comment) {
$comments[$key]['chapter'] = $chapters[$comment['chapter_id']] ?? []; $comments[$key]['chapter'] = $chapters[$comment['chapter_id']] ?? new \stdClass();
} }
return $comments; return $comments;
} }
public function handleUsers($comments) public function handleUsers(array $comments)
{ {
$users = $this->getUsers($comments); $users = $this->getUsers($comments);
foreach ($comments as $key => $comment) { foreach ($comments as $key => $comment) {
$comments[$key]['user'] = $users[$comment['user_id']] ?? []; $comments[$key]['user'] = $users[$comment['user_id']] ?? new \stdClass();
} }
return $comments; return $comments;
} }
public function getCourses($comments) public function getCourses(array $comments)
{ {
$ids = kg_array_column($comments, 'course_id'); $ids = kg_array_column($comments, 'course_id');
@ -59,7 +59,7 @@ class CommentList extends Builder
return $result; return $result;
} }
public function getChapters($comments) public function getChapters(array $comments)
{ {
$ids = kg_array_column($comments, 'chapter_id'); $ids = kg_array_column($comments, 'chapter_id');
@ -76,7 +76,7 @@ class CommentList extends Builder
return $result; return $result;
} }
public function getUsers($comments) public function getUsers(array $comments)
{ {
$ids = kg_array_column($comments, 'user_id'); $ids = kg_array_column($comments, 'user_id');

View File

@ -8,29 +8,29 @@ use App\Repos\User as UserRepo;
class ConsultList extends Builder class ConsultList extends Builder
{ {
public function handleCourses($consults) public function handleCourses(array $consults)
{ {
$courses = $this->getCourses($consults); $courses = $this->getCourses($consults);
foreach ($consults as $key => $consult) { foreach ($consults as $key => $consult) {
$consults[$key]['course'] = $courses[$consult['course_id']] ?? []; $consults[$key]['course'] = $courses[$consult['course_id']] ?? new \stdClass();
} }
return $consults; return $consults;
} }
public function handleUsers($consults) public function handleUsers(array $consults)
{ {
$users = $this->getUsers($consults); $users = $this->getUsers($consults);
foreach ($consults as $key => $consult) { foreach ($consults as $key => $consult) {
$consults[$key]['user'] = $users[$consult['user_id']] ?? []; $consults[$key]['user'] = $users[$consult['user_id']] ?? new \stdClass();
} }
return $consults; return $consults;
} }
public function getCourses($consults) public function getCourses(array $consults)
{ {
$ids = kg_array_column($consults, 'course_id'); $ids = kg_array_column($consults, 'course_id');
@ -47,7 +47,7 @@ class ConsultList extends Builder
return $result; return $result;
} }
public function getUsers($consults) public function getUsers(array $consults)
{ {
$ids = kg_array_column($consults, 'user_id'); $ids = kg_array_column($consults, 'user_id');

View File

@ -1,21 +0,0 @@
<?php
namespace App\Builders;
use App\Models\Course as CourseModel;
class Course extends Builder
{
/**
* @param CourseModel $course
* @return CourseModel
*/
public function handleCourse(CourseModel $course)
{
$course->cover = kg_ci_img_url($course->cover);
return $course;
}
}

View File

@ -49,7 +49,7 @@ class CourseChapterUser extends Builder
$attrs = json_decode($chapter['attrs'], true); $attrs = json_decode($chapter['attrs'], true);
$me = $chapter['me'] ?? []; $me = $chapter['me'] ?? new \stdClass();
$clickable = $chapter['published']; $clickable = $chapter['published'];

View File

@ -8,38 +8,39 @@ use App\Repos\User as UserRepo;
class CourseFavoriteList extends Builder class CourseFavoriteList extends Builder
{ {
public function handleCourses($relations) public function handleCourses(array $relations)
{ {
$courses = $this->getCourses($relations); $courses = $this->getCourses($relations);
foreach ($relations as $key => $value) { foreach ($relations as $key => $value) {
$relations[$key]['course'] = $courses[$value['course_id']]; $relations[$key]['course'] = $courses[$value['course_id']] ?? new \stdClass();
} }
return $relations; return $relations;
} }
public function handleUsers($relations) public function handleUsers(array $relations)
{ {
$users = $this->getUsers($relations); $users = $this->getUsers($relations);
foreach ($relations as $key => $value) { foreach ($relations as $key => $value) {
$relations[$key]['user'] = $users[$value['user_id']]; $relations[$key]['user'] = $users[$value['user_id']] ?? new \stdClass();
} }
return $relations; return $relations;
} }
public function getCourses($relations) public function getCourses(array $relations)
{ {
$ids = kg_array_column($relations, 'course_id'); $ids = kg_array_column($relations, 'course_id');
$courseRepo = new CourseRepo(); $courseRepo = new CourseRepo();
$columns = [ $columns = [
'id', 'title', 'cover', 'summary', 'id', 'title', 'cover',
'market_price', 'vip_price', 'model', 'level', 'attrs', 'market_price', 'vip_price',
'user_count', 'lesson_count', 'review_count', 'favorite_count', 'rating', 'model', 'level', 'attrs',
'user_count', 'lesson_count',
]; ];
$courses = $courseRepo->findByIds($ids, $columns); $courses = $courseRepo->findByIds($ids, $columns);
@ -57,7 +58,7 @@ class CourseFavoriteList extends Builder
return $result; return $result;
} }
public function getUsers($relations) public function getUsers(array $relations)
{ {
$ids = kg_array_column($relations, 'user_id'); $ids = kg_array_column($relations, 'user_id');

View File

@ -8,35 +8,37 @@ use App\Repos\User as UserRepo;
class CourseList extends Builder class CourseList extends Builder
{ {
public function handleCategories($courses) public function handleCategories(array $courses)
{ {
$categories = $this->getCategories(); $categories = $this->getCategories();
foreach ($courses as $key => $course) { foreach ($courses as $key => $course) {
$courses[$key]['category'] = $categories[$course['category_id']] ?? []; $courses[$key]['category'] = $categories[$course['category_id']] ?? new \stdClass();
} }
return $courses; return $courses;
} }
public function handleTeachers($courses) public function handleTeachers(array $courses)
{ {
$teachers = $this->getTeachers($courses); $teachers = $this->getTeachers($courses);
foreach ($courses as $key => $course) { foreach ($courses as $key => $course) {
$courses[$key]['teacher'] = $teachers[$course['teacher_id']] ?? []; $courses[$key]['teacher'] = $teachers[$course['teacher_id']] ?? new \stdClass();
} }
return $courses; return $courses;
} }
protected function getCategories() public function getCategories()
{ {
$cache = new CategoryListCache(); $cache = new CategoryListCache();
$items = $cache->get(); $items = $cache->get();
if (!$items) return null; if (empty($items)) {
return [];
}
$result = []; $result = [];
@ -50,7 +52,7 @@ class CourseList extends Builder
return $result; return $result;
} }
protected function getTeachers($courses) public function getTeachers($courses)
{ {
$ids = kg_array_column($courses, 'teacher_id'); $ids = kg_array_column($courses, 'teacher_id');

View File

@ -13,7 +13,7 @@ class CourseUserList extends Builder
$courses = $this->getCourses($relations); $courses = $this->getCourses($relations);
foreach ($relations as $key => $value) { foreach ($relations as $key => $value) {
$relations[$key]['course'] = $courses[$value['course_id']]; $relations[$key]['course'] = $courses[$value['course_id']] ?? new \stdClass();
} }
return $relations; return $relations;
@ -24,7 +24,7 @@ class CourseUserList extends Builder
$users = $this->getUsers($relations); $users = $this->getUsers($relations);
foreach ($relations as $key => $value) { foreach ($relations as $key => $value) {
$relations[$key]['user'] = $users[$value['user_id']]; $relations[$key]['user'] = $users[$value['user_id']] ?? new \stdClass();
} }
return $relations; return $relations;
@ -37,9 +37,10 @@ class CourseUserList extends Builder
$courseRepo = new CourseRepo(); $courseRepo = new CourseRepo();
$columns = [ $columns = [
'id', 'title', 'cover', 'summary', 'id', 'title', 'cover',
'market_price', 'vip_price', 'model', 'level', 'attrs', 'market_price', 'vip_price',
'user_count', 'lesson_count', 'review_count', 'favorite_count', 'rating', 'model', 'level', 'attrs',
'user_count', 'lesson_count',
]; ];
$courses = $courseRepo->findByIds($ids, $columns); $courses = $courseRepo->findByIds($ids, $columns);

View File

@ -14,7 +14,7 @@ class LearningList extends Builder
$courses = $this->getCourses($relations); $courses = $this->getCourses($relations);
foreach ($relations as $key => $value) { foreach ($relations as $key => $value) {
$relations[$key]['course'] = $courses[$value['course_id']]; $relations[$key]['course'] = $courses[$value['course_id']] ?? new \stdClass();
} }
return $relations; return $relations;
@ -25,7 +25,7 @@ class LearningList extends Builder
$chapters = $this->getChapters($relations); $chapters = $this->getChapters($relations);
foreach ($relations as $key => $value) { foreach ($relations as $key => $value) {
$relations[$key]['chapter'] = $chapters[$value['chapter_id']]; $relations[$key]['chapter'] = $chapters[$value['chapter_id']] ?? new \stdClass();
} }
return $relations; return $relations;
@ -36,7 +36,7 @@ class LearningList extends Builder
$users = $this->getUsers($relations); $users = $this->getUsers($relations);
foreach ($relations as $key => $value) { foreach ($relations as $key => $value) {
$relations[$key]['user'] = $users[$value['user_id']]; $relations[$key]['user'] = $users[$value['user_id']] ?? new \stdClass();
} }
return $relations; return $relations;
@ -48,7 +48,7 @@ class LearningList extends Builder
$courseRepo = new CourseRepo(); $courseRepo = new CourseRepo();
$courses = $courseRepo->findByIds($ids, ['id', 'title', 'cover']); $courses = $courseRepo->findByIds($ids, ['id', 'title']);
$result = []; $result = [];
@ -82,7 +82,7 @@ class LearningList extends Builder
$userRepo = new UserRepo(); $userRepo = new UserRepo();
$users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']); $users = $userRepo->findByIds($ids, ['id', 'name']);
$result = []; $result = [];

View File

@ -2,45 +2,76 @@
namespace App\Builders; namespace App\Builders;
use App\Models\Nav as NavModel;
use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface;
class NavTreeList extends Builder class NavTreeList extends Builder
{ {
public function handleTreeList($navs) public function handle($position = 'top')
{ {
$list = []; $topNavs = $this->findTopNavs($position);
foreach ($navs as $nav) { if ($topNavs->count() == 0) {
if ($nav['parent_id'] == 0) { return [];
$key = $nav['id'];
$list[$key] = [
'id' => $nav['id'],
'name' => $nav['name'],
'priority' => $nav['priority'],
'children' => [],
];
} else {
$key = $nav['parent_id'];
$list[$key]['children'][] = [
'id' => $nav['id'],
'name' => $nav['name'],
'priority' => $nav['priority'],
'target' => $nav['target'],
'url' => $nav['url'],
];
}
} }
usort($list, function ($a, $b) { $list = [];
return $a['priority'] > $b['priority'];
});
foreach ($list as $key => $value) { foreach ($topNavs as $nav) {
usort($list[$key]['children'], function ($a, $b) { $list[] = [
return $a['priority'] > $b['priority']; 'id' => $nav->id,
}); 'name' => $nav->name,
'children' => $this->handleChildren($nav),
];
} }
return $list; return $list;
} }
protected function handleChildren(NavModel $nav)
{
$subNavs = $this->findSubNavs($nav->id);
if ($subNavs->count() == 0) {
return [];
}
$list = [];
foreach ($subNavs as $nav) {
$list[] = [
'id' => $nav->id,
'name' => $nav->name,
];
}
return $list;
}
/**
* @param int $navId
* @return ResultsetInterface|Resultset|NavModel[]
*/
protected function findSubNavs($navId)
{
return NavModel::query()
->where('parent_id = :parent_id:', ['parent_id' => $navId])
->andWhere('deleted = 0')
->execute();
}
/**
* @param string $position
* @return ResultsetInterface|Resultset|NavModel[]
*/
protected function findTopNavs($position)
{
return NavModel::query()
->where('position = :position:', ['position' => $position])
->andWhere('deleted = 0')
->execute();
}
} }

View File

@ -8,7 +8,7 @@ use App\Repos\User as UserRepo;
class OrderList extends Builder class OrderList extends Builder
{ {
protected $baseUrl; protected $imgBaseUrl;
public function __construct() public function __construct()
{ {
@ -24,7 +24,7 @@ class OrderList extends Builder
$users = $this->getUsers($orders); $users = $this->getUsers($orders);
foreach ($orders as $key => $order) { foreach ($orders as $key => $order) {
$orders[$key]['user'] = $users[$order['user_id']]; $orders[$key]['user'] = $users[$order['user_id']] ?? new \stdClass();
} }
return $orders; return $orders;
@ -37,9 +37,7 @@ class OrderList extends Builder
public function handleItems(array $orders) public function handleItems(array $orders)
{ {
foreach ($orders as $key => $order) { foreach ($orders as $key => $order) {
$itemInfo = $this->handleItem($order); $itemInfo = $this->handleItem($order);
$orders[$key]['item_info'] = $itemInfo; $orders[$key]['item_info'] = $itemInfo;
} }

View File

@ -8,29 +8,29 @@ use App\Repos\User as UserRepo;
class RefundList extends Builder class RefundList extends Builder
{ {
public function handleOrders($trades) public function handleOrders(array $trades)
{ {
$orders = $this->getOrders($trades); $orders = $this->getOrders($trades);
foreach ($trades as $key => $trade) { foreach ($trades as $key => $trade) {
$trades[$key]['order'] = $orders[$trade['order_id']]; $trades[$key]['order'] = $orders[$trade['order_id']] ?? new \stdClass();
} }
return $trades; return $trades;
} }
public function handleUsers($refunds) public function handleUsers(array $refunds)
{ {
$users = $this->getUsers($refunds); $users = $this->getUsers($refunds);
foreach ($refunds as $key => $refund) { foreach ($refunds as $key => $refund) {
$refunds[$key]['user'] = $users[$refund['user_id']]; $refunds[$key]['user'] = $users[$refund['user_id']] ?? new \stdClass();
} }
return $refunds; return $refunds;
} }
public function getOrders($trades) public function getOrders(array $trades)
{ {
$ids = kg_array_column($trades, 'order_id'); $ids = kg_array_column($trades, 'order_id');
@ -47,7 +47,7 @@ class RefundList extends Builder
return $result; return $result;
} }
public function getUsers($refunds) public function getUsers(array $refunds)
{ {
$ids = kg_array_column($refunds, 'user_id'); $ids = kg_array_column($refunds, 'user_id');

View File

@ -8,29 +8,29 @@ use App\Repos\User as UserRepo;
class ReviewList extends Builder class ReviewList extends Builder
{ {
public function handleCourses($reviews) public function handleCourses(array $reviews)
{ {
$courses = $this->getCourses($reviews); $courses = $this->getCourses($reviews);
foreach ($reviews as $key => $review) { foreach ($reviews as $key => $review) {
$reviews[$key]['course'] = $courses[$review['course_id']] ?? []; $reviews[$key]['course'] = $courses[$review['course_id']] ?? new \stdClass();
} }
return $reviews; return $reviews;
} }
public function handleUsers($reviews) public function handleUsers(array $reviews)
{ {
$users = $this->getUsers($reviews); $users = $this->getUsers($reviews);
foreach ($reviews as $key => $review) { foreach ($reviews as $key => $review) {
$reviews[$key]['user'] = $users[$review['user_id']] ?? []; $reviews[$key]['user'] = $users[$review['user_id']] ?? new \stdClass();
} }
return $reviews; return $reviews;
} }
public function getCourses($reviews) public function getCourses(array $reviews)
{ {
$ids = kg_array_column($reviews, 'course_id'); $ids = kg_array_column($reviews, 'course_id');
@ -47,7 +47,7 @@ class ReviewList extends Builder
return $result; return $result;
} }
public function getUsers($reviews) public function getUsers(array $reviews)
{ {
$ids = kg_array_column($reviews, 'user_id'); $ids = kg_array_column($reviews, 'user_id');

View File

@ -1,19 +0,0 @@
<?php
namespace App\Builders;
class SlideList extends Builder
{
public function handleSlides($slides)
{
$baseUrl = kg_ci_base_url();
foreach ($slides as $key => $slide) {
$slides[$key]['cover'] = $baseUrl . $slide['cover'];
}
return $slides;
}
}

View File

@ -8,12 +8,12 @@ use App\Repos\User as UserRepo;
class TradeList extends Builder class TradeList extends Builder
{ {
public function handleOrders($trades) public function handleOrders(array $trades)
{ {
$orders = $this->getOrders($trades); $orders = $this->getOrders($trades);
foreach ($trades as $key => $trade) { foreach ($trades as $key => $trade) {
$trades[$key]['order'] = $orders[$trade['order_id']]; $trades[$key]['order'] = $orders[$trade['order_id']] ?? new \stdClass();
} }
return $trades; return $trades;
@ -24,7 +24,7 @@ class TradeList extends Builder
$users = $this->getUsers($trades); $users = $this->getUsers($trades);
foreach ($trades as $key => $trade) { foreach ($trades as $key => $trade) {
$trades[$key]['user'] = $users[$trade['user_id']]; $trades[$key]['user'] = $users[$trade['user_id']] ?? new \stdClass();
} }
return $trades; return $trades;

View File

@ -1,21 +0,0 @@
<?php
namespace App\Builders;
use App\Models\User as UserModel;
class User extends Builder
{
/**
* @param UserModel $user
* @return UserModel
*/
public function handleUser(UserModel $user)
{
$user->avatar = kg_ci_img_url($user->avatar);
return $user;
}
}

View File

@ -8,7 +8,7 @@ use App\Repos\Role as RoleRepo;
class UserList extends Builder class UserList extends Builder
{ {
public function handleUsers($users) public function handleUsers(array $users)
{ {
$baseUrl = kg_ci_base_url(); $baseUrl = kg_ci_base_url();
@ -19,7 +19,7 @@ class UserList extends Builder
return $users; return $users;
} }
public function handleAdminRoles($users) public function handleAdminRoles(array $users)
{ {
$roles = $this->getAdminRoles($users); $roles = $this->getAdminRoles($users);
@ -30,7 +30,7 @@ class UserList extends Builder
return $users; return $users;
} }
public function handleEduRoles($users) public function handleEduRoles(array $users)
{ {
$roles = $this->getEduRoles(); $roles = $this->getEduRoles();
@ -41,7 +41,7 @@ class UserList extends Builder
return $users; return $users;
} }
protected function getAdminRoles($users) protected function getAdminRoles(array $users)
{ {
$ids = kg_array_column($users, 'admin_role'); $ids = kg_array_column($users, 'admin_role');

View File

@ -3,8 +3,6 @@
namespace App\Caches; namespace App\Caches;
use App\Builders\CategoryTreeList as CategoryTreeListBuilder; use App\Builders\CategoryTreeList as CategoryTreeListBuilder;
use App\Models\Category as CategoryModel;
use Phalcon\Mvc\Model\Resultset;
class CategoryTreeList extends Cache class CategoryTreeList extends Cache
{ {
@ -23,31 +21,11 @@ class CategoryTreeList extends Cache
public function getContent($id = null) public function getContent($id = null)
{ {
/**
* @var Resultset $categories
*/
$categories = CategoryModel::query()
->where('published = 1 AND deleted = 0')
->execute();
if ($categories->count() == 0) {
return [];
}
return $this->handleContent($categories);
}
/**
* @param Resultset $categories
* @return array
*/
protected function handleContent($categories)
{
$items = $categories->toArray();
$builder = new CategoryTreeListBuilder(); $builder = new CategoryTreeListBuilder();
return $builder->handleTreeList($items); $list = $builder->handle();
return $list ?: [];
} }
} }

View File

@ -3,13 +3,11 @@
namespace App\Caches; namespace App\Caches;
use App\Builders\ChapterTreeList as ChapterTreeListBuilder; use App\Builders\ChapterTreeList as ChapterTreeListBuilder;
use App\Repos\Course as CourseRepo;
use Phalcon\Mvc\Model\Resultset;
class CourseChapterList extends Cache class CourseChapterList extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 7 * 86400;
public function getLifetime() public function getLifetime()
{ {
@ -23,28 +21,11 @@ class CourseChapterList extends Cache
public function getContent($id = null) public function getContent($id = null)
{ {
$courseRepo = new CourseRepo();
$chapters = $courseRepo->findChapters($id);
if ($chapters->count() == 0) {
return [];
}
return $this->handleContent($chapters);
}
/**
* @param Resultset $chapters
* @return array
*/
protected function handleContent($chapters)
{
$items = $chapters->toArray();
$builder = new ChapterTreeListBuilder(); $builder = new ChapterTreeListBuilder();
return $builder->handleTreeList($items); $list = $builder->handle($id);
return $list ?: [];
} }
} }

View File

@ -45,7 +45,6 @@ class CoursePackageList extends Cache
$result[] = [ $result[] = [
'id' => $package->id, 'id' => $package->id,
'title' => $package->title, 'title' => $package->title,
'summary' => $package->summary,
'market_price' => $package->market_price, 'market_price' => $package->market_price,
'vip_price' => $package->vip_price, 'vip_price' => $package->vip_price,
]; ];

View File

@ -0,0 +1,75 @@
<?php
namespace App\Caches;
use App\Models\Course as CourseModel;
use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface;
class CourseRecommendedList extends Cache
{
protected $lifetime = 1 * 86400;
public function getLifetime()
{
return $this->lifetime;
}
public function getKey($id = null)
{
return "course_recommended_list:{$id}";
}
public function getContent($id = null)
{
$courses = $this->findCourses(5);
if ($courses->count() == 0) {
return [];
}
return $this->handleContent($courses);
}
/**
* @param CourseModel[] $courses
* @return array
*/
public function handleContent($courses)
{
$result = [];
foreach ($courses as $course) {
$result[] = [
'id' => $course->id,
'title' => $course->title,
'cover' => $course->cover,
'market_price' => $course->market_price,
'vip_price' => $course->vip_price,
'rating' => $course->rating,
'model' => $course->model,
'level' => $course->level,
'user_count' => $course->user_count,
'lesson_count' => $course->lesson_count,
];
}
return $result;
}
/**
* @param int $limit
* @return ResultsetInterface|Resultset|CourseModel[]
*/
public function findCourses($limit = 5)
{
return CourseModel::query()
->where('published = 1 AND deleted = 0')
->orderBy('RAND()')
->limit($limit)
->execute();
}
}

View File

@ -47,7 +47,6 @@ class CourseTeacherList extends Cache
'name' => $user->name, 'name' => $user->name,
'avatar' => $user->avatar, 'avatar' => $user->avatar,
'title' => $user->title, 'title' => $user->title,
'about' => $user->about,
]; ];
} }

View File

@ -0,0 +1,67 @@
<?php
namespace App\Caches;
use App\Models\Topic as TopicModel;
use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface;
class CourseTopicList extends Cache
{
protected $lifetime = 1 * 86400;
public function getLifetime()
{
return $this->lifetime;
}
public function getKey($id = null)
{
return "course_topic_list:{$id}";
}
public function getContent($id = null)
{
$topics = $this->findTopics(5);
if ($topics->count() == 0) {
return [];
}
return $this->handleContent($topics);
}
/**
* @param TopicModel[] $topics
* @return array
*/
public function handleContent($topics)
{
$result = [];
foreach ($topics as $topic) {
$result[] = [
'id' => $topic->id,
'title' => $topic->title,
];
}
return $result;
}
/**
* @param int $limit
* @return ResultsetInterface|Resultset|TopicModel[]
*/
public function findTopics($limit = 5)
{
return TopicModel::query()
->where('published = 1 AND deleted = 0')
->orderBy('RAND()')
->limit($limit)
->execute();
}
}

View File

@ -4,7 +4,6 @@ namespace App\Caches;
use App\Models\Category as CategoryModel; use App\Models\Category as CategoryModel;
use App\Models\Course as CourseModel; use App\Models\Course as CourseModel;
use App\Repos\User as UserRepo;
use App\Services\Category as CategoryService; use App\Services\Category as CategoryService;
use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface; use Phalcon\Mvc\Model\ResultsetInterface;
@ -41,7 +40,7 @@ class IndexFreeCourseList extends Cache
$categories = $this->findCategories($categoryLimit); $categories = $this->findCategories($categoryLimit);
if ($categories->count() == 0) { if ($categories->count() == 0) {
return null; return [];
} }
foreach ($categories as $category) { foreach ($categories as $category) {
@ -57,21 +56,16 @@ class IndexFreeCourseList extends Cache
continue; continue;
} }
$teacherMappings = $this->getTeacherMappings($courses);
$categoryCourses = []; $categoryCourses = [];
foreach ($courses as $course) { foreach ($courses as $course) {
$teacher = $teacherMappings[$course->teacher_id];
$categoryCourses[] = [ $categoryCourses[] = [
'id' => $course->id, 'id' => $course->id,
'title' => $course->title, 'title' => $course->title,
'cover' => $course->cover, 'cover' => $course->cover,
'teacher' => $teacher,
'market_price' => $course->market_price, 'market_price' => $course->market_price,
'vip_price' => $course->vip_price, 'vip_price' => $course->vip_price,
'rating' => $course->rating,
'model' => $course->model, 'model' => $course->model,
'level' => $course->level, 'level' => $course->level,
'user_count' => $course->user_count, 'user_count' => $course->user_count,
@ -87,31 +81,6 @@ class IndexFreeCourseList extends Cache
return $result; return $result;
} }
/**
* @param Resultset|CourseModel[] $courses
* @return array
*/
protected function getTeacherMappings($courses)
{
$teacherIds = kg_array_column($courses->toArray(), 'teacher_id');
$userRepo = new UserRepo();
$teachers = $userRepo->findByIds($teacherIds);
$mappings = [];
foreach ($teachers as $teacher) {
$mappings[$teacher->id] = [
'id' => $teacher->id,
'name' => $teacher->name,
'avatar' => $teacher->avatar,
];
}
return $mappings;
}
/** /**
* @param int $limit * @param int $limit
* @return ResultsetInterface|Resultset|CategoryModel[] * @return ResultsetInterface|Resultset|CategoryModel[]

View File

@ -5,7 +5,6 @@ namespace App\Caches;
use App\Models\ChapterLive as ChapterLiveModel; use App\Models\ChapterLive as ChapterLiveModel;
use App\Repos\Chapter as ChapterRepo; use App\Repos\Chapter as ChapterRepo;
use App\Repos\Course as CourseRepo; use App\Repos\Course as CourseRepo;
use App\Repos\User as UserRepo;
use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\Resultset;
/** /**
@ -44,8 +43,6 @@ class IndexLiveList extends Cache
$beginTime = strtotime('today'); $beginTime = strtotime('today');
$endTime = strtotime("+30 days"); $endTime = strtotime("+30 days");
$result = [];
/** /**
* @var Resultset|ChapterLiveModel[] $lives * @var Resultset|ChapterLiveModel[] $lives
*/ */
@ -55,9 +52,11 @@ class IndexLiveList extends Cache
->execute(); ->execute();
if ($lives->count() == 0) { if ($lives->count() == 0) {
return $result; return [];
} }
$result = [];
$chapterIds = kg_array_column($lives->toArray(), 'chapter_id'); $chapterIds = kg_array_column($lives->toArray(), 'chapter_id');
$chapterRepo = new ChapterRepo(); $chapterRepo = new ChapterRepo();
@ -82,18 +81,6 @@ class IndexLiveList extends Cache
$courseMappings[$course->id] = $course; $courseMappings[$course->id] = $course;
} }
$teacherIds = kg_array_column($courses->toArray(), 'teacher_id');
$userRepo = new UserRepo();
$teachers = $userRepo->findByIds($teacherIds);
$teacherMappings = [];
foreach ($teachers as $teacher) {
$teacherMappings[$teacher->id] = $teacher;
}
foreach ($lives as $live) { foreach ($lives as $live) {
if (count($result) >= $dayLimit) { if (count($result) >= $dayLimit) {
@ -108,7 +95,6 @@ class IndexLiveList extends Cache
$chapter = $chapterMappings[$live->chapter_id]; $chapter = $chapterMappings[$live->chapter_id];
$course = $courseMappings[$chapter->course_id]; $course = $courseMappings[$chapter->course_id];
$teacher = $teacherMappings[$course->teacher_id];
$chapterInfo = [ $chapterInfo = [
'id' => $chapter->id, 'id' => $chapter->id,
@ -121,13 +107,9 @@ class IndexLiveList extends Cache
'id' => $course->id, 'id' => $course->id,
'title' => $course->title, 'title' => $course->title,
'cover' => $course->cover, 'cover' => $course->cover,
'teacher' => [
'id' => $teacher->id,
'name' => $teacher->name,
'avatar' => $teacher->avatar,
],
'market_price' => $course->market_price, 'market_price' => $course->market_price,
'vip_price' => $course->vip_price, 'vip_price' => $course->vip_price,
'rating' => $course->rating,
'model' => $course->model, 'model' => $course->model,
'level' => $course->level, 'level' => $course->level,
'user_count' => $course->user_count, 'user_count' => $course->user_count,

View File

@ -4,7 +4,6 @@ namespace App\Caches;
use App\Models\Category as CategoryModel; use App\Models\Category as CategoryModel;
use App\Models\Course as CourseModel; use App\Models\Course as CourseModel;
use App\Repos\User as UserRepo;
use App\Services\Category as CategoryService; use App\Services\Category as CategoryService;
use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface; use Phalcon\Mvc\Model\ResultsetInterface;
@ -41,7 +40,7 @@ class IndexNewCourseList extends Cache
$categories = $this->findCategories($categoryLimit); $categories = $this->findCategories($categoryLimit);
if ($categories->count() == 0) { if ($categories->count() == 0) {
return null; return [];
} }
foreach ($categories as $category) { foreach ($categories as $category) {
@ -57,21 +56,16 @@ class IndexNewCourseList extends Cache
continue; continue;
} }
$teacherMappings = $this->getTeacherMappings($courses);
$categoryCourses = []; $categoryCourses = [];
foreach ($courses as $course) { foreach ($courses as $course) {
$teacher = $teacherMappings[$course->teacher_id];
$categoryCourses[] = [ $categoryCourses[] = [
'id' => $course->id, 'id' => $course->id,
'title' => $course->title, 'title' => $course->title,
'cover' => $course->cover, 'cover' => $course->cover,
'teacher' => $teacher,
'market_price' => $course->market_price, 'market_price' => $course->market_price,
'vip_price' => $course->vip_price, 'vip_price' => $course->vip_price,
'rating' => $course->rating,
'model' => $course->model, 'model' => $course->model,
'level' => $course->level, 'level' => $course->level,
'user_count' => $course->user_count, 'user_count' => $course->user_count,
@ -87,31 +81,6 @@ class IndexNewCourseList extends Cache
return $result; return $result;
} }
/**
* @param Resultset|CourseModel[] $courses
* @return array
*/
protected function getTeacherMappings($courses)
{
$teacherIds = kg_array_column($courses->toArray(), 'teacher_id');
$userRepo = new UserRepo();
$teachers = $userRepo->findByIds($teacherIds);
$mappings = [];
foreach ($teachers as $teacher) {
$mappings[$teacher->id] = [
'id' => $teacher->id,
'name' => $teacher->name,
'avatar' => $teacher->avatar,
];
}
return $mappings;
}
/** /**
* @param int $limit * @param int $limit
* @return ResultsetInterface|Resultset|CategoryModel[] * @return ResultsetInterface|Resultset|CategoryModel[]

View File

@ -4,7 +4,6 @@ namespace App\Caches;
use App\Models\Category as CategoryModel; use App\Models\Category as CategoryModel;
use App\Models\Course as CourseModel; use App\Models\Course as CourseModel;
use App\Repos\User as UserRepo;
use App\Services\Category as CategoryService; use App\Services\Category as CategoryService;
use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface; use Phalcon\Mvc\Model\ResultsetInterface;
@ -41,7 +40,7 @@ class IndexVipCourseList extends Cache
$categories = $this->findCategories($categoryLimit); $categories = $this->findCategories($categoryLimit);
if ($categories->count() == 0) { if ($categories->count() == 0) {
return null; return [];
} }
foreach ($categories as $category) { foreach ($categories as $category) {
@ -57,21 +56,16 @@ class IndexVipCourseList extends Cache
continue; continue;
} }
$teacherMappings = $this->getTeacherMappings($courses);
$categoryCourses = []; $categoryCourses = [];
foreach ($courses as $course) { foreach ($courses as $course) {
$teacher = $teacherMappings[$course->teacher_id];
$categoryCourses[] = [ $categoryCourses[] = [
'id' => $course->id, 'id' => $course->id,
'title' => $course->title, 'title' => $course->title,
'cover' => $course->cover, 'cover' => $course->cover,
'teacher' => $teacher,
'market_price' => $course->market_price, 'market_price' => $course->market_price,
'vip_price' => $course->vip_price, 'vip_price' => $course->vip_price,
'rating' => $course->rating,
'model' => $course->model, 'model' => $course->model,
'level' => $course->level, 'level' => $course->level,
'user_count' => $course->user_count, 'user_count' => $course->user_count,
@ -87,31 +81,6 @@ class IndexVipCourseList extends Cache
return $result; return $result;
} }
/**
* @param Resultset|CourseModel[] $courses
* @return array
*/
protected function getTeacherMappings($courses)
{
$teacherIds = kg_array_column($courses->toArray(), 'teacher_id');
$userRepo = new UserRepo();
$teachers = $userRepo->findByIds($teacherIds);
$mappings = [];
foreach ($teachers as $teacher) {
$mappings[$teacher->id] = [
'id' => $teacher->id,
'name' => $teacher->name,
'avatar' => $teacher->avatar,
];
}
return $mappings;
}
/** /**
* @param int $limit * @param int $limit
* @return ResultsetInterface|Resultset|CategoryModel[] * @return ResultsetInterface|Resultset|CategoryModel[]

View File

@ -3,8 +3,6 @@
namespace App\Caches; namespace App\Caches;
use App\Builders\NavTreeList as NavTreeListBuilder; use App\Builders\NavTreeList as NavTreeListBuilder;
use App\Models\Nav as NavModel;
use Phalcon\Mvc\Model\Resultset;
class NavTreeList extends Cache class NavTreeList extends Cache
{ {
@ -23,45 +21,11 @@ class NavTreeList extends Cache
public function getContent($id = null) public function getContent($id = null)
{ {
/**
* @var Resultset $navs
*/
$navs = NavModel::query()
->where('published = 1 AND deleted = 0')
->orderBy('position ASC, priority ASC')
->execute();
if ($navs->count() == 0) {
return [];
}
return $this->handleContent($navs);
}
/**
* @param Resultset $navs
* @return array
*/
protected function handleContent($navs)
{
$list = [
'top' => [],
'bottom' => [],
];
foreach ($navs->toArray() as $nav) {
if ($nav['position'] == 'top') {
$list['top'][] = $nav;
} elseif ($nav['position'] == 'bottom') {
$list['bottom'][] = $nav;
}
}
$builder = new NavTreeListBuilder(); $builder = new NavTreeListBuilder();
return [ return [
'top' => $builder->handleTreeList($list['top']), 'top' => $builder->handle('top'),
'bottom' => $builder->handleTreeList($list['bottom']), 'bottom' => $builder->handle('bottom'),
]; ];
} }

View File

@ -4,8 +4,6 @@ namespace App\Caches;
use App\Models\Course as CourseModel; use App\Models\Course as CourseModel;
use App\Repos\Package as PackageRepo; use App\Repos\Package as PackageRepo;
use App\Repos\User as UserRepo;
use Phalcon\Mvc\Model\Resultset;
class PackageCourseList extends Cache class PackageCourseList extends Cache
{ {
@ -43,17 +41,11 @@ class PackageCourseList extends Cache
{ {
$result = []; $result = [];
$teacherMappings = $this->getTeacherMappings($courses);
foreach ($courses as $course) { foreach ($courses as $course) {
$teacher = $teacherMappings[$course->teacher_id];
$result[] = [ $result[] = [
'id' => $course->id, 'id' => $course->id,
'title' => $course->title, 'title' => $course->title,
'cover' => $course->cover, 'cover' => $course->cover,
'teacher' => $teacher,
'market_price' => $course->market_price, 'market_price' => $course->market_price,
'vip_price' => $course->vip_price, 'vip_price' => $course->vip_price,
'rating' => $course->rating, 'rating' => $course->rating,
@ -67,29 +59,4 @@ class PackageCourseList extends Cache
return $result; return $result;
} }
/**
* @param Resultset|CourseModel[] $courses
* @return array
*/
protected function getTeacherMappings($courses)
{
$teacherIds = kg_array_column($courses->toArray(), 'teacher_id');
$userRepo = new UserRepo();
$teachers = $userRepo->findByIds($teacherIds);
$mappings = [];
foreach ($teachers as $teacher) {
$mappings[$teacher->id] = [
'id' => $teacher->id,
'name' => $teacher->name,
'avatar' => $teacher->avatar,
];
}
return $mappings;
}
} }

View File

@ -4,8 +4,6 @@ namespace App\Caches;
use App\Models\Course as CourseModel; use App\Models\Course as CourseModel;
use App\Repos\Topic as TopicRepo; use App\Repos\Topic as TopicRepo;
use App\Repos\User as UserRepo;
use Phalcon\Mvc\Model\Resultset;
class TopicCourseList extends Cache class TopicCourseList extends Cache
{ {
@ -43,17 +41,11 @@ class TopicCourseList extends Cache
{ {
$result = []; $result = [];
$teacherMappings = $this->getTeacherMappings($courses);
foreach ($courses as $course) { foreach ($courses as $course) {
$teacher = $teacherMappings[$course->teacher_id];
$result[] = [ $result[] = [
'id' => $course->id, 'id' => $course->id,
'title' => $course->title, 'title' => $course->title,
'cover' => $course->cover, 'cover' => $course->cover,
'teacher' => $teacher,
'market_price' => $course->market_price, 'market_price' => $course->market_price,
'vip_price' => $course->vip_price, 'vip_price' => $course->vip_price,
'rating' => $course->rating, 'rating' => $course->rating,
@ -67,29 +59,4 @@ class TopicCourseList extends Cache
return $result; return $result;
} }
/**
* @param Resultset|CourseModel[] $courses
* @return array
*/
protected function getTeacherMappings($courses)
{
$teacherIds = kg_array_column($courses->toArray(), 'teacher_id');
$userRepo = new UserRepo();
$teachers = $userRepo->findByIds($teacherIds);
$mappings = [];
foreach ($teachers as $teacher) {
$mappings[$teacher->id] = [
'id' => $teacher->id,
'name' => $teacher->name,
'avatar' => $teacher->avatar,
];
}
return $mappings;
}
} }

View File

@ -105,7 +105,7 @@ class OrderTask extends Task
$courseUser = new CourseUserModel(); $courseUser = new CourseUserModel();
if ($courseUser->create($data) === false) { if ($courseUser->create($data) === false) {
throw new \RuntimeException('Create Course User Failed'); throw new \RuntimeException('Create CourseQuery User Failed');
} }
$this->handleCourseHistory($data['course_id'], $data['user_id']); $this->handleCourseHistory($data['course_id'], $data['user_id']);
@ -134,7 +134,7 @@ class OrderTask extends Task
$courseUser = new CourseUserModel(); $courseUser = new CourseUserModel();
if ($courseUser->create($data) === false) { if ($courseUser->create($data) === false) {
throw new \RuntimeException('Create Course User Failed'); throw new \RuntimeException('Create CourseQuery User Failed');
} }
$this->handleCourseHistory($data['course_id'], $data['user_id']); $this->handleCourseHistory($data['course_id'], $data['user_id']);

View File

@ -183,7 +183,7 @@ class RefundTask extends Task
$courseUser->deleted = 1; $courseUser->deleted = 1;
if ($courseUser->update() === false) { if ($courseUser->update() === false) {
throw new \RuntimeException('Delete Course User Failed'); throw new \RuntimeException('Delete CourseQuery User Failed');
} }
} }
} }
@ -211,7 +211,7 @@ class RefundTask extends Task
$courseUser->deleted = 1; $courseUser->deleted = 1;
if ($courseUser->update() === false) { if ($courseUser->update() === false) {
throw new \RuntimeException('Delete Course User Failed'); throw new \RuntimeException('Delete CourseQuery User Failed');
} }
} }
} }

View File

@ -54,12 +54,12 @@ class AccountController extends Controller
$service->register(); $service->register();
$location = $this->request->getHTTPReferer(); $content = [
'location' => $this->request->getHTTPReferer(),
return $this->jsonSuccess([
'location' => $location,
'msg' => '注册账户成功', 'msg' => '注册账户成功',
]); ];
return $this->jsonSuccess($content);
} }
} }

View File

@ -2,13 +2,18 @@
namespace App\Http\Web\Controllers; namespace App\Http\Web\Controllers;
use App\Http\Web\Services\Course as CourseService; use App\Http\Web\Services\CourseQuery as CourseQueryService;
use App\Services\Frontend\Course\ChapterList as CourseChapterListService;
use App\Services\Frontend\Course\ConsultList as CourseConsultListService; use App\Services\Frontend\Course\ConsultList as CourseConsultListService;
use App\Services\Frontend\Course\CourseFavorite as CourseFavoriteService;
use App\Services\Frontend\Course\CourseInfo as CourseInfoService; use App\Services\Frontend\Course\CourseInfo as CourseInfoService;
use App\Services\Frontend\Course\CourseList as CourseListService; use App\Services\Frontend\Course\CourseList as CourseListService;
use App\Services\Frontend\Course\CourseRelated as CourseRelatedService; use App\Services\Frontend\Course\Favorite as CourseFavoriteService;
use App\Services\Frontend\Course\PackageList as CoursePackageListService;
use App\Services\Frontend\Course\RecommendedList as CourseRecommendedListService;
use App\Services\Frontend\Course\RelatedList as CourseRelatedListService;
use App\Services\Frontend\Course\ReviewList as CourseReviewListService; use App\Services\Frontend\Course\ReviewList as CourseReviewListService;
use App\Services\Frontend\Course\TeacherList as CourseTeacherListService;
use App\Services\Frontend\Course\TopicList as CourseTopicListService;
/** /**
* @RoutePrefix("/course") * @RoutePrefix("/course")
@ -25,17 +30,19 @@ class CourseController extends Controller
$pager = $courseListService->handle(); $pager = $courseListService->handle();
$courseService = new CourseService(); $courseQueryService = new CourseQueryService();
$topCategories = $courseService->handleTopCategories(); $topCategories = $courseQueryService->handleTopCategories();
$subCategories = $courseService->handleSubCategories(); $subCategories = $courseQueryService->handleSubCategories();
$levels = $courseService->handleLevels(); $models = $courseQueryService->handleModels();
$levels = $courseQueryService->handleLevels();
dd($topCategories, $subCategories, $levels); $sorts = $courseQueryService->handleSorts();
$this->view->setVar('top_categories', $topCategories); $this->view->setVar('top_categories', $topCategories);
$this->view->setVar('sub_categories', $subCategories); $this->view->setVar('sub_categories', $subCategories);
$this->view->setVar('models', $models);
$this->view->setVar('levels', $levels); $this->view->setVar('levels', $levels);
$this->view->setVar('sorts', $sorts);
$this->view->setVar('pager', $pager); $this->view->setVar('pager', $pager);
} }
@ -46,14 +53,81 @@ class CourseController extends Controller
{ {
$courseInfoService = new CourseInfoService(); $courseInfoService = new CourseInfoService();
$courseInfo = $courseInfoService->handle($id); $course = $courseInfoService->handle($id);
$courseRelatedService = new CourseRelatedService(); $this->view->setVar('course', $course);
}
$relatedCourses = $courseRelatedService->handle($id); /**
* @Get("/{id:[0-9]+}/teachers", name="web.course.teachers")
*/
public function teachersAction($id)
{
$service = new CourseTeacherListService();
$this->view->setVar('course_info', $courseInfo); $teachers = $service->handle($id);
$this->view->setVar('related_courses', $relatedCourses);
return $this->jsonSuccess(['teachers' => $teachers]);
}
/**
* @Get("/{id:[0-9]+}/chapters", name="web.course.chapters")
*/
public function chaptersAction($id)
{
$service = new CourseChapterListService();
$chapters = $service->handle($id);
return $this->jsonSuccess(['chapters' => $chapters]);
}
/**
* @Get("/{id:[0-9]+}/packages", name="web.course.packages")
*/
public function packagesAction($id)
{
$service = new CoursePackageListService();
$packages = $service->handle($id);
return $this->jsonSuccess(['packages' => $packages]);
}
/**
* @Get("/{id:[0-9]+}/recommended", name="web.course.recommended")
*/
public function recommendedAction($id)
{
$service = new CourseRecommendedListService();
$courses = $service->handle($id);
return $this->jsonSuccess(['courses' => $courses]);
}
/**
* @Get("/{id:[0-9]+}/related", name="web.course.related")
*/
public function relatedAction($id)
{
$service = new CourseRelatedListService();
$courses = $service->handle($id);
return $this->jsonSuccess(['courses' => $courses]);
}
/**
* @Get("/{id:[0-9]+}/topics", name="web.course.topics")
*/
public function topicsAction($id)
{
$service = new CourseTopicListService();
$topics = $service->handle($id);
return $this->jsonSuccess(['topics' => $topics]);
} }
/** /**

View File

@ -17,11 +17,11 @@ class IndexController extends Controller
$indexService = new IndexService(); $indexService = new IndexService();
$this->view->setVar('slide_list', $indexService->getSlideList()); $this->view->setVar('slides', $indexService->getSlides());
$this->view->setVar('live_list', $indexService->getLiveList()); $this->view->setVar('lives', $indexService->getLives());
$this->view->setVar('new_course_list', $indexService->getNewCourseList()); $this->view->setVar('new_courses', $indexService->getNewCourses());
$this->view->setVar('free_course_list', $indexService->getFreeCourseList()); $this->view->setVar('free_courses', $indexService->getFreeCourses());
$this->view->setVar('vip_course_list', $indexService->getVipCourseList()); $this->view->setVar('vip_courses', $indexService->getVipCourses());
} }
} }

View File

@ -5,9 +5,16 @@ namespace App\Http\Web\Services;
use App\Models\Course as CourseModel; use App\Models\Course as CourseModel;
use App\Services\Category as CategoryService; use App\Services\Category as CategoryService;
class Course extends Service class CourseQuery extends Service
{ {
protected $baseUrl;
public function __construct()
{
$this->baseUrl = $this->url->get(['for' => 'web.course.list']);
}
public function handleTopCategories() public function handleTopCategories()
{ {
$params = $this->getQueryParams(); $params = $this->getQueryParams();
@ -92,22 +99,50 @@ class Course extends Service
return $result; return $result;
} }
public function handleLevels() public function handleModels()
{ {
$params = $this->getQueryParams(); $params = $this->getQueryParams();
$defaultParams = $params; if (isset($params['model'])) {
unset($params['model']);
if (isset($defaultParams['level'])) {
unset($defaultParams['level']);
} }
$baseUrl = $this->url->get(['for' => 'web.course.list']);
$defaultItem = [ $defaultItem = [
'id' => 0, 'id' => 0,
'name' => '全部', 'name' => '全部',
'href' => $baseUrl . $this->buildQueryParams($defaultParams), 'href' => $this->baseUrl . $this->buildQueryParams($params),
];
$result = [];
$result[] = $defaultItem;
$models = CourseModel::modelTypes();
foreach ($models as $key => $value) {
$params['model'] = $key;
$result[] = [
'id' => $key,
'name' => $value,
'href' => $this->baseUrl . $this->buildQueryParams($params),
];
}
return $result;
}
public function handleLevels()
{
$params = $this->getQueryParams();
if (isset($params['level'])) {
unset($params['level']);
}
$defaultItem = [
'id' => 0,
'name' => '全部',
'href' => $this->baseUrl . $this->buildQueryParams($params),
]; ];
$result = []; $result = [];
@ -121,7 +156,7 @@ class Course extends Service
$result[] = [ $result[] = [
'id' => $key, 'id' => $key,
'name' => $value, 'name' => $value,
'href' => $baseUrl . $this->buildQueryParams($params), 'href' => $this->baseUrl . $this->buildQueryParams($params),
]; ];
} }
@ -130,6 +165,22 @@ class Course extends Service
public function handleSorts() public function handleSorts()
{ {
$params = $this->getQueryParams();
$result = [];
$sorts = CourseModel::sortTypes();
foreach ($sorts as $key => $value) {
$params['sort'] = $key;
$result[] = [
'id' => $key,
'name' => $value,
'href' => $this->baseUrl . $this->buildQueryParams($params),
];
}
return $result;
} }
protected function getQueryParams() protected function getQueryParams()
@ -138,18 +189,33 @@ class Course extends Service
$params = []; $params = [];
$validator = new \App\Validators\CourseQuery();
if (!empty($query['tc'])) { if (!empty($query['tc'])) {
$validator->checkTopCategory($query['tc']);
$params['tc'] = $query['tc']; $params['tc'] = $query['tc'];
} }
if (!empty($query['sc'])) { if (!empty($query['sc'])) {
$validator->checkSubCategory($query['sc']);
$params['sc'] = $query['sc']; $params['sc'] = $query['sc'];
} }
if (!empty($query['model'])) {
$validator->checkModel($query['model']);
$params['model'] = $query['model'];
}
if (!empty($query['level'])) { if (!empty($query['level'])) {
$validator->checkLevel($query['level']);
$params['level'] = $query['level']; $params['level'] = $query['level'];
} }
if (!empty($query['sort'])) {
$validator->checkSort($query['sort']);
$params['sort'] = $query['sort'];
}
return $params; return $params;
} }

View File

@ -2,46 +2,46 @@
namespace App\Http\Web\Services; namespace App\Http\Web\Services;
use App\Caches\IndexFreeCourseList; use App\Caches\IndexFreeCourseList as IndexFreeCourseListCache;
use App\Caches\IndexLiveList; use App\Caches\IndexLiveList as IndexLiveListCache;
use App\Caches\IndexNewCourseList; use App\Caches\IndexNewCourseList as IndexNewCourseListCache;
use App\Caches\IndexSlideList; use App\Caches\IndexSlideList as IndexSlideListCache;
use App\Caches\IndexVipCourseList; use App\Caches\IndexVipCourseList as IndexVipCourseListCache;
class Index extends Service class Index extends Service
{ {
public function getSlideList() public function getSlides()
{ {
$cache = new IndexSlideList(); $cache = new IndexSlideListCache();
return $cache->get(); return $cache->get();
} }
public function getLiveList() public function getLives()
{ {
$cache = new IndexLiveList(); $cache = new IndexLiveListCache();
return $cache->get(); return $cache->get();
} }
public function getNewCourseList() public function getNewCourses()
{ {
$cache = new IndexNewCourseList(); $cache = new IndexNewCourseListCache();
return $cache->get(); return $cache->get();
} }
public function getFreeCourseList() public function getFreeCourses()
{ {
$cache = new IndexFreeCourseList(); $cache = new IndexFreeCourseListCache();
return $cache->get(); return $cache->get();
} }
public function getVipCourseList() public function getVipCourses()
{ {
$cache = new IndexVipCourseList(); $cache = new IndexVipCourseListCache();
return $cache->get(); return $cache->get();
} }

View File

@ -342,6 +342,15 @@ class Course extends Model
]; ];
} }
public static function sortTypes()
{
return [
'score' => '综合',
'rating' => '好评',
'pop' => '人气',
];
}
public static function studyExpiryOptions() public static function studyExpiryOptions()
{ {
return [ return [

View File

@ -83,11 +83,14 @@ class Course extends Repository
} }
switch ($sort) { switch ($sort) {
case 'score':
$orderBy = 'c.score DESC';
break;
case 'rating': case 'rating':
$orderBy = 'c.rating DESC'; $orderBy = 'c.rating DESC';
break; break;
case 'score': case 'pop':
$orderBy = 'c.score DESC'; $orderBy = 'c.user_count DESC';
break; break;
default: default:
$orderBy = 'c.id DESC'; $orderBy = 'c.id DESC';

View File

@ -2,82 +2,65 @@
namespace App\Services\Frontend\Course; namespace App\Services\Frontend\Course;
use App\Builders\ChapterTreeList as ChapterListBuilder; use App\Caches\CourseChapterList as CourseChapterListCache;
use App\Models\Course as CourseModel; use App\Models\Course as CourseModel;
use App\Models\User as UserModel; use App\Models\User as UserModel;
use App\Repos\Course as CourseRepo; use App\Repos\Course as CourseRepo;
use App\Services\Frontend\CourseTrait; use App\Services\Frontend\CourseTrait;
use App\Services\Frontend\Service; use App\Services\Frontend\Service;
use Phalcon\Mvc\Model\Resultset;
class ChapterList extends Service class ChapterList extends Service
{ {
use CourseTrait; use CourseTrait;
/** public function handle($id)
* @var CourseModel
*/
protected $course;
/**
* @var UserModel
*/
protected $user;
public function getChapters($id)
{ {
$this->course = $this->checkCourse($id); $course = $this->checkCourse($id);
$this->user = $this->getCurrentUser(); $user = $this->getCurrentUser();
$this->setCourseUser($this->course, $this->user); $this->setCourseUser($course, $user);
$courseRepo = new CourseRepo(); return $this->getChapters($course, $user);
$chapters = $courseRepo->findChapters($id);
return $this->handleChapters($chapters);
} }
/** protected function getChapters(CourseModel $course, UserModel $user)
* @param Resultset $chapters
* @return array
*/
protected function handleChapters($chapters)
{ {
if ($chapters->count() == 0) { $cache = new CourseChapterListCache();
$chapters = $cache->get($course->id);
if (empty($chapters)) {
return []; return [];
} }
$builder = new ChapterListBuilder(); if ($user->id == 0) {
foreach ($chapters as &$chapter) {
$items = $chapters->toArray(); foreach ($chapter['children'] as &$lesson) {
$lesson['me'] = [
$treeList = $builder->handleTreeList($items); 'owned' => $this->ownedCourse || $lesson['free'] ? 1 : 0,
'progress' => 0,
$learningMapping = $this->getLearningMapping($this->course, $this->user); ];
}
foreach ($treeList as &$chapter) { }
foreach ($chapter['children'] as &$lesson) { } else {
$owned = ($this->ownedCourse || $lesson['free']) ? 1 : 0; $mapping = $this->getLearningMapping($course, $user);
$progress = $learningMapping[$lesson['id']]['progress'] ?? 0; foreach ($chapters as &$chapter) {
$lesson['me'] = [ foreach ($chapter['children'] as &$lesson) {
'owned' => $owned, $lesson['me'] = [
'progress' => $progress, 'owned' => $this->ownedCourse || $lesson['free'] ? 1 : 0,
]; 'progress' => $mapping[$lesson['id']]['progress'] ?? 0,
];
}
} }
} }
return $treeList; return $chapters;
} }
protected function getLearningMapping(CourseModel $course, UserModel $user) protected function getLearningMapping(CourseModel $course, UserModel $user)
{ {
if ($user->id == 0) {
return [];
}
$courseRepo = new CourseRepo(); $courseRepo = new CourseRepo();
$userLearnings = $courseRepo->findUserLearnings($course->id, $user->id); $userLearnings = $courseRepo->findUserLearnings($course->id, $user->id);

View File

@ -11,7 +11,6 @@ use App\Repos\Consult as ConsultRepo;
use App\Repos\Course as CourseRepo; use App\Repos\Course as CourseRepo;
use App\Services\Frontend\CourseTrait; use App\Services\Frontend\CourseTrait;
use App\Services\Frontend\Service; use App\Services\Frontend\Service;
use Phalcon\Mvc\Model\Resultset;
class ConsultList extends Service class ConsultList extends Service
{ {
@ -28,9 +27,9 @@ class ConsultList extends Service
use CourseTrait; use CourseTrait;
public function handle($courseId) public function handle($id)
{ {
$this->course = $this->checkCourse($courseId); $this->course = $this->checkCourse($id);
$this->user = $this->getCurrentUser(); $this->user = $this->getCurrentUser();
@ -65,7 +64,7 @@ class ConsultList extends Service
$users = $builder->getUsers($consults); $users = $builder->getUsers($consults);
$votes = $this->getConsultVotes($this->course->id, $this->user->id); $votes = $this->getConsultVotes($this->course, $this->user);
$items = []; $items = [];
@ -95,18 +94,15 @@ class ConsultList extends Service
return $pager; return $pager;
} }
protected function getConsultVotes($courseId, $userId) protected function getConsultVotes(CourseModel $course, UserModel $user)
{ {
if (!$courseId || !$userId) { if ($course->id == 0 || !$user->id == 0) {
return []; return [];
} }
$courseRepo = new CourseRepo(); $courseRepo = new CourseRepo();
/** $votes = $courseRepo->findUserConsultVotes($course->id, $user->id);
* @var Resultset $votes
*/
$votes = $courseRepo->findUserConsultVotes($courseId, $userId);
if ($votes->count() == 0) { if ($votes->count() == 0) {
return []; return [];

View File

@ -2,11 +2,8 @@
namespace App\Services\Frontend\Course; namespace App\Services\Frontend\Course;
use App\Caches\CourseChapterList as CourseChapterListCache;
use App\Caches\CourseTeacherList as CourseTeacherListCache;
use App\Models\Course as CourseModel; use App\Models\Course as CourseModel;
use App\Models\User as UserModel; use App\Models\User as UserModel;
use App\Repos\Course as CourseRepo;
use App\Repos\CourseFavorite as CourseFavoriteRepo; use App\Repos\CourseFavorite as CourseFavoriteRepo;
use App\Services\Category as CategoryService; use App\Services\Category as CategoryService;
use App\Services\Frontend\CourseTrait; use App\Services\Frontend\CourseTrait;
@ -80,77 +77,17 @@ class CourseInfo extends Service
$me['owned'] = $this->ownedCourse ? 1 : 0; $me['owned'] = $this->ownedCourse ? 1 : 0;
} }
$result['category_paths'] = $this->getCategoryPaths($course); $result['paths'] = $this->getPaths($course);
$result['teachers'] = $this->getTeachers($course);
$result['chapters'] = $this->getChapters($course, $user);
$result['me'] = $me; $result['me'] = $me;
return $result; return $result;
} }
protected function getCategoryPaths(CourseModel $course) protected function getPaths(CourseModel $course)
{ {
$service = new CategoryService(); $service = new CategoryService();
return $service->getCategoryPaths($course->category_id); return $service->getCategoryPaths($course->category_id);
} }
protected function getTeachers(CourseModel $course)
{
$cache = new CourseTeacherListCache();
return $cache->get($course->id);
}
protected function getChapters(CourseModel $course, UserModel $user)
{
$cache = new CourseChapterListCache();
$chapters = $cache->get($course->id);
if ($user->id == 0) {
foreach ($chapters as &$chapter) {
foreach ($chapter['children'] as &$lesson) {
$lesson['me'] = [
'owned' => $this->ownedCourse || $lesson['free'] ? 1 : 0,
'progress' => 0,
];
}
}
} else {
$mapping = $this->getLearningMapping($course, $user);
foreach ($chapters as &$chapter) {
foreach ($chapter['children'] as &$lesson) {
$lesson['me'] = [
'owned' => $this->ownedCourse || $lesson['free'] ? 1 : 0,
'progress' => $mapping[$lesson['id']]['progress'] ?? 0,
];
}
}
}
return $chapters;
}
protected function getLearningMapping(CourseModel $course, UserModel $user)
{
$courseRepo = new CourseRepo();
$userLearnings = $courseRepo->findUserLearnings($course->id, $user->id);
if ($userLearnings->count() == 0) {
return [];
}
$mapping = [];
foreach ($userLearnings as $learning) {
$mapping[$learning['chapter_id']] = [
'progress' => $learning['progress'],
];
}
return $mapping;
}
} }

View File

@ -67,7 +67,6 @@ class CourseList extends Service
'id' => $course['id'], 'id' => $course['id'],
'title' => $course['title'], 'title' => $course['title'],
'cover' => $course['cover'], 'cover' => $course['cover'],
'summary' => $course['summary'],
'market_price' => (float)$course['market_price'], 'market_price' => (float)$course['market_price'],
'vip_price' => (float)$course['vip_price'], 'vip_price' => (float)$course['vip_price'],
'rating' => (float)$course['rating'], 'rating' => (float)$course['rating'],

View File

@ -3,14 +3,14 @@
namespace App\Services\Frontend\Course; namespace App\Services\Frontend\Course;
use App\Models\Course as CourseModel; use App\Models\Course as CourseModel;
use App\Models\CourseFavorite as FavoriteModel; use App\Models\CourseFavorite as CourseFavoriteModel;
use App\Models\User as UserModel; use App\Models\User as UserModel;
use App\Repos\CourseFavorite as CourseFavoriteRepo; use App\Repos\CourseFavorite as CourseFavoriteRepo;
use App\Services\Frontend\CourseTrait; use App\Services\Frontend\CourseTrait;
use App\Services\Frontend\Service; use App\Services\Frontend\Service;
use App\Validators\UserDailyLimit as UserDailyLimitValidator; use App\Validators\UserDailyLimit as UserDailyLimitValidator;
class CourseFavorite extends Service class Favorite extends Service
{ {
use CourseTrait; use CourseTrait;
@ -31,7 +31,7 @@ class CourseFavorite extends Service
if (!$favorite) { if (!$favorite) {
$favorite = new FavoriteModel(); $favorite = new CourseFavoriteModel();
$favorite->course_id = $course->id; $favorite->course_id = $course->id;
$favorite->user_id = $user->id; $favorite->user_id = $user->id;

View File

@ -20,7 +20,7 @@ class PackageList extends Service
$packages = $cache->get($course->id); $packages = $cache->get($course->id);
if (!$packages) { if (empty($packages)) {
return []; return [];
} }
@ -28,7 +28,7 @@ class PackageList extends Service
$result = []; $result = [];
foreach ($packages->toArray() as $package) { foreach ($packages as $package) {
$courses = $cache->get($package['id']); $courses = $cache->get($package['id']);

View File

@ -0,0 +1,25 @@
<?php
namespace App\Services\Frontend\Course;
use App\Caches\CourseRecommendedList as CourseRecommendedListCache;
use App\Services\Frontend\CourseTrait;
use App\Services\Frontend\Service;
class RecommendedList extends Service
{
use CourseTrait;
public function handle($id)
{
$course = $this->checkCourse($id);
$cache = new CourseRecommendedListCache();
$result = $cache->get($course->id);
return $result ?: [];
}
}

View File

@ -6,7 +6,7 @@ use App\Caches\CourseRelatedList as CourseRelatedListCache;
use App\Services\Frontend\CourseTrait; use App\Services\Frontend\CourseTrait;
use App\Services\Frontend\Service; use App\Services\Frontend\Service;
class CourseRelated extends Service class RelatedList extends Service
{ {
use CourseTrait; use CourseTrait;

View File

@ -64,7 +64,7 @@ class ReviewList extends Service
$users = $builder->getUsers($reviews); $users = $builder->getUsers($reviews);
$votes = $this->getReviewVotes($this->course->id, $this->user->id); $votes = $this->getReviewVotes($this->course, $this->user);
$items = []; $items = [];
@ -94,15 +94,15 @@ class ReviewList extends Service
return $pager; return $pager;
} }
protected function getReviewVotes($courseId, $userId) protected function getReviewVotes(CourseModel $course, UserModel $user)
{ {
if (!$courseId || !$userId) { if ($course->id == 0 || $user->id == 0) {
return []; return [];
} }
$courseRepo = new CourseRepo(); $courseRepo = new CourseRepo();
$votes = $courseRepo->findUserReviewVotes($courseId, $userId); $votes = $courseRepo->findUserReviewVotes($course->id, $user->id);
if ($votes->count() == 0) { if ($votes->count() == 0) {
return []; return [];

View File

@ -11,7 +11,7 @@ class TeacherList extends Service
use CourseTrait; use CourseTrait;
public function getTeachers($id) public function handle($id)
{ {
$course = $this->checkCourse($id); $course = $this->checkCourse($id);

View File

@ -0,0 +1,25 @@
<?php
namespace App\Services\Frontend\Course;
use App\Caches\CourseTopicList as CourseTopicListCache;
use App\Services\Frontend\CourseTrait;
use App\Services\Frontend\Service;
class TopicList extends Service
{
use CourseTrait;
public function handle($id)
{
$course = $this->checkCourse($id);
$cache = new CourseTopicListCache();
$result = $cache->get($course->id);
return $result ?: [];
}
}

View File

@ -2,20 +2,34 @@
namespace App\Validators; namespace App\Validators;
use App\Caches\Category as CategoryCache;
use App\Exceptions\BadRequest as BadRequestException;
use App\Models\Course as CourseModel; use App\Models\Course as CourseModel;
use App\Repos\Category as CategoryRepo;
class CourseQuery extends Validator class CourseQuery extends Validator
{ {
public function checkCategory($id) public function checkTopCategory($id)
{ {
$categoryRepo = new CategoryRepo(); $categoryCache = new CategoryCache();
$category = $categoryRepo->findById($id); $category = $categoryCache->get($id);
if (!$category) { if (!$category) {
return false; throw new BadRequestException('course_query.invalid_top_category');
}
return $category->id;
}
public function checkSubCategory($id)
{
$categoryCache = new CategoryCache();
$category = $categoryCache->get($id);
if (!$category) {
throw new BadRequestException('course_query.invalid_sub_category');
} }
return $category->id; return $category->id;
@ -26,38 +40,32 @@ class CourseQuery extends Validator
$types = CourseModel::levelTypes(); $types = CourseModel::levelTypes();
if (!isset($types[$level])) { if (!isset($types[$level])) {
return $level; throw new BadRequestException('course_query.invalid_level');
} }
return false; return $level;
} }
public function checkModel($model) public function checkModel($model)
{ {
$types = CourseModel::levelTypes(); $types = CourseModel::modelTypes();
if (!isset($types[$model])) { if (!isset($types[$model])) {
return $model; throw new BadRequestException('course_query.invalid_model');
} }
return false; return $model;
} }
public function checkSort($sort) public function checkSort($sort)
{ {
switch ($sort) { $types = CourseModel::sortTypes();
case 'rating':
$orderBy = 'rating DESC'; if (!isset($types[$sort])) {
break; throw new BadRequestException('course_query.invalid_sort');
case 'score':
$orderBy = 'score DESC';
break;
default:
$orderBy = 'id DESC';
break;
} }
return $orderBy; return $sort;
} }
} }

View File

@ -295,4 +295,13 @@ $error['user_daily_limit.reach_review_limit'] = '超出日评价限额';
$error['user_daily_limit.reach_order_limit'] = '超出日订单限额'; $error['user_daily_limit.reach_order_limit'] = '超出日订单限额';
$error['user_daily_limit.reach_vote_limit'] = '超出日投票限额'; $error['user_daily_limit.reach_vote_limit'] = '超出日投票限额';
/**
* 课程查询
*/
$error['course_query.invalid_top_category'] = '无效的方向类别';
$error['course_query.invalid_sub_category'] = '无效的分类类别';
$error['course_query.invalid_model'] = '无效的模型类别';
$error['course_query.invalid_level'] = '无效的难度类别';
$error['course_query.invalid_sort'] = '无效的排序类别';
return $error; return $error;