diff --git a/README.md b/README.md index ff312fb0..e33aaf68 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ Tips: 请用手机注册一个新账号,用户中心 -> 关注订阅,扫码 - 后台框架:[phalcon 3.4.5](https://phalcon.io) - 前端框架:[layui 2.9.3](https://layui.dev) -- 全文检索:[xunsearch 1.4.9](http://www.xunsearch.com) +- 全文检索:[xunsearch 1.4.17](http://www.xunsearch.com) - 基础依赖:[php7.3](https://php.net), [mysql5.7](https://mysql.com), [redis5.0](https://redis.io) ### 项目文档 diff --git a/app/Console/Migrations/V20230817240809.php b/app/Console/Migrations/V20230817240809.php deleted file mode 100644 index 0da4357b..00000000 --- a/app/Console/Migrations/V20230817240809.php +++ /dev/null @@ -1,58 +0,0 @@ -handleCourseResourceCount(); - } - - protected function handleCourseResourceCount() - { - $courses = CourseModel::find(); - - if ($courses->count() == 0) return; - - foreach ($courses as $course) { - if ($course->resource_count > 0) { - $this->recountCourseResources($course); - } - } - } - - protected function recountCourseResources(CourseModel $course) - { - $courseRepo = new CourseRepo(); - - $lessons = $courseRepo->findLessons($course->id); - - $chapterRepo = new ChapterRepo(); - - $resourceCount = 0; - - if ($lessons->count() > 0) { - foreach ($lessons as $lesson) { - if ($lesson->deleted == 0) { - $resourceCount += $chapterRepo->countResources($lesson->id); - } - } - } - - $course->resource_count = $resourceCount; - - $course->update(); - } - -} \ No newline at end of file diff --git a/app/Http/Admin/Services/Consult.php b/app/Http/Admin/Services/Consult.php index 9a44d10a..9cc67cf4 100644 --- a/app/Http/Admin/Services/Consult.php +++ b/app/Http/Admin/Services/Consult.php @@ -10,12 +10,10 @@ namespace App\Http\Admin\Services; use App\Builders\ConsultList as ConsultListBuilder; use App\Http\Admin\Services\Traits\AccountSearchTrait; use App\Library\Paginator\Query as PagerQuery; -use App\Models\Chapter as ChapterModel; use App\Models\Consult as ConsultModel; use App\Models\Course as CourseModel; use App\Models\Reason as ReasonModel; use App\Models\User as UserModel; -use App\Repos\Chapter as ChapterRepo; use App\Repos\Consult as ConsultRepo; use App\Repos\Course as CourseRepo; use App\Services\Logic\Consult\ConsultInfo as ConsultInfoService; @@ -104,6 +102,8 @@ class Consult extends Service { $consult = $this->findOrFail($id); + $course = $this->findCourse($consult->course_id); + $post = $this->request->getPost(); $validator = new ConsultValidator(); @@ -138,7 +138,7 @@ class Consult extends Service $this->handleReplyNotice($consult); } - $this->recountItemConsults($consult); + $this->recountCourseConsults($course); $this->eventsManager->fire('Consult:afterUpdate', $this, $consult); @@ -153,7 +153,9 @@ class Consult extends Service $consult->update(); - $this->recountItemConsults($consult); + $course = $this->findCourse($consult->course_id); + + $this->recountCourseConsults($course); $sender = $this->getLoginUser(); @@ -170,7 +172,9 @@ class Consult extends Service $consult->update(); - $this->recountItemConsults($consult); + $course = $this->findCourse($consult->course_id); + + $this->recountCourseConsults($course); $this->eventsManager->fire('Consult:afterRestore', $this, $consult); } @@ -202,7 +206,9 @@ class Consult extends Service $this->eventsManager->fire('Consult:afterReject', $this, $consult); } - $this->recountItemConsults($consult); + $course = $this->findCourse($consult->course_id); + + $this->recountCourseConsults($course); return $consult; } @@ -237,7 +243,9 @@ class Consult extends Service $this->handleConsultRejectedNotice($consult, $sender); } - $this->recountItemConsults($consult); + $course = $this->findCourse($consult->course_id); + + $this->recountCourseConsults($course); } } @@ -259,7 +267,10 @@ class Consult extends Service $consult->update(); $this->handleConsultDeletedNotice($consult, $sender); - $this->recountItemConsults($consult); + + $course = $this->findCourse($consult->course_id); + + $this->recountCourseConsults($course); } } @@ -277,13 +288,6 @@ class Consult extends Service return $courseRepo->findById($id); } - protected function findChapter($id) - { - $chapterRepo = new ChapterRepo(); - - return $chapterRepo->findById($id); - } - protected function handleReplyNotice(ConsultModel $consult) { $notice = new ConsultReplyNotice(); @@ -306,19 +310,6 @@ class Consult extends Service } - protected function recountItemConsults(ConsultModel $consult) - { - if ($consult->course_id > 0) { - $course = $this->findCourse($consult->course_id); - $this->recountCourseConsults($course); - } - - if ($consult->chapter_id > 0) { - $chapter = $this->findChapter($consult->chapter_id); - $this->recountChapterConsults($chapter); - } - } - protected function recountCourseConsults(CourseModel $course) { $courseRepo = new CourseRepo(); @@ -330,17 +321,6 @@ class Consult extends Service $course->update(); } - protected function recountChapterConsults(ChapterModel $chapter) - { - $chapterRepo = new ChapterRepo(); - - $consultCount = $chapterRepo->countConsults($chapter->id); - - $chapter->consult_count = $consultCount; - - $chapter->update(); - } - protected function handleConsults($pager) { if ($pager->total_items > 0) { diff --git a/app/Http/Home/Views/consult/add.volt b/app/Http/Home/Views/consult/add.volt index 6e1f5706..040225f7 100644 --- a/app/Http/Home/Views/consult/add.volt +++ b/app/Http/Home/Views/consult/add.volt @@ -20,7 +20,6 @@