From 50c5e403eb6e3a9de0b0c4f0c3f2b615947fb904 Mon Sep 17 00:00:00 2001 From: xiaochong0302 Date: Sun, 12 Jul 2020 19:40:31 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8C=96=E6=8A=95=E7=A5=A8=E4=B8=BA?= =?UTF-8?q?=E5=8D=95=E4=B8=80=E7=82=B9=E8=B5=9E=EF=BC=8C=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=A4=9A=E7=BB=B4=E5=BA=A6=E8=AF=84=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Caches/ChapterCounter.php | 3 +- app/Caches/CommentCounter.php | 3 +- app/Caches/ConsultCounter.php | 3 +- app/Caches/ReviewCounter.php | 3 +- app/Caches/UserDailyCounter.php | 8 +- app/Console/Tasks/SyncChapterCounterTask.php | 6 +- app/Console/Tasks/SyncCommentCounterTask.php | 6 +- app/Console/Tasks/SyncConsultCounterTask.php | 6 +- app/Console/Tasks/SyncReviewCounterTask.php | 6 +- .../Web/Controllers/ChapterController.php | 21 +--- .../Web/Controllers/CommentController.php | 21 +--- .../Web/Controllers/ConsultController.php | 21 +--- app/Http/Web/Controllers/ReviewController.php | 21 +--- app/Http/Web/Views/chapter/menu.volt | 2 +- app/Http/Web/Views/chapter/show_vod.volt | 27 ++--- app/Listeners/ChapterCounter.php | 36 +------ app/Listeners/CommentCounter.php | 22 +--- app/Listeners/ConsultCounter.php | 22 +--- app/Listeners/CourseCounter.php | 28 ----- app/Listeners/ReviewCounter.php | 22 +--- app/Listeners/UserDailyCounter.php | 16 +-- app/Models/Chapter.php | 11 +- .../{ChapterVote.php => ChapterLike.php} | 18 +--- app/Models/Comment.php | 35 +----- .../{CommentVote.php => CommentLike.php} | 18 +--- app/Models/Consult.php | 9 +- .../{ConsultVote.php => ConsultLike.php} | 18 +--- app/Models/Course.php | 11 +- app/Models/CourseRating.php | 100 ++++++++++++++++++ app/Models/Review.php | 28 +++-- app/Models/{ReviewVote.php => ReviewLike.php} | 18 +--- app/Repos/Chapter.php | 47 +------- .../{ChapterVote.php => ChapterLike.php} | 10 +- app/Repos/Comment.php | 22 +--- .../{CommentVote.php => CommentLike.php} | 12 +-- app/Repos/Consult.php | 26 +---- .../{ConsultVote.php => ConsultLike.php} | 10 +- app/Repos/Course.php | 16 +-- app/Repos/Review.php | 22 +--- app/Repos/{ReviewVote.php => ReviewLike.php} | 12 +-- app/Services/Frontend/Chapter/AgreeVote.php | 73 ------------- .../Frontend/Chapter/ChapterBasic.php | 9 +- app/Services/Frontend/Chapter/ChapterInfo.php | 29 +---- app/Services/Frontend/Chapter/ChapterLike.php | 89 ++++++++++++++++ app/Services/Frontend/Chapter/CommentList.php | 57 +--------- app/Services/Frontend/Chapter/OpposeVote.php | 73 ------------- app/Services/Frontend/Chapter/VoteTrait.php | 46 -------- app/Services/Frontend/Comment/AgreeVote.php | 73 ------------- app/Services/Frontend/Comment/CommentInfo.php | 34 +----- app/Services/Frontend/Comment/CommentLike.php | 89 ++++++++++++++++ app/Services/Frontend/Comment/OpposeVote.php | 73 ------------- app/Services/Frontend/Comment/VoteTrait.php | 46 -------- app/Services/Frontend/Consult/AgreeVote.php | 73 ------------- app/Services/Frontend/Consult/ConsultInfo.php | 33 +----- app/Services/Frontend/Consult/ConsultLike.php | 89 ++++++++++++++++ app/Services/Frontend/Consult/OpposeVote.php | 73 ------------- app/Services/Frontend/Consult/VoteTrait.php | 46 -------- app/Services/Frontend/Course/ConsultList.php | 58 +--------- app/Services/Frontend/Course/ReviewList.php | 57 +--------- app/Services/Frontend/My/ConsultList.php | 3 +- app/Services/Frontend/My/ReviewList.php | 3 +- app/Services/Frontend/Review/AgreeVote.php | 73 ------------- app/Services/Frontend/Review/OpposeVote.php | 73 ------------- app/Services/Frontend/Review/ReviewCreate.php | 24 +++-- app/Services/Frontend/Review/ReviewInfo.php | 33 +----- app/Services/Frontend/Review/ReviewLike.php | 91 ++++++++++++++++ app/Services/Frontend/Review/VoteTrait.php | 46 -------- app/Validators/Chapter.php | 12 +++ app/Validators/Comment.php | 17 ++- app/Validators/Consult.php | 12 +++ app/Validators/Review.php | 12 +++ app/Validators/UserDailyLimit.php | 24 ++--- config/errors.php | 9 +- public/static/web/css/common.css | 45 +++++++- public/static/web/js/chapter.action.js | 37 +++++++ public/static/web/js/vod.player.js | 2 +- 76 files changed, 807 insertions(+), 1575 deletions(-) rename app/Models/{ChapterVote.php => ChapterLike.php} (77%) rename app/Models/{CommentVote.php => CommentLike.php} (77%) rename app/Models/{ConsultVote.php => ConsultLike.php} (76%) create mode 100644 app/Models/CourseRating.php rename app/Models/{ReviewVote.php => ReviewLike.php} (76%) rename app/Repos/{ChapterVote.php => ChapterLike.php} (57%) rename app/Repos/{CommentVote.php => CommentLike.php} (54%) rename app/Repos/{ConsultVote.php => ConsultLike.php} (57%) rename app/Repos/{ReviewVote.php => ReviewLike.php} (54%) delete mode 100644 app/Services/Frontend/Chapter/AgreeVote.php create mode 100644 app/Services/Frontend/Chapter/ChapterLike.php delete mode 100644 app/Services/Frontend/Chapter/OpposeVote.php delete mode 100644 app/Services/Frontend/Chapter/VoteTrait.php delete mode 100644 app/Services/Frontend/Comment/AgreeVote.php create mode 100644 app/Services/Frontend/Comment/CommentLike.php delete mode 100644 app/Services/Frontend/Comment/OpposeVote.php delete mode 100644 app/Services/Frontend/Comment/VoteTrait.php delete mode 100644 app/Services/Frontend/Consult/AgreeVote.php create mode 100644 app/Services/Frontend/Consult/ConsultLike.php delete mode 100644 app/Services/Frontend/Consult/OpposeVote.php delete mode 100644 app/Services/Frontend/Consult/VoteTrait.php delete mode 100644 app/Services/Frontend/Review/AgreeVote.php delete mode 100644 app/Services/Frontend/Review/OpposeVote.php create mode 100644 app/Services/Frontend/Review/ReviewLike.php delete mode 100644 app/Services/Frontend/Review/VoteTrait.php create mode 100644 public/static/web/js/chapter.action.js diff --git a/app/Caches/ChapterCounter.php b/app/Caches/ChapterCounter.php index a07b39a7..3ed88699 100644 --- a/app/Caches/ChapterCounter.php +++ b/app/Caches/ChapterCounter.php @@ -31,8 +31,7 @@ class ChapterCounter extends Counter 'user_count' => $chapter->user_count, 'lesson_count' => $chapter->lesson_count, 'comment_count' => $chapter->comment_count, - 'agree_count' => $chapter->agree_count, - 'oppose_count' => $chapter->oppose_count, + 'like_count' => $chapter->like_count, ]; } diff --git a/app/Caches/CommentCounter.php b/app/Caches/CommentCounter.php index 4afed9ac..daa5e6d4 100644 --- a/app/Caches/CommentCounter.php +++ b/app/Caches/CommentCounter.php @@ -29,8 +29,7 @@ class CommentCounter extends Counter return [ 'reply_count' => $comment->reply_count, - 'agree_count' => $comment->agree_count, - 'oppose_count' => $comment->oppose_count, + 'like_count' => $comment->like_count, ]; } diff --git a/app/Caches/ConsultCounter.php b/app/Caches/ConsultCounter.php index 6d0f4570..0e16c623 100644 --- a/app/Caches/ConsultCounter.php +++ b/app/Caches/ConsultCounter.php @@ -28,8 +28,7 @@ class ConsultCounter extends Counter if (!$consult) return null; return [ - 'agree_count' => $consult->agree_count, - 'oppose_count' => $consult->oppose_count, + 'like_count' => $consult->like_count, ]; } diff --git a/app/Caches/ReviewCounter.php b/app/Caches/ReviewCounter.php index 24cd5811..6d23b686 100644 --- a/app/Caches/ReviewCounter.php +++ b/app/Caches/ReviewCounter.php @@ -28,8 +28,7 @@ class ReviewCounter extends Counter if (!$review) return null; return [ - 'agree_count' => $review->agree_count, - 'oppose_count' => $review->oppose_count, + 'like_count' => $review->like_count, ]; } diff --git a/app/Caches/UserDailyCounter.php b/app/Caches/UserDailyCounter.php index 6eb45a68..3c2e207e 100644 --- a/app/Caches/UserDailyCounter.php +++ b/app/Caches/UserDailyCounter.php @@ -27,10 +27,10 @@ class UserDailyCounter extends Counter 'danmu_count' => 0, 'consult_count' => 0, 'order_count' => 0, - 'chapter_vote_count' => 0, - 'comment_vote_count' => 0, - 'consult_vote_count' => 0, - 'review_vote_count' => 0, + 'chapter_like_count' => 0, + 'comment_like_count' => 0, + 'consult_like_count' => 0, + 'review_like_count' => 0, ]; } diff --git a/app/Console/Tasks/SyncChapterCounterTask.php b/app/Console/Tasks/SyncChapterCounterTask.php index 2182e37e..803ef67b 100644 --- a/app/Console/Tasks/SyncChapterCounterTask.php +++ b/app/Console/Tasks/SyncChapterCounterTask.php @@ -61,8 +61,7 @@ class SyncChapterCounterTask extends Task $chapter->user_count = $chapterRepo->countUsers($chapter->id); $chapter->lesson_count = $chapterRepo->countLessons($chapter->id); $chapter->comment_count = $chapterRepo->countComments($chapter->id); - $chapter->agree_count = $chapterRepo->countAgrees($chapter->id); - $chapter->oppose_count = $chapterRepo->countOpposes($chapter->id); + $chapter->like_count = $chapterRepo->countLikes($chapter->id); $chapter->update(); $counterCache->rebuild($chapter->id); @@ -77,8 +76,7 @@ class SyncChapterCounterTask extends Task $chapter->user_count = $counter['user_count']; $chapter->lesson_count = $counter['lesson_count']; $chapter->comment_count = $counter['comment_count']; - $chapter->agree_count = $counter['agree_count']; - $chapter->oppose_count = $counter['oppose_count']; + $chapter->like_count = $counter['like_count']; $chapter->update(); $chapterCache->rebuild($chapter->id); diff --git a/app/Console/Tasks/SyncCommentCounterTask.php b/app/Console/Tasks/SyncCommentCounterTask.php index ea8ec5a7..d55f1fd6 100644 --- a/app/Console/Tasks/SyncCommentCounterTask.php +++ b/app/Console/Tasks/SyncCommentCounterTask.php @@ -56,8 +56,7 @@ class SyncCommentCounterTask extends Task if ($recount && $hour % 3 == 0) { $comment->reply_count = $commentRepo->countReplies($comment->id); - $comment->agree_count = $commentRepo->countAgrees($comment->id); - $comment->oppose_count = $commentRepo->countOpposes($comment->id); + $comment->like_count = $commentRepo->countLikes($comment->id); $comment->update(); $counterCache->rebuild($comment->id); @@ -68,8 +67,7 @@ class SyncCommentCounterTask extends Task if ($counter) { $comment->reply_count = $counter['reply_count']; - $comment->agree_count = $counter['agree_count']; - $comment->oppose_count = $counter['oppose_count']; + $comment->like_count = $counter['like_count']; $comment->update(); } } diff --git a/app/Console/Tasks/SyncConsultCounterTask.php b/app/Console/Tasks/SyncConsultCounterTask.php index 1e4d3df0..7a92aa46 100644 --- a/app/Console/Tasks/SyncConsultCounterTask.php +++ b/app/Console/Tasks/SyncConsultCounterTask.php @@ -55,8 +55,7 @@ class SyncConsultCounterTask extends Task if ($recount && $hour % 3 == 0) { - $consult->agree_count = $consultRepo->countAgrees($consult->id); - $consult->oppose_count = $consultRepo->countOpposes($consult->id); + $consult->like_count = $consultRepo->countLikes($consult->id); $consult->update(); $counterCache->rebuild($consult->id); @@ -66,8 +65,7 @@ class SyncConsultCounterTask extends Task $counter = $counterCache->get($consult->id); if ($counter) { - $consult->agree_count = $counter['agree_count']; - $consult->oppose_count = $counter['oppose_count']; + $consult->like_count = $counter['like_count']; $consult->update(); } } diff --git a/app/Console/Tasks/SyncReviewCounterTask.php b/app/Console/Tasks/SyncReviewCounterTask.php index 826893d6..27ad4612 100644 --- a/app/Console/Tasks/SyncReviewCounterTask.php +++ b/app/Console/Tasks/SyncReviewCounterTask.php @@ -55,8 +55,7 @@ class SyncReviewCounterTask extends Task if ($recount && $hour % 3 == 0) { - $review->agree_count = $reviewRepo->countAgrees($review->id); - $review->oppose_count = $reviewRepo->countOpposes($review->id); + $review->like_count = $reviewRepo->countLikes($review->id); $review->update(); $counterCache->rebuild($review->id); @@ -66,8 +65,7 @@ class SyncReviewCounterTask extends Task $counter = $counterCache->get($review->id); if ($counter) { - $review->agree_count = $counter['agree_count']; - $review->oppose_count = $counter['oppose_count']; + $review->like_count = $counter['like_count']; $review->update(); } } diff --git a/app/Http/Web/Controllers/ChapterController.php b/app/Http/Web/Controllers/ChapterController.php index 8b3c4393..d951a5d9 100644 --- a/app/Http/Web/Controllers/ChapterController.php +++ b/app/Http/Web/Controllers/ChapterController.php @@ -2,12 +2,11 @@ namespace App\Http\Web\Controllers; -use App\Services\Frontend\Chapter\AgreeVote as ChapterAgreeVoteService; use App\Services\Frontend\Chapter\ChapterInfo as ChapterInfoService; +use App\Services\Frontend\Chapter\ChapterLike as ChapterLikeService; use App\Services\Frontend\Chapter\CommentList as ChapterCommentListService; use App\Services\Frontend\Chapter\DanmuList as ChapterDanmuListService; use App\Services\Frontend\Chapter\Learning as ChapterLearningService; -use App\Services\Frontend\Chapter\OpposeVote as ChapterOpposeVoteService; use App\Services\Frontend\Course\ChapterList as CourseChapterListService; /** @@ -79,23 +78,11 @@ class ChapterController extends Controller } /** - * @Post("/{id:[0-9]+}/agree", name="web.chapter.agree") + * @Post("/{id:[0-9]+}/like", name="web.chapter.like") */ - public function agreeAction($id) + public function likeAction($id) { - $service = new ChapterAgreeVoteService(); - - $service->handle($id); - - return $this->jsonSuccess(); - } - - /** - * @Post("/{id:[0-9]+}/oppose", name="web.chapter.oppose") - */ - public function opposeAction($id) - { - $service = new ChapterOpposeVoteService(); + $service = new ChapterLikeService(); $service->handle($id); diff --git a/app/Http/Web/Controllers/CommentController.php b/app/Http/Web/Controllers/CommentController.php index a3d417de..fa81303e 100644 --- a/app/Http/Web/Controllers/CommentController.php +++ b/app/Http/Web/Controllers/CommentController.php @@ -2,12 +2,11 @@ namespace App\Http\Web\Controllers; -use App\Services\Frontend\Comment\AgreeVote as CommentAgreeVoteService; use App\Services\Frontend\Comment\CommentCreate as CommentCreateService; use App\Services\Frontend\Comment\CommentDelete as CommentDeleteService; use App\Services\Frontend\Comment\CommentInfo as CommentInfoService; +use App\Services\Frontend\Comment\CommentLike as CommentLikeService; use App\Services\Frontend\Comment\CommentUpdate as CommentUpdateService; -use App\Services\Frontend\Comment\OpposeVote as CommentOpposeVoteService; /** * @RoutePrefix("/comment") @@ -68,23 +67,11 @@ class CommentController extends Controller } /** - * @Post("/{id:[0-9]+}/agree", name="web.comment.agree") + * @Post("/{id:[0-9]+}/like", name="web.comment.like") */ - public function agreeAction($id) + public function likeAction($id) { - $service = new CommentAgreeVoteService(); - - $service->handle($id); - - return $this->jsonSuccess(); - } - - /** - * @Post("/{id:[0-9]+}/oppose", name="web.comment.oppose") - */ - public function opposeAction($id) - { - $service = new CommentOpposeVoteService(); + $service = new CommentLikeService(); $service->handle($id); diff --git a/app/Http/Web/Controllers/ConsultController.php b/app/Http/Web/Controllers/ConsultController.php index 2795599a..9581e5b8 100644 --- a/app/Http/Web/Controllers/ConsultController.php +++ b/app/Http/Web/Controllers/ConsultController.php @@ -2,12 +2,11 @@ namespace App\Http\Web\Controllers; -use App\Services\Frontend\Consult\AgreeVote as ConsultAgreeVoteService; use App\Services\Frontend\Consult\ConsultCreate as ConsultCreateService; use App\Services\Frontend\Consult\ConsultDelete as ConsultDeleteService; use App\Services\Frontend\Consult\ConsultInfo as ConsultInfoService; +use App\Services\Frontend\Consult\ConsultLike as ConsultLikeService; use App\Services\Frontend\Consult\ConsultUpdate as ConsultUpdateService; -use App\Services\Frontend\Consult\OpposeVote as ConsultOpposeVoteService; /** * @RoutePrefix("/consult") @@ -68,23 +67,11 @@ class ConsultController extends Controller } /** - * @Post("/{id:[0-9]+}/agree", name="web.consult.agree") + * @Post("/{id:[0-9]+}/like", name="web.consult.like") */ - public function agreeAction($id) + public function likeAction($id) { - $service = new ConsultAgreeVoteService(); - - $service->handle($id); - - return $this->jsonSuccess(); - } - - /** - * @Post("/{id:[0-9]+}/oppose", name="web.consult.oppose") - */ - public function opposeAction($id) - { - $service = new ConsultOpposeVoteService(); + $service = new ConsultLikeService(); $service->handle($id); diff --git a/app/Http/Web/Controllers/ReviewController.php b/app/Http/Web/Controllers/ReviewController.php index e706a30e..fdc63712 100644 --- a/app/Http/Web/Controllers/ReviewController.php +++ b/app/Http/Web/Controllers/ReviewController.php @@ -2,11 +2,10 @@ namespace App\Http\Web\Controllers; -use App\Services\Frontend\Review\AgreeVote as ReviewAgreeVoteService; -use App\Services\Frontend\Review\OpposeVote as ReviewOpposeVoteService; use App\Services\Frontend\Review\ReviewCreate as ReviewCreateService; use App\Services\Frontend\Review\ReviewDelete as ReviewDeleteService; use App\Services\Frontend\Review\ReviewInfo as ReviewInfoService; +use App\Services\Frontend\Review\ReviewLike as ReviewLikeService; use App\Services\Frontend\Review\ReviewUpdate as ReviewUpdateService; /** @@ -68,23 +67,11 @@ class ReviewController extends Controller } /** - * @Post("/{id:[0-9]+}/agree", name="web.review.agree") + * @Post("/{id:[0-9]+}/like", name="web.review.like") */ - public function agreeAction($id) + public function likeAction($id) { - $service = new ReviewAgreeVoteService(); - - $service->handle($id); - - return $this->jsonSuccess(); - } - - /** - * @Post("/{id:[0-9]+}/oppose", name="web.review.oppose") - */ - public function opposeAction($id) - { - $service = new ReviewOpposeVoteService(); + $service = new ReviewLikeService(); $service->handle($id); diff --git a/app/Http/Web/Views/chapter/menu.volt b/app/Http/Web/Views/chapter/menu.volt index b796696d..d9ed60b3 100644 --- a/app/Http/Web/Views/chapter/menu.volt +++ b/app/Http/Web/Views/chapter/menu.volt @@ -1,4 +1,4 @@ -