mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-22 11:41:27 +08:00
清理代码
This commit is contained in:
parent
46b817c416
commit
bacdcec7fc
@ -20,18 +20,14 @@ class Audit extends Service
|
||||
|
||||
$auditRepo = new AuditRepo();
|
||||
|
||||
$pager = $auditRepo->paginate($params, $sort, $page, $limit);
|
||||
|
||||
return $pager;
|
||||
return $auditRepo->paginate($params, $sort, $page, $limit);
|
||||
}
|
||||
|
||||
public function getAudit($id)
|
||||
{
|
||||
$auditRepo = new AuditRepo();
|
||||
|
||||
$audit = $auditRepo->findById($id);
|
||||
|
||||
return $audit;
|
||||
return $auditRepo->findById($id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,16 +5,13 @@ namespace App\Http\Admin\Services;
|
||||
use App\Models\Category as CategoryModel;
|
||||
use App\Repos\Category as CategoryRepo;
|
||||
use App\Validators\Category as CategoryValidator;
|
||||
use Phalcon\Mvc\Model\Resultset;
|
||||
|
||||
class Category extends Service
|
||||
{
|
||||
|
||||
public function getCategory($id)
|
||||
{
|
||||
$category = $this->findOrFail($id);
|
||||
|
||||
return $category;
|
||||
return $this->findOrFail($id);
|
||||
}
|
||||
|
||||
public function getParentCategory($id)
|
||||
@ -34,12 +31,10 @@ class Category extends Service
|
||||
{
|
||||
$categoryRepo = new CategoryRepo();
|
||||
|
||||
$categories = $categoryRepo->findAll([
|
||||
return $categoryRepo->findAll([
|
||||
'parent_id' => 0,
|
||||
'deleted' => 0,
|
||||
]);
|
||||
|
||||
return $categories;
|
||||
}
|
||||
|
||||
public function getChildCategories($parentId)
|
||||
@ -48,12 +43,10 @@ class Category extends Service
|
||||
|
||||
$categoryRepo = new CategoryRepo();
|
||||
|
||||
$categories = $categoryRepo->findAll([
|
||||
return $categoryRepo->findAll([
|
||||
'parent_id' => $parentId,
|
||||
'deleted' => $deleted,
|
||||
]);
|
||||
|
||||
return $categories;
|
||||
}
|
||||
|
||||
public function createCategory()
|
||||
@ -180,9 +173,6 @@ class Category extends Service
|
||||
{
|
||||
$categoryRepo = new CategoryRepo();
|
||||
|
||||
/**
|
||||
* @var Resultset|CategoryModel[] $categories
|
||||
*/
|
||||
$categories = $categoryRepo->findAll(['parent_id' => $parentId]);
|
||||
|
||||
if ($categories->count() == 0) {
|
||||
@ -199,9 +189,6 @@ class Category extends Service
|
||||
{
|
||||
$categoryRepo = new CategoryRepo();
|
||||
|
||||
/**
|
||||
* @var Resultset|CategoryModel[] $categories
|
||||
*/
|
||||
$categories = $categoryRepo->findAll(['parent_id' => $parentId]);
|
||||
|
||||
if ($categories->count() == 0) {
|
||||
@ -218,9 +205,7 @@ class Category extends Service
|
||||
{
|
||||
$validator = new CategoryValidator();
|
||||
|
||||
$result = $validator->checkCategory($id);
|
||||
|
||||
return $result;
|
||||
return $validator->checkCategory($id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,19 +18,15 @@ class Chapter extends Service
|
||||
|
||||
$chapterRepo = new ChapterRepo();
|
||||
|
||||
$result = $chapterRepo->findAll([
|
||||
return $chapterRepo->findAll([
|
||||
'parent_id' => $parentId,
|
||||
'deleted' => $deleted,
|
||||
]);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getChapter($id)
|
||||
{
|
||||
$chapter = $this->findOrFail($id);
|
||||
|
||||
return $chapter;
|
||||
return $this->findOrFail($id);
|
||||
}
|
||||
|
||||
public function createChapter()
|
||||
@ -64,8 +60,6 @@ class Chapter extends Service
|
||||
$this->updateChapterStats($chapter);
|
||||
$this->updateCourseStats($chapter);
|
||||
|
||||
$this->eventsManager->fire('chapterAdmin:afterCreate', $this, $chapter);
|
||||
|
||||
return $chapter;
|
||||
}
|
||||
|
||||
@ -107,8 +101,6 @@ class Chapter extends Service
|
||||
$this->updateChapterStats($chapter);
|
||||
$this->updateCourseStats($chapter);
|
||||
|
||||
$this->eventsManager->fire('chapterAdmin:afterUpdate', $this, $chapter);
|
||||
|
||||
return $chapter;
|
||||
}
|
||||
|
||||
@ -127,8 +119,6 @@ class Chapter extends Service
|
||||
$this->updateChapterStats($chapter);
|
||||
$this->updateCourseStats($chapter);
|
||||
|
||||
$this->eventsManager->fire('chapterAdmin:afterDelete', $this, $chapter);
|
||||
|
||||
return $chapter;
|
||||
}
|
||||
|
||||
@ -143,8 +133,6 @@ class Chapter extends Service
|
||||
$this->updateChapterStats($chapter);
|
||||
$this->updateCourseStats($chapter);
|
||||
|
||||
$this->eventsManager->fire('chapterAdmin:afterRestore', $this, $chapter);
|
||||
|
||||
return $chapter;
|
||||
}
|
||||
|
||||
@ -184,9 +172,7 @@ class Chapter extends Service
|
||||
{
|
||||
$validator = new ChapterValidator();
|
||||
|
||||
$result = $validator->checkChapter($id);
|
||||
|
||||
return $result;
|
||||
return $validator->checkChapter($id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,27 +20,21 @@ class ChapterContent extends Service
|
||||
{
|
||||
$chapterRepo = new ChapterRepo();
|
||||
|
||||
$result = $chapterRepo->findChapterVod($chapterId);
|
||||
|
||||
return $result;
|
||||
return $chapterRepo->findChapterVod($chapterId);
|
||||
}
|
||||
|
||||
public function getChapterLive($chapterId)
|
||||
{
|
||||
$chapterRepo = new ChapterRepo();
|
||||
|
||||
$result = $chapterRepo->findChapterLive($chapterId);
|
||||
|
||||
return $result;
|
||||
return $chapterRepo->findChapterLive($chapterId);
|
||||
}
|
||||
|
||||
public function getChapterRead($chapterId)
|
||||
{
|
||||
$chapterRepo = new ChapterRepo();
|
||||
|
||||
$result = $chapterRepo->findChapterRead($chapterId);
|
||||
|
||||
return $result;
|
||||
return $chapterRepo->findChapterRead($chapterId);
|
||||
}
|
||||
|
||||
public function getPlayUrls($chapterId)
|
||||
|
@ -28,34 +28,26 @@ class Comment extends Service
|
||||
|
||||
$pager = $commentRepo->paginate($params, $sort, $page, $limit);
|
||||
|
||||
$result = $this->handleComments($pager);
|
||||
|
||||
return $result;
|
||||
return $this->handleComments($pager);
|
||||
}
|
||||
|
||||
public function getCourse($courseId)
|
||||
{
|
||||
$courseRepo = new CourseRepo();
|
||||
|
||||
$result = $courseRepo->findById($courseId);
|
||||
|
||||
return $result;
|
||||
return $courseRepo->findById($courseId);
|
||||
}
|
||||
|
||||
public function getChapter($chapterId)
|
||||
{
|
||||
$chapterRepo = new ChapterRepo();
|
||||
|
||||
$result = $chapterRepo->findById($chapterId);
|
||||
|
||||
return $result;
|
||||
return $chapterRepo->findById($chapterId);
|
||||
}
|
||||
|
||||
public function getComment($id)
|
||||
{
|
||||
$comment = $this->findOrFail($id);
|
||||
|
||||
return $comment;
|
||||
return $this->findOrFail($id);
|
||||
}
|
||||
|
||||
public function updateComment($id)
|
||||
@ -135,9 +127,7 @@ class Comment extends Service
|
||||
{
|
||||
$validator = new CommentValidator();
|
||||
|
||||
$result = $validator->checkComment($id);
|
||||
|
||||
return $result;
|
||||
return $validator->checkComment($id);
|
||||
}
|
||||
|
||||
private function handleComments($pager)
|
||||
|
@ -34,16 +34,12 @@ class Consult extends Service
|
||||
{
|
||||
$courseRepo = new CourseRepo();
|
||||
|
||||
$result = $courseRepo->findById($courseId);
|
||||
|
||||
return $result;
|
||||
return $courseRepo->findById($courseId);
|
||||
}
|
||||
|
||||
public function getConsult($id)
|
||||
{
|
||||
$result = $this->findOrFail($id);
|
||||
|
||||
return $result;
|
||||
return $this->findOrFail($id);
|
||||
}
|
||||
|
||||
public function updateConsult($id)
|
||||
@ -111,9 +107,7 @@ class Consult extends Service
|
||||
{
|
||||
$validator = new ConsultValidator();
|
||||
|
||||
$result = $validator->checkConsult($id);
|
||||
|
||||
return $result;
|
||||
return $validator->checkConsult($id);
|
||||
}
|
||||
|
||||
protected function handleConsults($pager)
|
||||
|
@ -4,12 +4,10 @@ namespace App\Http\Admin\Services;
|
||||
|
||||
use App\Builders\CourseList as CourseListBuilder;
|
||||
use App\Library\Paginator\Query as PagerQuery;
|
||||
use App\Models\Category as CategoryModel;
|
||||
use App\Models\Course as CourseModel;
|
||||
use App\Models\CourseCategory as CourseCategoryModel;
|
||||
use App\Models\CourseRelated as CourseRelatedModel;
|
||||
use App\Models\CourseUser as CourseUserModel;
|
||||
use App\Models\User as UserModel;
|
||||
use App\Repos\Category as CategoryRepo;
|
||||
use App\Repos\Chapter as ChapterRepo;
|
||||
use App\Repos\Course as CourseRepo;
|
||||
@ -18,7 +16,6 @@ use App\Repos\CourseRelated as CourseRelatedRepo;
|
||||
use App\Repos\CourseUser as CourseUserRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
use App\Validators\Course as CourseValidator;
|
||||
use Phalcon\Mvc\Model\Resultset;
|
||||
|
||||
class Course extends Service
|
||||
{
|
||||
@ -49,9 +46,7 @@ class Course extends Service
|
||||
|
||||
public function getCourse($id)
|
||||
{
|
||||
$course = $this->findOrFail($id);
|
||||
|
||||
return $course;
|
||||
return $this->findOrFail($id);
|
||||
}
|
||||
|
||||
public function createCourse()
|
||||
@ -69,8 +64,6 @@ class Course extends Service
|
||||
|
||||
$course->create($data);
|
||||
|
||||
$this->eventsManager->fire('courseAdmin:afterCreate', $this, $course);
|
||||
|
||||
return $course;
|
||||
}
|
||||
|
||||
@ -141,8 +134,6 @@ class Course extends Service
|
||||
|
||||
$course->update($data);
|
||||
|
||||
$this->eventsManager->fire('courseAdmin:afterUpdate', $this, $course);
|
||||
|
||||
return $course;
|
||||
}
|
||||
|
||||
@ -154,8 +145,6 @@ class Course extends Service
|
||||
|
||||
$course->update();
|
||||
|
||||
$this->eventsManager->fire('courseAdmin:afterDelete', $this, $course);
|
||||
|
||||
return $course;
|
||||
}
|
||||
|
||||
@ -167,8 +156,6 @@ class Course extends Service
|
||||
|
||||
$course->update();
|
||||
|
||||
$this->eventsManager->fire('courseAdmin:afterRestore', $this, $course);
|
||||
|
||||
return $course;
|
||||
}
|
||||
|
||||
@ -190,9 +177,6 @@ class Course extends Service
|
||||
{
|
||||
$categoryRepo = new CategoryRepo();
|
||||
|
||||
/**
|
||||
* @var Resultset|CategoryModel[] $allCategories
|
||||
*/
|
||||
$allCategories = $categoryRepo->findAll(['deleted' => 0]);
|
||||
|
||||
if ($allCategories->count() == 0) {
|
||||
@ -205,9 +189,6 @@ class Course extends Service
|
||||
|
||||
$courseRepo = new CourseRepo();
|
||||
|
||||
/**
|
||||
* @var Resultset|CategoryModel[] $courseCategories
|
||||
*/
|
||||
$courseCategories = $courseRepo->findCategories($id);
|
||||
|
||||
if ($courseCategories->count() > 0) {
|
||||
@ -248,9 +229,6 @@ class Course extends Service
|
||||
{
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
/**
|
||||
* @var Resultset|UserModel[] $allTeachers
|
||||
*/
|
||||
$allTeachers = $userRepo->findTeachers();
|
||||
|
||||
if ($allTeachers->count() == 0) {
|
||||
@ -263,9 +241,6 @@ class Course extends Service
|
||||
|
||||
$courseRepo = new CourseRepo();
|
||||
|
||||
/**
|
||||
* @var Resultset|UserModel[] $courseTeachers
|
||||
*/
|
||||
$courseTeachers = $courseRepo->findTeachers($id);
|
||||
|
||||
if ($courseTeachers->count() > 0) {
|
||||
@ -293,9 +268,6 @@ class Course extends Service
|
||||
{
|
||||
$courseRepo = new CourseRepo();
|
||||
|
||||
/**
|
||||
* @var Resultset|CourseModel[] $courses
|
||||
*/
|
||||
$courses = $courseRepo->findRelatedCourses($id);
|
||||
|
||||
$list = [];
|
||||
@ -321,31 +293,24 @@ class Course extends Service
|
||||
|
||||
$chapterRepo = new ChapterRepo();
|
||||
|
||||
$chapters = $chapterRepo->findAll([
|
||||
return $chapterRepo->findAll([
|
||||
'parent_id' => 0,
|
||||
'course_id' => $course->id,
|
||||
'deleted' => $deleted,
|
||||
]);
|
||||
|
||||
return $chapters;
|
||||
}
|
||||
|
||||
protected function findOrFail($id)
|
||||
{
|
||||
$validator = new CourseValidator();
|
||||
|
||||
$result = $validator->checkCourse($id);
|
||||
|
||||
return $result;
|
||||
return $validator->checkCourse($id);
|
||||
}
|
||||
|
||||
protected function saveTeachers(CourseModel $course, $teacherIds)
|
||||
{
|
||||
$courseRepo = new CourseRepo();
|
||||
|
||||
/**
|
||||
* @var Resultset|UserModel[] $courseTeachers
|
||||
*/
|
||||
$courseTeachers = $courseRepo->findTeachers($course->id);
|
||||
|
||||
$originTeacherIds = [];
|
||||
@ -389,9 +354,6 @@ class Course extends Service
|
||||
{
|
||||
$courseRepo = new CourseRepo();
|
||||
|
||||
/**
|
||||
* @var Resultset|CategoryModel[] $courseCategories
|
||||
*/
|
||||
$courseCategories = $courseRepo->findCategories($course->id);
|
||||
|
||||
$originCategoryIds = [];
|
||||
@ -432,9 +394,6 @@ class Course extends Service
|
||||
{
|
||||
$courseRepo = new CourseRepo();
|
||||
|
||||
/**
|
||||
* @var Resultset|CourseModel[] $relatedCourses
|
||||
*/
|
||||
$relatedCourses = $courseRepo->findRelatedCourses($course->id);
|
||||
|
||||
$originRelatedIds = [];
|
||||
|
@ -15,18 +15,14 @@ class Help extends Service
|
||||
|
||||
$helpRepo = new HelpRepo();
|
||||
|
||||
$helps = $helpRepo->findAll([
|
||||
return $helpRepo->findAll([
|
||||
'deleted' => $deleted,
|
||||
]);
|
||||
|
||||
return $helps;
|
||||
}
|
||||
|
||||
public function getHelp($id)
|
||||
{
|
||||
$help = $this->findOrFail($id);
|
||||
|
||||
return $help;
|
||||
return $this->findOrFail($id);
|
||||
}
|
||||
|
||||
public function createHelp()
|
||||
@ -106,9 +102,7 @@ class Help extends Service
|
||||
{
|
||||
$validator = new HelpValidator();
|
||||
|
||||
$result = $validator->checkHelp($id);
|
||||
|
||||
return $result;
|
||||
return $validator->checkHelp($id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,16 +6,13 @@ use App\Caches\NavTreeList as NavTreeListCache;
|
||||
use App\Models\Nav as NavModel;
|
||||
use App\Repos\Nav as NavRepo;
|
||||
use App\Validators\Nav as NavValidator;
|
||||
use Phalcon\Mvc\Model\Resultset;
|
||||
|
||||
class Nav extends Service
|
||||
{
|
||||
|
||||
public function getNav($id)
|
||||
{
|
||||
$nav = $this->findOrFail($id);
|
||||
|
||||
return $nav;
|
||||
return $this->findOrFail($id);
|
||||
}
|
||||
|
||||
public function getParentNav($id)
|
||||
@ -35,13 +32,11 @@ class Nav extends Service
|
||||
{
|
||||
$navRepo = new NavRepo();
|
||||
|
||||
$navs = $navRepo->findAll([
|
||||
return $navRepo->findAll([
|
||||
'parent_id' => 0,
|
||||
'position' => 'top',
|
||||
'deleted' => 0,
|
||||
]);
|
||||
|
||||
return $navs;
|
||||
}
|
||||
|
||||
public function getChildNavs($parentId)
|
||||
@ -50,12 +45,10 @@ class Nav extends Service
|
||||
|
||||
$navRepo = new NavRepo();
|
||||
|
||||
$navs = $navRepo->findAll([
|
||||
return $navRepo->findAll([
|
||||
'parent_id' => $parentId,
|
||||
'deleted' => $deleted,
|
||||
]);
|
||||
|
||||
return $navs;
|
||||
}
|
||||
|
||||
public function createNav()
|
||||
@ -200,9 +193,6 @@ class Nav extends Service
|
||||
{
|
||||
$navRepo = new NavRepo();
|
||||
|
||||
/**
|
||||
* @var Resultset $navs
|
||||
*/
|
||||
$navs = $navRepo->findAll(['parent_id' => $parentId]);
|
||||
|
||||
if ($navs->count() == 0) {
|
||||
@ -219,9 +209,6 @@ class Nav extends Service
|
||||
{
|
||||
$navRepo = new NavRepo();
|
||||
|
||||
/**
|
||||
* @var Resultset $navs
|
||||
*/
|
||||
$navs = $navRepo->findAll(['parent_id' => $parentId]);
|
||||
|
||||
if ($navs->count() == 0) {
|
||||
@ -238,9 +225,7 @@ class Nav extends Service
|
||||
{
|
||||
$validator = new NavValidator();
|
||||
|
||||
$result = $validator->checkNav($id);
|
||||
|
||||
return $result;
|
||||
return $validator->checkNav($id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,43 +33,33 @@ class Order extends Service
|
||||
{
|
||||
$orderRepo = new OrderRepo();
|
||||
|
||||
$trades = $orderRepo->findTrades($sn);
|
||||
|
||||
return $trades;
|
||||
return $orderRepo->findTrades($sn);
|
||||
}
|
||||
|
||||
public function getRefunds($sn)
|
||||
{
|
||||
$orderRepo = new OrderRepo();
|
||||
|
||||
$trades = $orderRepo->findRefunds($sn);
|
||||
|
||||
return $trades;
|
||||
return $orderRepo->findRefunds($sn);
|
||||
}
|
||||
|
||||
public function getUser($userId)
|
||||
{
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$user = $userRepo->findById($userId);
|
||||
|
||||
return $user;
|
||||
return $userRepo->findById($userId);
|
||||
}
|
||||
|
||||
public function getAccount($userId)
|
||||
{
|
||||
$accountRepo = new AccountRepo();
|
||||
|
||||
$account = $accountRepo->findById($userId);
|
||||
|
||||
return $account;
|
||||
return $accountRepo->findById($userId);
|
||||
}
|
||||
|
||||
public function getOrder($id)
|
||||
{
|
||||
$order = $this->findOrFail($id);
|
||||
|
||||
return $order;
|
||||
return $this->findOrFail($id);
|
||||
}
|
||||
|
||||
public function closeOrder($id)
|
||||
@ -88,9 +78,7 @@ class Order extends Service
|
||||
{
|
||||
$validator = new OrderValidator();
|
||||
|
||||
$result = $validator->checkOrderById($id);
|
||||
|
||||
return $result;
|
||||
return $validator->checkOrderById($id);
|
||||
}
|
||||
|
||||
protected function handleOrders($pager)
|
||||
|
@ -27,16 +27,12 @@ class Package extends Service
|
||||
|
||||
$pageRepo = new PackageRepo();
|
||||
|
||||
$pager = $pageRepo->paginate($params, $sort, $page, $limit);
|
||||
|
||||
return $pager;
|
||||
return $pageRepo->paginate($params, $sort, $page, $limit);
|
||||
}
|
||||
|
||||
public function getPackage($id)
|
||||
{
|
||||
$package = $this->findOrFail($id);
|
||||
|
||||
return $package;
|
||||
return $this->findOrFail($id);
|
||||
}
|
||||
|
||||
public function createPackage()
|
||||
@ -128,9 +124,7 @@ class Package extends Service
|
||||
|
||||
$ids = explode(',', $courseIds);
|
||||
|
||||
$courses = $courseRepo->findByIds($ids);
|
||||
|
||||
return $courses;
|
||||
return $courseRepo->findByIds($ids);
|
||||
}
|
||||
|
||||
public function getGuidingPrice($courses)
|
||||
@ -230,9 +224,7 @@ class Package extends Service
|
||||
{
|
||||
$validator = new PackageValidator();
|
||||
|
||||
$result = $validator->checkPackage($id);
|
||||
|
||||
return $result;
|
||||
return $validator->checkPackage($id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,16 +24,12 @@ class Page extends Service
|
||||
|
||||
$pageRepo = new PageRepo();
|
||||
|
||||
$pager = $pageRepo->paginate($params, $sort, $page, $limit);
|
||||
|
||||
return $pager;
|
||||
return $pageRepo->paginate($params, $sort, $page, $limit);
|
||||
}
|
||||
|
||||
public function getPage($id)
|
||||
{
|
||||
$page = $this->findOrFail($id);
|
||||
|
||||
return $page;
|
||||
return $this->findOrFail($id);
|
||||
}
|
||||
|
||||
public function createPage()
|
||||
@ -108,9 +104,7 @@ class Page extends Service
|
||||
{
|
||||
$validator = new PageValidator();
|
||||
|
||||
$result = $validator->checkPage($id);
|
||||
|
||||
return $result;
|
||||
return $validator->checkPage($id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -43,45 +43,35 @@ class Refund extends Service
|
||||
|
||||
public function getRefund($id)
|
||||
{
|
||||
$refund = $this->findOrFail($id);
|
||||
|
||||
return $refund;
|
||||
return $this->findOrFail($id);
|
||||
}
|
||||
|
||||
public function getTrade($tradeId)
|
||||
{
|
||||
$tradeRepo = new TradeRepo();
|
||||
|
||||
$trade = $tradeRepo->findById($tradeId);
|
||||
|
||||
return $trade;
|
||||
return $tradeRepo->findById($tradeId);
|
||||
}
|
||||
|
||||
public function getOrder($orderId)
|
||||
{
|
||||
$orderRepo = new OrderRepo();
|
||||
|
||||
$order = $orderRepo->findById($orderId);
|
||||
|
||||
return $order;
|
||||
return $orderRepo->findById($orderId);
|
||||
}
|
||||
|
||||
public function getUser($userId)
|
||||
{
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$user = $userRepo->findById($userId);
|
||||
|
||||
return $user;
|
||||
return $userRepo->findById($userId);
|
||||
}
|
||||
|
||||
public function getAccount($userId)
|
||||
{
|
||||
$accountRepo = new AccountRepo();
|
||||
|
||||
$account = $accountRepo->findById($userId);
|
||||
|
||||
return $account;
|
||||
return $accountRepo->findById($userId);
|
||||
}
|
||||
|
||||
public function reviewRefund($id)
|
||||
@ -118,9 +108,7 @@ class Refund extends Service
|
||||
{
|
||||
$validator = new RefundValidator();
|
||||
|
||||
$result = $validator->checkRefund($id);
|
||||
|
||||
return $result;
|
||||
return $validator->checkRefund($id);
|
||||
}
|
||||
|
||||
protected function handleRefunds($pager)
|
||||
|
@ -34,16 +34,12 @@ class Review extends Service
|
||||
{
|
||||
$courseRepo = new CourseRepo();
|
||||
|
||||
$result = $courseRepo->findById($courseId);
|
||||
|
||||
return $result;
|
||||
return $courseRepo->findById($courseId);
|
||||
}
|
||||
|
||||
public function getReview($id)
|
||||
{
|
||||
$result = $this->findOrFail($id);
|
||||
|
||||
return $result;
|
||||
return $this->findOrFail($id);
|
||||
}
|
||||
|
||||
public function updateReview($id)
|
||||
@ -111,9 +107,7 @@ class Review extends Service
|
||||
{
|
||||
$validator = new ReviewValidator();
|
||||
|
||||
$result = $validator->checkReview($id);
|
||||
|
||||
return $result;
|
||||
return $validator->checkReview($id);
|
||||
}
|
||||
|
||||
protected function handleReviews($pager)
|
||||
|
@ -24,16 +24,12 @@ class Role extends Service
|
||||
|
||||
$roleRepo = new RoleRepo();
|
||||
|
||||
$roles = $roleRepo->findAll(['deleted' => $deleted]);
|
||||
|
||||
return $roles;
|
||||
return $roleRepo->findAll(['deleted' => $deleted]);
|
||||
}
|
||||
|
||||
public function getRole($id)
|
||||
{
|
||||
$role = $this->findOrFail($id);
|
||||
|
||||
return $role;
|
||||
return $this->findOrFail($id);
|
||||
}
|
||||
|
||||
public function createRole()
|
||||
@ -105,9 +101,7 @@ class Role extends Service
|
||||
{
|
||||
$validator = new RoleValidator();
|
||||
|
||||
$result = $validator->checkRole($id);
|
||||
|
||||
return $result;
|
||||
return $validator->checkRole($id);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -159,9 +153,9 @@ class Role extends Service
|
||||
$list[] = 'admin.chapter.restore';
|
||||
}
|
||||
|
||||
$result = array_values(array_unique($list));
|
||||
$list = array_unique($list);
|
||||
|
||||
return $result;
|
||||
return array_values($list);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,16 +24,12 @@ class Slide extends Service
|
||||
|
||||
$slideRepo = new SlideRepo();
|
||||
|
||||
$pager = $slideRepo->paginate($params, $sort, $page, $limit);
|
||||
|
||||
return $pager;
|
||||
return $slideRepo->paginate($params, $sort, $page, $limit);
|
||||
}
|
||||
|
||||
public function getSlide($id)
|
||||
{
|
||||
$slide = $this->findOrFail($id);
|
||||
|
||||
return $slide;
|
||||
return $this->findOrFail($id);
|
||||
}
|
||||
|
||||
public function createSlide()
|
||||
@ -139,9 +135,7 @@ class Slide extends Service
|
||||
{
|
||||
$validator = new SlideValidator();
|
||||
|
||||
$result = $validator->checkSlide($id);
|
||||
|
||||
return $result;
|
||||
return $validator->checkSlide($id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -69,9 +69,7 @@ class Student extends Service
|
||||
|
||||
public function getPlan($id)
|
||||
{
|
||||
$result = $this->findOrFail($id);
|
||||
|
||||
return $result;
|
||||
return $this->findOrFail($id);
|
||||
}
|
||||
|
||||
public function createPlan()
|
||||
@ -134,9 +132,7 @@ class Student extends Service
|
||||
{
|
||||
$validator = new CourseUserValidator();
|
||||
|
||||
$result = $validator->checkCourseUser($id);
|
||||
|
||||
return $result;
|
||||
return $validator->checkCourseUser($id);
|
||||
}
|
||||
|
||||
protected function handlePlans($pager)
|
||||
|
@ -26,16 +26,12 @@ class Topic extends Service
|
||||
|
||||
$pageRepo = new TopicRepo();
|
||||
|
||||
$pager = $pageRepo->paginate($params, $sort, $page, $limit);
|
||||
|
||||
return $pager;
|
||||
return $pageRepo->paginate($params, $sort, $page, $limit);
|
||||
}
|
||||
|
||||
public function getTopic($id)
|
||||
{
|
||||
$topic = $this->findOrFail($id);
|
||||
|
||||
return $topic;
|
||||
return $this->findOrFail($id);
|
||||
}
|
||||
|
||||
public function createTopic()
|
||||
@ -187,9 +183,7 @@ class Topic extends Service
|
||||
{
|
||||
$validator = new TopicValidator();
|
||||
|
||||
$result = $validator->checkTopic($id);
|
||||
|
||||
return $result;
|
||||
return $validator->checkTopic($id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,45 +45,35 @@ class Trade extends Service
|
||||
{
|
||||
$tradeRepo = new TradeRepo();
|
||||
|
||||
$trade = $tradeRepo->findById($id);
|
||||
|
||||
return $trade;
|
||||
return $tradeRepo->findById($id);
|
||||
}
|
||||
|
||||
public function getOrder($orderId)
|
||||
{
|
||||
$orderRepo = new OrderRepo();
|
||||
|
||||
$order = $orderRepo->findById($orderId);
|
||||
|
||||
return $order;
|
||||
return $orderRepo->findById($orderId);
|
||||
}
|
||||
|
||||
public function getRefunds($tradeId)
|
||||
{
|
||||
$tradeRepo = new TradeRepo();
|
||||
|
||||
$refunds = $tradeRepo->findRefunds($tradeId);
|
||||
|
||||
return $refunds;
|
||||
return $tradeRepo->findRefunds($tradeId);
|
||||
}
|
||||
|
||||
public function getUser($userId)
|
||||
{
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$user = $userRepo->findById($userId);
|
||||
|
||||
return $user;
|
||||
return $userRepo->findById($userId);
|
||||
}
|
||||
|
||||
public function getAccount($userId)
|
||||
{
|
||||
$accountRepo = new AccountRepo();
|
||||
|
||||
$account = $accountRepo->findById($userId);
|
||||
|
||||
return $account;
|
||||
return $accountRepo->findById($userId);
|
||||
}
|
||||
|
||||
public function closeTrade($id)
|
||||
@ -127,9 +117,7 @@ class Trade extends Service
|
||||
{
|
||||
$validator = new TradeValidator();
|
||||
|
||||
$result = $validator->checkTrade($id);
|
||||
|
||||
return $result;
|
||||
return $validator->checkTrade($id);
|
||||
}
|
||||
|
||||
protected function handleTrades($pager)
|
||||
|
@ -18,9 +18,7 @@ class User extends Service
|
||||
{
|
||||
$roleRepo = new RoleRepo();
|
||||
|
||||
$roles = $roleRepo->findAll(['deleted' => 0]);
|
||||
|
||||
return $roles;
|
||||
return $roleRepo->findAll(['deleted' => 0]);
|
||||
}
|
||||
|
||||
public function getUsers()
|
||||
@ -36,25 +34,19 @@ class User extends Service
|
||||
|
||||
$pager = $userRepo->paginate($params, $sort, $page, $limit);
|
||||
|
||||
$result = $this->handleUsers($pager);
|
||||
|
||||
return $result;
|
||||
return $this->handleUsers($pager);
|
||||
}
|
||||
|
||||
public function getUser($id)
|
||||
{
|
||||
$user = $this->findOrFail($id);
|
||||
|
||||
return $user;
|
||||
return $this->findOrFail($id);
|
||||
}
|
||||
|
||||
public function getAccount($id)
|
||||
{
|
||||
$accountRepo = new AccountRepo();
|
||||
|
||||
$account = $accountRepo->findById($id);
|
||||
|
||||
return $account;
|
||||
return $accountRepo->findById($id);
|
||||
}
|
||||
|
||||
public function createUser()
|
||||
@ -205,9 +197,7 @@ class User extends Service
|
||||
{
|
||||
$validator = new UserValidator();
|
||||
|
||||
$result = $validator->checkUser($id);
|
||||
|
||||
return $result;
|
||||
return $validator->checkUser($id);
|
||||
}
|
||||
|
||||
protected function updateAdminUserCount($roleId)
|
||||
|
@ -22,9 +22,7 @@ class XmCourse extends Service
|
||||
|
||||
$courseRepo = new CourseRepo();
|
||||
|
||||
$pager = $courseRepo->paginate($params, $sort, $page, $limit);
|
||||
|
||||
return $pager;
|
||||
return $courseRepo->paginate($params, $sort, $page, $limit);
|
||||
}
|
||||
|
||||
public function getPaidCourses()
|
||||
@ -42,9 +40,7 @@ class XmCourse extends Service
|
||||
|
||||
$courseRepo = new CourseRepo();
|
||||
|
||||
$pager = $courseRepo->paginate($params, $sort, $page, $limit);
|
||||
|
||||
return $pager;
|
||||
return $courseRepo->paginate($params, $sort, $page, $limit);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,8 +12,6 @@ class IndexController extends Controller
|
||||
{
|
||||
$this->seo->setKeywords($this->site->keywords);
|
||||
$this->seo->setDescription($this->site->description);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,21 +1,7 @@
|
||||
{% extends "templates/base.volt" %}
|
||||
{% extends 'templates/base.volt' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<img src="/qr/img?text=http://ctc.koogua.com">
|
||||
{% endblock %}
|
||||
|
||||
{% block inline_css %}
|
||||
<style>
|
||||
.ok {
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block inline_js %}
|
||||
<script>
|
||||
function ok() {
|
||||
console.log("fuck");
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
1
app/Http/Web/Views/partials/footer.volt
Normal file
1
app/Http/Web/Views/partials/footer.volt
Normal file
@ -0,0 +1 @@
|
||||
<h1>I am footer</h1>
|
1
app/Http/Web/Views/partials/header.volt
Normal file
1
app/Http/Web/Views/partials/header.volt
Normal file
@ -0,0 +1 @@
|
||||
<h1>I am header</h1>
|
8
app/Http/Web/Views/partials/pager.volt
Normal file
8
app/Http/Web/Views/partials/pager.volt
Normal file
@ -0,0 +1,8 @@
|
||||
{% if pager.total_pages > 1 %}
|
||||
<div class="layui-box layui-laypage layui-laypage-default">
|
||||
<a href="{{ pager.first }}">首页</a>
|
||||
<a href="{{ pager.previous }}">上页</a>
|
||||
<a href="{{ pager.next }}">下页</a>
|
||||
<a href="{{ pager.last }}">尾页</a>
|
||||
</div>
|
||||
{% endif %}
|
@ -9,13 +9,21 @@
|
||||
{{ icon_link("favicon.ico") }}
|
||||
{{ css_link("lib/layui/css/layui.css") }}
|
||||
{{ css_link("web/css/style.css") }}
|
||||
{% block header_css %}{% endblock %}
|
||||
{% block link_css %}{% endblock %}
|
||||
{% block inline_css %}{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
<div id="header">
|
||||
{{ partial('partials/header') }}
|
||||
</div>
|
||||
<div id="content">
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
<div id="footer">
|
||||
{{ partial('partials/footer') }}
|
||||
</div>
|
||||
{{ js_include("lib/layui/layui.js") }}
|
||||
{% block footer_js %}{% endblock %}
|
||||
{% block include_js %}{% endblock %}
|
||||
{% block inline_js %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
@ -1,84 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use App\Caches\Chapter as ChapterCache;
|
||||
use App\Caches\MaxChapterId as MaxChapterIdCache;
|
||||
use App\Models\Chapter as ChapterModel;
|
||||
use Phalcon\Events\Event;
|
||||
|
||||
class ChapterAdmin extends Listener
|
||||
{
|
||||
|
||||
protected $logger;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->logger = $this->getLogger();
|
||||
}
|
||||
|
||||
public function afterCreate(Event $event, $source, ChapterModel $chapter)
|
||||
{
|
||||
$this->syncMaxIdCache();
|
||||
|
||||
$this->logger->debug('Event: {event}, Source: {source}, Data: {data}', [
|
||||
'event' => $event->getType(),
|
||||
'source' => get_class($source),
|
||||
'data' => kg_json_encode($chapter),
|
||||
]);
|
||||
}
|
||||
|
||||
public function afterUpdate(Event $event, $source, ChapterModel $chapter)
|
||||
{
|
||||
if ($chapter->published == 1) {
|
||||
$this->syncCache($chapter);
|
||||
}
|
||||
|
||||
$this->logger->debug('Event: {event}, Source: {source}, Data: {data}', [
|
||||
'event' => $event->getType(),
|
||||
'source' => get_class($source),
|
||||
'data' => kg_json_encode($chapter),
|
||||
]);
|
||||
}
|
||||
|
||||
public function afterDelete(Event $event, $source, ChapterModel $chapter)
|
||||
{
|
||||
if ($chapter->published == 1) {
|
||||
$this->syncCache($chapter);
|
||||
}
|
||||
|
||||
$this->logger->debug('Event: {event}, Source: {source}, Data: {data}', [
|
||||
'event' => $event->getType(),
|
||||
'source' => get_class($source),
|
||||
'data' => kg_json_encode($chapter),
|
||||
]);
|
||||
}
|
||||
|
||||
public function afterRestore(Event $event, $source, ChapterModel $chapter)
|
||||
{
|
||||
if ($chapter->published == 1) {
|
||||
$this->syncCache($chapter);
|
||||
}
|
||||
|
||||
$this->logger->debug('Event: {event}, Source: {source}, Data: {data}', [
|
||||
'event' => $event->getType(),
|
||||
'source' => get_class($source),
|
||||
'data' => kg_json_encode($chapter),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function syncMaxIdCache()
|
||||
{
|
||||
$maxIdCache = new MaxChapterIdCache();
|
||||
|
||||
$maxIdCache->rebuild();
|
||||
}
|
||||
|
||||
protected function syncCache(ChapterModel $chapter)
|
||||
{
|
||||
$chapterCache = new ChapterCache();
|
||||
|
||||
$chapterCache->rebuild($chapter->id);
|
||||
}
|
||||
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use App\Caches\Course as CourseCache;
|
||||
use App\Caches\MaxCourseId as MaxCourseIdCache;
|
||||
use App\Models\Course as CourseModel;
|
||||
use App\Services\CourseIndexSyncer;
|
||||
use Phalcon\Events\Event;
|
||||
|
||||
class CourseAdmin extends Listener
|
||||
{
|
||||
|
||||
protected $logger;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->logger = $this->getLogger();
|
||||
}
|
||||
|
||||
public function afterCreate(Event $event, $source, CourseModel $course)
|
||||
{
|
||||
if ($course->published == 1) {
|
||||
$this->syncMaxIdCache();
|
||||
$this->syncCache($course);
|
||||
$this->syncIndex($course);
|
||||
}
|
||||
|
||||
$this->logger->debug('Event: {event}, Source: {source}, Data: {data}', [
|
||||
'event' => $event->getType(),
|
||||
'source' => get_class($source),
|
||||
'data' => kg_json_encode($course),
|
||||
]);
|
||||
}
|
||||
|
||||
public function afterUpdate(Event $event, $source, CourseModel $course)
|
||||
{
|
||||
if ($course->published == 1) {
|
||||
$this->syncCache($course);
|
||||
$this->syncIndex($course);
|
||||
}
|
||||
|
||||
$this->logger->debug('Event: {event}, Source: {source}, Data: {data}', [
|
||||
'event' => $event->getType(),
|
||||
'source' => get_class($source),
|
||||
'data' => kg_json_encode($course),
|
||||
]);
|
||||
}
|
||||
|
||||
public function afterDelete(Event $event, $source, CourseModel $course)
|
||||
{
|
||||
if ($course->published == 1) {
|
||||
$this->syncCache($course);
|
||||
$this->syncIndex($course);
|
||||
}
|
||||
|
||||
$this->logger->debug('Event: {event}, Source: {source}, Data: {data}', [
|
||||
'event' => $event->getType(),
|
||||
'source' => get_class($source),
|
||||
'data' => kg_json_encode($course),
|
||||
]);
|
||||
}
|
||||
|
||||
public function afterRestore(Event $event, $source, CourseModel $course)
|
||||
{
|
||||
if ($course->published == 1) {
|
||||
$this->syncCache($course);
|
||||
$this->syncIndex($course);
|
||||
}
|
||||
|
||||
$this->logger->debug('Event: {event}, Source: {source}, Data: {data}', [
|
||||
'event' => $event->getType(),
|
||||
'source' => get_class($source),
|
||||
'data' => kg_json_encode($course),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function syncMaxIdCache()
|
||||
{
|
||||
$maxIdCache = new MaxCourseIdCache();
|
||||
|
||||
$maxIdCache->rebuild();
|
||||
}
|
||||
|
||||
protected function syncCache(CourseModel $course)
|
||||
{
|
||||
$courseCache = new CourseCache();
|
||||
|
||||
$courseCache->rebuild($course->id);
|
||||
}
|
||||
|
||||
protected function syncIndex(CourseModel $course)
|
||||
{
|
||||
$indexSyncer = new CourseIndexSyncer();
|
||||
|
||||
$indexSyncer->addItem($course->id);
|
||||
}
|
||||
|
||||
}
|
@ -134,12 +134,15 @@ class Category extends Model
|
||||
public function rebuildCache()
|
||||
{
|
||||
$itemCache = new CategoryCache();
|
||||
|
||||
$itemCache->rebuild($this->id);
|
||||
|
||||
$listCache = new CategoryListCache();
|
||||
|
||||
$listCache->rebuild();
|
||||
|
||||
$treeListCache = new CategoryTreeListCache();
|
||||
|
||||
$treeListCache->rebuild();
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Services\CourseIndexSyncer;
|
||||
use Phalcon\Mvc\Model\Behavior\SoftDelete;
|
||||
|
||||
class Course extends Model
|
||||
@ -113,6 +114,13 @@ class Course extends Model
|
||||
*/
|
||||
public $refund_expiry;
|
||||
|
||||
/**
|
||||
* 用户评价
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
public $rating;
|
||||
|
||||
/**
|
||||
* 综合得分
|
||||
*
|
||||
@ -141,13 +149,6 @@ class Course extends Model
|
||||
*/
|
||||
public $attrs;
|
||||
|
||||
/**
|
||||
* 课时数
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $lesson_count;
|
||||
|
||||
/**
|
||||
* 学员数
|
||||
*
|
||||
@ -155,6 +156,13 @@ class Course extends Model
|
||||
*/
|
||||
public $user_count;
|
||||
|
||||
/**
|
||||
* 课时数
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $lesson_count;
|
||||
|
||||
/**
|
||||
* 评论数
|
||||
*
|
||||
@ -260,16 +268,35 @@ class Course extends Model
|
||||
}
|
||||
}
|
||||
|
||||
public function afterCreate()
|
||||
{
|
||||
$this->rebuildIndex();
|
||||
}
|
||||
|
||||
public function afterUpdate()
|
||||
{
|
||||
$this->rebuildIndex();
|
||||
}
|
||||
|
||||
public function afterFetch()
|
||||
{
|
||||
$this->market_price = (float)$this->market_price;
|
||||
$this->vip_price = (float)$this->vip_price;
|
||||
$this->rating = (float)$this->rating;
|
||||
$this->score = (float)$this->score;
|
||||
|
||||
if (!empty($this->attrs)) {
|
||||
$this->attrs = json_decode($this->attrs, true);
|
||||
}
|
||||
}
|
||||
|
||||
public function rebuildIndex()
|
||||
{
|
||||
$syncer = new CourseIndexSyncer();
|
||||
|
||||
$syncer->addItem($this->id);
|
||||
}
|
||||
|
||||
public static function modelTypes()
|
||||
{
|
||||
return [
|
||||
|
@ -157,8 +157,9 @@ class Nav extends Model
|
||||
|
||||
public function rebuildCache()
|
||||
{
|
||||
$treeListCache = new NavTreeListCache();
|
||||
$treeListCache->rebuild();
|
||||
$cache = new NavTreeListCache();
|
||||
|
||||
$cache->rebuild();
|
||||
}
|
||||
|
||||
public static function positionTypes()
|
||||
|
@ -131,8 +131,9 @@ class Slide extends Model
|
||||
|
||||
public function rebuildCache()
|
||||
{
|
||||
$listCache = new SlideListCache();
|
||||
$listCache->rebuild();
|
||||
$cache = new SlideListCache();
|
||||
|
||||
$cache->rebuild();
|
||||
}
|
||||
|
||||
public static function targetTypes()
|
||||
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Library\Util\Seo as AppSeo;
|
||||
|
||||
class Seo extends Provider
|
||||
{
|
||||
|
||||
protected $serviceName = 'seo';
|
||||
|
||||
public function register()
|
||||
{
|
||||
$this->di->setShared($this->serviceName, function () {
|
||||
return new AppSeo();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -291,7 +291,7 @@ class Course extends Repository
|
||||
public function countConsults($courseId)
|
||||
{
|
||||
return ConsultModel::count([
|
||||
'conditions' => 'course_id = :course_id: AND deleted = 0',
|
||||
'conditions' => 'course_id = :course_id: AND published = 1',
|
||||
'bind' => ['course_id' => $courseId],
|
||||
]);
|
||||
}
|
||||
@ -299,7 +299,7 @@ class Course extends Repository
|
||||
public function countReviews($courseId)
|
||||
{
|
||||
return ReviewModel::count([
|
||||
'conditions' => 'course_id = :course_id: AND deleted = 0',
|
||||
'conditions' => 'course_id = :course_id: AND published = 1',
|
||||
'bind' => ['course_id' => $courseId],
|
||||
]);
|
||||
}
|
||||
@ -307,7 +307,7 @@ class Course extends Repository
|
||||
public function countComments($courseId)
|
||||
{
|
||||
return CommentModel::count([
|
||||
'conditions' => 'course_id = :course_id: AND deleted = 0',
|
||||
'conditions' => 'course_id = :course_id: AND published = 1',
|
||||
'bind' => ['course_id' => $courseId],
|
||||
]);
|
||||
}
|
||||
@ -315,7 +315,16 @@ class Course extends Repository
|
||||
public function countFavorites($courseId)
|
||||
{
|
||||
return CourseFavoriteModel::count([
|
||||
'conditions' => 'course_id = :course_id: AND deleted = 0',
|
||||
'conditions' => 'course_id = :course_id: AND published = 1',
|
||||
'bind' => ['course_id' => $courseId],
|
||||
]);
|
||||
}
|
||||
|
||||
public function averageRating($courseId)
|
||||
{
|
||||
return ReviewModel::average([
|
||||
'column' => 'rating',
|
||||
'conditions' => 'course_id = :course_id: AND published = 1',
|
||||
'bind' => ['course_id' => $courseId],
|
||||
]);
|
||||
}
|
||||
|
@ -47,13 +47,17 @@ class CourseDocument extends Component
|
||||
'vip_price' => $course->vip_price,
|
||||
'study_expiry' => $course->study_expiry,
|
||||
'refund_expiry' => $course->refund_expiry,
|
||||
'rating' => $course->rating,
|
||||
'score' => $course->score,
|
||||
'model' => $course->model,
|
||||
'level' => $course->level,
|
||||
'attrs' => $course->attrs,
|
||||
'user_count' => $course->user_count,
|
||||
'lesson_count' => $course->lesson_count,
|
||||
'create_time' => $course->create_time,
|
||||
'comment_count' => $course->comment_count,
|
||||
'consult_count' => $course->consult_count,
|
||||
'review_count' => $course->review_count,
|
||||
'favorite_count' => $course->favorite_count,
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,24 @@ class CourseStats extends Service
|
||||
$course->update();
|
||||
}
|
||||
|
||||
public function updateRating($courseId)
|
||||
{
|
||||
$courseRepo = new CourseRepo();
|
||||
|
||||
$course = $courseRepo->findById($courseId);
|
||||
|
||||
$rating = $courseRepo->averageRating($courseId);
|
||||
|
||||
$course->rating = $rating;
|
||||
|
||||
$course->update();
|
||||
}
|
||||
|
||||
public function updateScore($courseId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function updateReadAttrs($courseId)
|
||||
{
|
||||
$courseRepo = new CourseRepo();
|
||||
|
@ -1,17 +1,11 @@
|
||||
<?php
|
||||
|
||||
use App\Listeners\ChapterAdmin;
|
||||
use App\Listeners\CourseAdmin;
|
||||
use App\Listeners\Payment;
|
||||
use App\Listeners\Profiler;
|
||||
use App\Listeners\UserDailyCounter;
|
||||
|
||||
return [
|
||||
|
||||
'db' => Profiler::class,
|
||||
'payment' => Payment::class,
|
||||
'userDailyCounter' => UserDailyCounter::class,
|
||||
'courseAdmin' => CourseAdmin::class,
|
||||
'chapterAdmin' => ChapterAdmin::class,
|
||||
|
||||
];
|
@ -32,6 +32,9 @@ type = string
|
||||
[refund_expiry]
|
||||
type = string
|
||||
|
||||
[rating]
|
||||
type = numeric
|
||||
|
||||
[score]
|
||||
type = numeric
|
||||
|
||||
@ -54,5 +57,14 @@ type = string
|
||||
[lesson_count]
|
||||
type = string
|
||||
|
||||
[create_time]
|
||||
type = numeric
|
||||
[comment_count]
|
||||
type = string
|
||||
|
||||
[consult_count]
|
||||
type = string
|
||||
|
||||
[review_count]
|
||||
type = string
|
||||
|
||||
[favorite_count]
|
||||
type = string
|
Loading…
x
Reference in New Issue
Block a user