1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-07-15 21:02:20 +08:00

当deleted=1,published=0

This commit is contained in:
xiaochong0302 2020-07-14 21:13:37 +08:00
parent fe968a394a
commit 5cbb11141b
39 changed files with 156 additions and 114 deletions

View File

@ -58,7 +58,8 @@ class CategoryTreeList extends Builder
{ {
return CategoryModel::query() return CategoryModel::query()
->where('parent_id = :parent_id:', ['parent_id' => $categoryId]) ->where('parent_id = :parent_id:', ['parent_id' => $categoryId])
->andWhere('deleted = 0') ->andWhere('published = 1')
->orderBy('priority ASC')
->execute(); ->execute();
} }

View File

@ -31,7 +31,7 @@ class CategoryList extends Cache
*/ */
$categories = CategoryModel::query() $categories = CategoryModel::query()
->columns(['id', 'parent_id', 'name', 'priority', 'level', 'path']) ->columns(['id', 'parent_id', 'name', 'priority', 'level', 'path'])
->where('published = 1 AND deleted = 0') ->where('published = 1')
->execute(); ->execute();
if ($categories->count() == 0) { if ($categories->count() == 0) {

View File

@ -16,7 +16,7 @@ class ImGroup extends Cache
public function getKey($id = null) public function getKey($id = null)
{ {
return "im_chat_group:{$id}"; return "im_group:{$id}";
} }
public function getContent($id = null) public function getContent($id = null)

View File

@ -18,6 +18,7 @@ class CleanLogTask extends Task
$this->cleanMailerLog(); $this->cleanMailerLog();
$this->cleanSmserLog(); $this->cleanSmserLog();
$this->cleanVodLog(); $this->cleanVodLog();
$this->cleanLiveLog();
$this->cleanStorageLog(); $this->cleanStorageLog();
$this->cleanAlipayLog(); $this->cleanAlipayLog();
$this->cleanWxpayLog(); $this->cleanWxpayLog();
@ -81,6 +82,14 @@ class CleanLogTask extends Task
$this->cleanLog('vod', 7); $this->cleanLog('vod', 7);
} }
/**
* 清理直播服务日志
*/
protected function cleanLiveLog()
{
$this->cleanLog('live', 7);
}
/** /**
* 清理存储服务日志 * 清理存储服务日志
*/ */

View File

@ -50,13 +50,11 @@ class SyncChapterCounterTask extends Task
$chapterCache = new ChapterCache(); $chapterCache = new ChapterCache();
$hour = date('H'); $allowRecount = $this->allowRecount();
$recount = $this->checkEnableRecount();
foreach ($chapters as $chapter) { foreach ($chapters as $chapter) {
if ($recount && $hour % 3 == 0) { if ($allowRecount) {
$chapter->user_count = $chapterRepo->countUsers($chapter->id); $chapter->user_count = $chapterRepo->countUsers($chapter->id);
$chapter->lesson_count = $chapterRepo->countLessons($chapter->id); $chapter->lesson_count = $chapterRepo->countLessons($chapter->id);
@ -94,11 +92,9 @@ class SyncChapterCounterTask extends Task
return $syncer->getSyncKey(); return $syncer->getSyncKey();
} }
protected function checkEnableRecount() protected function allowRecount()
{ {
$config = $this->getDI()->get('config'); return date('H') % 2 == 0;
return $config->syncer->recount_chapter ?? false;
} }
} }

View File

@ -47,13 +47,11 @@ class SyncCommentCounterTask extends Task
$counterCache = new CommentCounterCache(); $counterCache = new CommentCounterCache();
$hour = date('H'); $allowRecount = $this->allowRecount();
$recount = $this->checkEnableRecount();
foreach ($comments as $comment) { foreach ($comments as $comment) {
if ($recount && $hour % 3 == 0) { if ($allowRecount) {
$comment->reply_count = $commentRepo->countReplies($comment->id); $comment->reply_count = $commentRepo->countReplies($comment->id);
$comment->like_count = $commentRepo->countLikes($comment->id); $comment->like_count = $commentRepo->countLikes($comment->id);
@ -83,11 +81,9 @@ class SyncCommentCounterTask extends Task
return $syncer->getSyncKey(); return $syncer->getSyncKey();
} }
protected function checkEnableRecount() protected function allowRecount()
{ {
$config = $this->getDI()->get('config'); return date('H') == 5;
return $config->syncer->recount_comment ?? false;
} }
} }

View File

@ -47,13 +47,11 @@ class SyncConsultCounterTask extends Task
$counterCache = new ConsultCounterCache(); $counterCache = new ConsultCounterCache();
$hour = date('H'); $allowRecount = $this->allowRecount();
$recount = $this->checkEnableRecount();
foreach ($consults as $consult) { foreach ($consults as $consult) {
if ($recount && $hour % 3 == 0) { if ($allowRecount) {
$consult->like_count = $consultRepo->countLikes($consult->id); $consult->like_count = $consultRepo->countLikes($consult->id);
$consult->update(); $consult->update();
@ -81,11 +79,9 @@ class SyncConsultCounterTask extends Task
return $syncer->getSyncKey(); return $syncer->getSyncKey();
} }
protected function checkEnableRecount() protected function allowRecount()
{ {
$config = $this->getDI()->get('config'); return date('H') == 1;
return $config->syncer->recount_consult ?? false;
} }
} }

View File

@ -50,16 +50,13 @@ class SyncCourseCounterTask extends Task
$courseCache = new CourseCache(); $courseCache = new CourseCache();
$hour = date('H'); $allowRecount = $this->allowRecount();
$recount = $this->checkEnableRecount();
foreach ($courses as $course) { foreach ($courses as $course) {
if ($recount && $hour % 3 == 0) { if ($allowRecount) {
$course->user_count = $courseRepo->countUsers($course->id); $course->user_count = $courseRepo->countUsers($course->id);
$course->lesson_count = $courseRepo->countLessons($course->id);
$course->comment_count = $courseRepo->countComments($course->id); $course->comment_count = $courseRepo->countComments($course->id);
$course->consult_count = $courseRepo->countConsults($course->id); $course->consult_count = $courseRepo->countConsults($course->id);
$course->review_count = $courseRepo->countReviews($course->id); $course->review_count = $courseRepo->countReviews($course->id);
@ -75,7 +72,6 @@ class SyncCourseCounterTask extends Task
if ($counter) { if ($counter) {
$course->user_count = $counter['user_count']; $course->user_count = $counter['user_count'];
$course->lesson_count = $counter['lesson_count'];
$course->comment_count = $counter['comment_count']; $course->comment_count = $counter['comment_count'];
$course->consult_count = $counter['consult_count']; $course->consult_count = $counter['consult_count'];
$course->review_count = $counter['review_count']; $course->review_count = $counter['review_count'];
@ -95,11 +91,9 @@ class SyncCourseCounterTask extends Task
return $syncer->getSyncKey(); return $syncer->getSyncKey();
} }
protected function checkEnableRecount() protected function allowRecount()
{ {
$config = $this->getDI()->get('config'); return date('H') % 2 == 0;
return $config->syncer->recount_course ?? false;
} }
} }

View File

@ -47,13 +47,11 @@ class SyncReviewCounterTask extends Task
$counterCache = new ReviewCounterCache(); $counterCache = new ReviewCounterCache();
$hour = date('H'); $allowRecount = $this->allowRecount();
$recount = $this->checkEnableRecount();
foreach ($reviews as $review) { foreach ($reviews as $review) {
if ($recount && $hour % 3 == 0) { if ($allowRecount) {
$review->like_count = $reviewRepo->countLikes($review->id); $review->like_count = $reviewRepo->countLikes($review->id);
$review->update(); $review->update();
@ -81,11 +79,9 @@ class SyncReviewCounterTask extends Task
return $syncer->getSyncKey(); return $syncer->getSyncKey();
} }
protected function checkEnableRecount() protected function allowRecount()
{ {
$config = $this->getDI()->get('config'); return date('H') == 2;
return $config->syncer->recount_review ?? false;
} }
} }

View File

@ -72,6 +72,8 @@ Trait ImGroupTrait
'group_id' => $group->id, 'group_id' => $group->id,
'user_id' => $applicant->id, 'user_id' => $applicant->id,
]); ]);
$group->user_count += 1;
$group->update();
} }
$itemInfo = $message->item_info; $itemInfo = $message->item_info;

View File

@ -117,6 +117,10 @@ class Category extends Model
public function beforeUpdate() public function beforeUpdate()
{ {
$this->update_time = time(); $this->update_time = time();
if ($this->deleted == 1) {
$this->published = 0;
}
} }
public function afterCreate() public function afterCreate()

View File

@ -216,6 +216,10 @@ class Chapter extends Model
{ {
$this->update_time = time(); $this->update_time = time();
if ($this->deleted == 1) {
$this->published = 0;
}
if (is_array($this->attrs)) { if (is_array($this->attrs)) {
$this->attrs = kg_json_encode($this->attrs); $this->attrs = kg_json_encode($this->attrs);
} }

View File

@ -123,6 +123,10 @@ class Comment extends Model
public function beforeUpdate() public function beforeUpdate()
{ {
$this->update_time = time(); $this->update_time = time();
if ($this->deleted == 1) {
$this->published = 0;
}
} }
} }

View File

@ -109,6 +109,10 @@ class Consult extends Model
public function beforeUpdate() public function beforeUpdate()
{ {
$this->update_time = time(); $this->update_time = time();
if ($this->deleted == 1) {
$this->published = 0;
}
} }
} }

View File

@ -284,6 +284,10 @@ class Course extends Model
{ {
$this->update_time = time(); $this->update_time = time();
if ($this->deleted == 1) {
$this->published = 0;
}
if (Text::startsWith($this->cover, 'http')) { if (Text::startsWith($this->cover, 'http')) {
$this->cover = self::getCoverPath($this->cover); $this->cover = self::getCoverPath($this->cover);
} }

View File

@ -145,6 +145,10 @@ class Danmu extends Model
public function beforeUpdate() public function beforeUpdate()
{ {
$this->update_time = time(); $this->update_time = time();
if ($this->deleted == 1) {
$this->published = 0;
}
} }
public static function sizeTypes() public static function sizeTypes()

View File

@ -89,6 +89,10 @@ class Help extends Model
public function beforeUpdate() public function beforeUpdate()
{ {
$this->update_time = time(); $this->update_time = time();
if ($this->deleted == 1) {
$this->published = 0;
}
} }
public function afterCreate() public function afterCreate()

View File

@ -142,6 +142,10 @@ class Nav extends Model
public function beforeUpdate() public function beforeUpdate()
{ {
$this->update_time = time(); $this->update_time = time();
if ($this->deleted == 1) {
$this->published = 0;
}
} }
public static function positionTypes() public static function positionTypes()

View File

@ -103,6 +103,10 @@ class Package extends Model
public function beforeUpdate() public function beforeUpdate()
{ {
$this->update_time = time(); $this->update_time = time();
if ($this->deleted == 1) {
$this->published = 0;
}
} }
public function afterCreate() public function afterCreate()

View File

@ -29,6 +29,13 @@ class Page extends Model
*/ */
public $content; public $content;
/**
* 发布标识
*
* @var int
*/
public $published;
/** /**
* 删除标识 * 删除标识
* *
@ -75,6 +82,10 @@ class Page extends Model
public function beforeUpdate() public function beforeUpdate()
{ {
$this->update_time = time(); $this->update_time = time();
if ($this->deleted == 1) {
$this->published = 0;
}
} }
public function afterCreate() public function afterCreate()

View File

@ -134,6 +134,10 @@ class Review extends Model
$this->update_time = time(); $this->update_time = time();
$this->rating = $this->getAvgRating(); $this->rating = $this->getAvgRating();
if ($this->deleted == 1) {
$this->published = 0;
}
} }
protected function getAvgRating() protected function getAvgRating()

View File

@ -135,6 +135,10 @@ class Slide extends Model
{ {
$this->update_time = time(); $this->update_time = time();
if ($this->deleted == 1) {
$this->published = 0;
}
if (Text::startsWith($this->cover, 'http')) { if (Text::startsWith($this->cover, 'http')) {
$this->cover = self::getCoverPath($this->cover); $this->cover = self::getCoverPath($this->cover);
} }

View File

@ -89,6 +89,10 @@ class Topic extends Model
public function beforeUpdate() public function beforeUpdate()
{ {
$this->update_time = time(); $this->update_time = time();
if ($this->deleted == 1) {
$this->published = 0;
}
} }
public function afterCreate() public function afterCreate()

View File

@ -72,7 +72,6 @@ class Category extends Repository
{ {
return CategoryModel::query() return CategoryModel::query()
->where('parent_id = 0') ->where('parent_id = 0')
->andWhere('deleted = 0')
->andWhere('published = 1') ->andWhere('published = 1')
->execute(); ->execute();
} }
@ -85,7 +84,6 @@ class Category extends Repository
{ {
return CategoryModel::query() return CategoryModel::query()
->where('parent_id = :parent_id:', ['parent_id' => $categoryId]) ->where('parent_id = :parent_id:', ['parent_id' => $categoryId])
->andWhere('deleted = 0')
->andWhere('published = 1') ->andWhere('published = 1')
->execute(); ->execute();
} }
@ -93,7 +91,7 @@ class Category extends Repository
public function countChildCategories($categoryId) public function countChildCategories($categoryId)
{ {
return CategoryModel::count([ return CategoryModel::count([
'conditions' => 'parent_id = :parent_id: AND deleted = 0 AND published = 1', 'conditions' => 'parent_id = :parent_id: AND published = 1',
'bind' => ['parent_id' => $categoryId], 'bind' => ['parent_id' => $categoryId],
]); ]);
} }
@ -101,7 +99,7 @@ class Category extends Repository
public function countCourses($categoryId) public function countCourses($categoryId)
{ {
$phql = 'SELECT COUNT(*) AS total FROM %s cc JOIN %s c ON cc.course_id = c.id $phql = 'SELECT COUNT(*) AS total FROM %s cc JOIN %s c ON cc.course_id = c.id
WHERE cc.category_id = :category_id: AND c.published = 1 AND c.deleted = 0'; WHERE cc.category_id = :category_id: AND c.published = 1 AND c.published = 1';
$phql = sprintf($phql, CourseCategoryModel::class, CourseModel::class); $phql = sprintf($phql, CourseCategoryModel::class, CourseModel::class);

View File

@ -146,7 +146,6 @@ class Course extends Repository
->join(CourseUserModel::class, 'u.id = cu.user_id', 'cu') ->join(CourseUserModel::class, 'u.id = cu.user_id', 'cu')
->where('cu.course_id = :course_id:', ['course_id' => $courseId]) ->where('cu.course_id = :course_id:', ['course_id' => $courseId])
->andWhere('cu.role_type = :role_type:', ['role_type' => $roleType]) ->andWhere('cu.role_type = :role_type:', ['role_type' => $roleType])
->andWhere('u.deleted = 0')
->getQuery()->execute(); ->getQuery()->execute();
} }
@ -161,7 +160,7 @@ class Course extends Repository
->addFrom(CategoryModel::class, 'c') ->addFrom(CategoryModel::class, 'c')
->join(CourseCategoryModel::class, 'c.id = cc.category_id', 'cc') ->join(CourseCategoryModel::class, 'c.id = cc.category_id', 'cc')
->where('cc.course_id = :course_id:', ['course_id' => $courseId]) ->where('cc.course_id = :course_id:', ['course_id' => $courseId])
->andWhere('c.deleted = 0') ->andWhere('c.published = 1')
->getQuery()->execute(); ->getQuery()->execute();
} }
@ -176,7 +175,7 @@ class Course extends Repository
->addFrom(PackageModel::class, 'p') ->addFrom(PackageModel::class, 'p')
->join(CoursePackageModel::class, 'p.id = cp.package_id', 'cp') ->join(CoursePackageModel::class, 'p.id = cp.package_id', 'cp')
->where('cp.course_id = :course_id:', ['course_id' => $courseId]) ->where('cp.course_id = :course_id:', ['course_id' => $courseId])
->andWhere('p.deleted = 0') ->andWhere('p.published = 1')
->getQuery()->execute(); ->getQuery()->execute();
} }
@ -191,7 +190,7 @@ class Course extends Repository
->addFrom(CourseModel::class, 'c') ->addFrom(CourseModel::class, 'c')
->join(CourseRelatedModel::class, 'c.id = cr.related_id', 'cr') ->join(CourseRelatedModel::class, 'c.id = cr.related_id', 'cr')
->where('cr.course_id = :course_id:', ['course_id' => $courseId]) ->where('cr.course_id = :course_id:', ['course_id' => $courseId])
->andWhere('c.deleted = 0') ->andWhere('c.published = 1')
->getQuery()->execute(); ->getQuery()->execute();
} }

View File

@ -87,7 +87,7 @@ class Package extends Repository
->addFrom(CourseModel::class, 'c') ->addFrom(CourseModel::class, 'c')
->join(CoursePackageModel::class, 'c.id = cp.course_id', 'cp') ->join(CoursePackageModel::class, 'c.id = cp.course_id', 'cp')
->where('cp.package_id = :package_id:', ['package_id' => $packageId]) ->where('cp.package_id = :package_id:', ['package_id' => $packageId])
->andWhere('c.deleted = 0') ->andWhere('c.published = 1')
->getQuery() ->getQuery()
->execute(); ->execute();
} }

View File

@ -83,7 +83,7 @@ class Topic extends Repository
->addFrom(CourseModel::class, 'c') ->addFrom(CourseModel::class, 'c')
->join(CourseTopicModel::class, 'c.id = ct.course_id', 'ct') ->join(CourseTopicModel::class, 'c.id = ct.course_id', 'ct')
->where('ct.topic_id = :topic_id:', ['topic_id' => $topicId]) ->where('ct.topic_id = :topic_id:', ['topic_id' => $topicId])
->andWhere('c.deleted = 0') ->andWhere('c.published = 1')
->getQuery()->execute(); ->getQuery()->execute();
} }

View File

@ -59,7 +59,7 @@ class Captcha extends Service
$request = new DescribeCaptchaResultRequest(); $request = new DescribeCaptchaResultRequest();
/** /**
* 注意CaptchaType CaptchaAppId 强类型要求 * 注意CaptchaType和CaptchaAppId强类型要求
*/ */
$params = json_encode([ $params = json_encode([
'Ticket' => $ticket, 'Ticket' => $ticket,

View File

@ -48,11 +48,6 @@ class ChapterBasic extends FrontendService
$playUrls = $chapterVodService->getPlayUrls($chapter->id); $playUrls = $chapterVodService->getPlayUrls($chapter->id);
/**
* @var array $attrs
*/
$attrs = $chapter->attrs;
return [ return [
'id' => $chapter->id, 'id' => $chapter->id,
'title' => $chapter->title, 'title' => $chapter->title,
@ -83,11 +78,6 @@ class ChapterBasic extends FrontendService
$live = $chapterRepo->findChapterLive($chapter->id); $live = $chapterRepo->findChapterLive($chapter->id);
/**
* @var array $attrs
*/
$attrs = $chapter->attrs;
return [ return [
'id' => $chapter->id, 'id' => $chapter->id,
'title' => $chapter->title, 'title' => $chapter->title,

View File

@ -28,6 +28,7 @@ class Learning extends FrontendService
'course_id' => $chapter->course_id, 'course_id' => $chapter->course_id,
'chapter_id' => $chapter->id, 'chapter_id' => $chapter->id,
'user_id' => $user->id, 'user_id' => $user->id,
'position' => 0,
]; ];
$data['request_id'] = $validator->checkRequestId($post['request_id']); $data['request_id'] = $validator->checkRequestId($post['request_id']);

View File

@ -5,9 +5,9 @@ namespace App\Services\Frontend\Course;
use App\Models\Course as CourseModel; use App\Models\Course as CourseModel;
use App\Models\CourseFavorite as CourseFavoriteModel; 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\Services\Frontend\CourseTrait; use App\Services\Frontend\CourseTrait;
use App\Services\Frontend\Service as FrontendService; use App\Services\Frontend\Service as FrontendService;
use App\Validators\Course as CourseValidator;
use App\Validators\UserDailyLimit as UserDailyLimitValidator; use App\Validators\UserDailyLimit as UserDailyLimitValidator;
class Favorite extends FrontendService class Favorite extends FrontendService
@ -25,18 +25,18 @@ class Favorite extends FrontendService
$validator->checkFavoriteLimit($user); $validator->checkFavoriteLimit($user);
$favoriteRepo = new CourseFavoriteRepo(); $validator = new CourseValidator();
$favorite = $favoriteRepo->findCourseFavorite($course->id, $user->id); $favorite = $validator->checkIfFavorited($course->id, $user->id);
if (!$favorite) { if (!$favorite) {
$favorite = new CourseFavoriteModel(); $favorite = new CourseFavoriteModel();
$favorite->course_id = $course->id; $favorite->create([
$favorite->user_id = $user->id; 'course_id' => $course->id,
'user_id' => $user->id,
$favorite->create(); ]);
$this->incrCourseFavoriteCount($course); $this->incrCourseFavoriteCount($course);
@ -44,18 +44,16 @@ class Favorite extends FrontendService
if ($favorite->deleted == 0) { if ($favorite->deleted == 0) {
$favorite->deleted = 1; $favorite->update(['deleted' => 1]);
$this->decrCourseFavoriteCount($course); $this->decrCourseFavoriteCount($course);
} else { } else {
$favorite->deleted = 0; $favorite->update(['deleted' => 0]);
$this->incrCourseFavoriteCount($course); $this->incrCourseFavoriteCount($course);
} }
$favorite->update();
} }
$this->incrUserDailyFavoriteCount($user); $this->incrUserDailyFavoriteCount($user);

View File

@ -1,19 +0,0 @@
<?php
namespace App\Services\Frontend\Messenger;
use App\Services\Frontend\Service as FrontendService;
class ContactList extends FrontendService
{
public function handle()
{
$user = $this->getLoginUser();
$mine = [
];
}
}

View File

@ -137,7 +137,7 @@ class Chapter extends Validator
return $status; return $status;
} }
public function checkPublishAbility($chapter) public function checkPublishAbility(ChapterModel $chapter)
{ {
$courseRepo = new CourseRepo(); $courseRepo = new CourseRepo();
@ -160,7 +160,7 @@ class Chapter extends Validator
} }
} }
public function checkDeleteAbility($chapter) public function checkDeleteAbility(ChapterModel $chapter)
{ {
$chapterRepo = new ChapterRepo(); $chapterRepo = new ChapterRepo();
@ -178,13 +178,13 @@ class Chapter extends Validator
{ {
$repo = new ChapterLikeRepo(); $repo = new ChapterLikeRepo();
$chapterLike = $repo->findChapterLike($chapterId, $userId); $like = $repo->findChapterLike($chapterId, $userId);
if ($chapterLike && time() - $chapterLike->create_time > 5 * 60) { if ($like && time() - $like->create_time > 5 * 60) {
throw new BadRequestException('chapter.has_liked'); throw new BadRequestException('chapter.has_liked');
} }
return $chapterLike; return $like;
} }
} }

View File

@ -80,13 +80,13 @@ class Comment extends Validator
{ {
$repo = new CommentLikeRepo(); $repo = new CommentLikeRepo();
$commentLike = $repo->findCommentLike($chapterId, $userId); $like = $repo->findCommentLike($chapterId, $userId);
if ($commentLike && time() - $commentLike->create_time > 5 * 60) { if ($like && time() - $like->create_time > 5 * 60) {
throw new BadRequestException('comment.has_liked'); throw new BadRequestException('comment.has_liked');
} }
return $commentLike; return $like;
} }
} }

View File

@ -85,13 +85,13 @@ class Consult extends Validator
{ {
$repo = new ConsultLikeRepo(); $repo = new ConsultLikeRepo();
$consultLike = $repo->findConsultLike($chapterId, $userId); $like = $repo->findConsultLike($chapterId, $userId);
if ($consultLike && time() - $consultLike->create_time > 5 * 60) { if ($like && time() - $like->create_time > 5 * 60) {
throw new BadRequestException('consult.has_liked'); throw new BadRequestException('consult.has_liked');
} }
return $consultLike; return $like;
} }
} }

View File

@ -8,6 +8,7 @@ use App\Exceptions\BadRequest as BadRequestException;
use App\Library\Validators\Common as CommonValidator; use App\Library\Validators\Common as CommonValidator;
use App\Models\Course as CourseModel; use App\Models\Course as CourseModel;
use App\Repos\Course as CourseRepo; use App\Repos\Course as CourseRepo;
use App\Repos\CourseFavorite as CourseFavoriteRepo;
class Course extends Validator class Course extends Validator
{ {
@ -217,7 +218,7 @@ class Course extends Validator
return $status; return $status;
} }
public function checkPublishAbility($course) public function checkPublishAbility(CourseModel $course)
{ {
$courseRepo = new CourseRepo(); $courseRepo = new CourseRepo();
@ -242,4 +243,17 @@ class Course extends Validator
} }
} }
public function checkIfFavorited($courseId, $userId)
{
$repo = new CourseFavoriteRepo();
$favorite = $repo->findCourseFavorite($courseId, $userId);
if ($favorite && time() - $favorite->create_time > 5 * 60) {
throw new BadRequestException('course.has_favorited');
}
return $favorite;
}
} }

View File

@ -69,13 +69,13 @@ class Review extends Validator
{ {
$repo = new ReviewLikeRepo(); $repo = new ReviewLikeRepo();
$reviewLike = $repo->findReviewLike($reviewId, $userId); $like = $repo->findReviewLike($reviewId, $userId);
if ($reviewLike && time() - $reviewLike->create_time > 5 * 60) { if ($like && time() - $like->create_time > 5 * 60) {
throw new BadRequestException('review.has_liked'); throw new BadRequestException('review.has_liked');
} }
return $reviewLike; return $like;
} }
} }

View File

@ -112,6 +112,7 @@ $error['course.invalid_refund_expiry'] = '无效的退款期限';
$error['course.invalid_publish_status'] = '无效的发布状态'; $error['course.invalid_publish_status'] = '无效的发布状态';
$error['course.pub_chapter_not_found'] = '尚未发现已发布的课时'; $error['course.pub_chapter_not_found'] = '尚未发现已发布的课时';
$error['course.pub_chapter_not_enough'] = '已发布的课时太少小于30%'; $error['course.pub_chapter_not_enough'] = '已发布的课时太少小于30%';
$error['course.has_favorited'] = '你已收藏过该课程啦';
/** /**
* 话题相关 * 话题相关

View File

@ -84,6 +84,12 @@
bottom: 60px; bottom: 60px;
} }
body {
display: flex;
flex-flow: column;
min-height: 100vh;
}
#header { #header {
left: 0; left: 0;
top: 0; top: 0;
@ -96,14 +102,15 @@
#main { #main {
margin-top: 80px; margin-top: 80px;
margin-bottom: 30px; margin-bottom: 30px;
min-height: 550px; flex: 1;
} }
#footer { #footer {
width: 100%;
padding: 30px 0; padding: 30px 0;
background: #474443;
text-align: center; text-align: center;
font-size: 12px; font-size: 12px;
background: #474443;
} }
.logo { .logo {
@ -137,11 +144,15 @@
color: #fff; color: #fff;
} }
.bottom-nav, .copyright { .bottom-nav {
margin-bottom: 10px; margin-bottom: 10px;
line-height: 18px; line-height: 18px;
} }
.copyright {
line-height: 18px;
}
.bottom-nav a, .copyright span, .copyright a { .bottom-nav a, .copyright span, .copyright a {
margin-right: 10px; margin-right: 10px;
} }