diff --git a/app/Caches/CourseRecommendedList.php b/app/Caches/CourseRecommendedList.php deleted file mode 100644 index c810082f..00000000 --- a/app/Caches/CourseRecommendedList.php +++ /dev/null @@ -1,90 +0,0 @@ -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) { - - $userCount = $course->user_count; - - if ($course->fake_user_count > $course->user_count) { - $userCount = $course->fake_user_count; - } - - $result[] = [ - 'id' => $course->id, - 'title' => $course->title, - 'cover' => $course->cover, - 'model' => $course->model, - 'level' => $course->level, - 'rating' => round($course->rating, 1), - 'market_price' => (float)$course->market_price, - 'vip_price' => (float)$course->vip_price, - 'user_count' => $userCount, - 'lesson_count' => $course->lesson_count, - 'review_count' => $course->review_count, - 'favorite_count' => $course->favorite_count, - ]; - } - - return $result; - } - - /** - * @param int $limit - * @return ResultsetInterface|Resultset|CourseModel[] - */ - public function findCourses($limit = 5) - { - return CourseModel::query() - ->where('market_price > 0') - ->andWhere('published = 1') - ->andWhere('deleted = 0') - ->orderBy('RAND()') - ->limit($limit) - ->execute(); - } - -} diff --git a/app/Console/Tasks/CleanDemoDataTask.php b/app/Console/Tasks/CleanDemoDataTask.php index 24cba3df..fabd6a6d 100644 --- a/app/Console/Tasks/CleanDemoDataTask.php +++ b/app/Console/Tasks/CleanDemoDataTask.php @@ -8,12 +8,13 @@ namespace App\Console\Tasks; use App\Caches\CategoryList as CategoryListCache; +use App\Caches\CategoryAllList as CategoryAllListCache; use App\Caches\CategoryTreeList as CategoryTreeListCache; use App\Caches\IndexSlideList as IndexSlideListCache; use App\Models\Account as AccountModel; use App\Models\Category as CategoryModel; use App\Repos\User as UserRepo; -use App\Services\Utils\IndexCourseCache as IndexCourseCacheUtil; +use App\Services\Utils\IndexPageCache as IndexPageCacheUtil; class CleanDemoDataTask extends Task { @@ -81,17 +82,19 @@ class CleanDemoDataTask extends Task protected function cleanCache() { - $util = new IndexCourseCacheUtil(); + $util = new IndexPageCacheUtil(); $util->rebuild(); $slideListCache = new IndexSlideListCache(); $slideListCache->rebuild(); $categoryListCache = new CategoryListCache(); + $categoryAllListCache = new CategoryAllListCache(); $categoryTreeListCache = new CategoryTreeListCache(); foreach (CategoryModel::types() as $key => $value) { $categoryListCache->rebuild($key); + $categoryAllListCache->rebuild($key); $categoryTreeListCache->rebuild($key); } } @@ -114,7 +117,7 @@ class CleanDemoDataTask extends Task $user = $userRepo->findById(100015); - return $user ? true : false; + return (bool)$user; } } diff --git a/app/Http/Admin/Controllers/AnswerController.php b/app/Http/Admin/Controllers/AnswerController.php index b0ecffa5..d592c327 100644 --- a/app/Http/Admin/Controllers/AnswerController.php +++ b/app/Http/Admin/Controllers/AnswerController.php @@ -61,12 +61,15 @@ class AnswerController extends Controller { $answerService = new AnswerService(); + $publishTypes = $answerService->getPublishTypes(); + $answer = $answerService->getAnswer($id); $questionService = new QuestionService(); $question = $questionService->getQuestion($answer->question_id); + $this->view->setVar('publish_types', $publishTypes); $this->view->setVar('question', $question); $this->view->setVar('answer', $answer); } diff --git a/app/Http/Admin/Controllers/ConsultController.php b/app/Http/Admin/Controllers/ConsultController.php index 7f66dcf5..92a22c0d 100644 --- a/app/Http/Admin/Controllers/ConsultController.php +++ b/app/Http/Admin/Controllers/ConsultController.php @@ -57,8 +57,11 @@ class ConsultController extends Controller { $consultService = new ConsultService(); + $publishTypes = $consultService->getPublishTypes(); + $consult = $consultService->getConsult($id); + $this->view->setVar('publish_types', $publishTypes); $this->view->setVar('consult', $consult); } diff --git a/app/Http/Admin/Services/Question.php b/app/Http/Admin/Services/Question.php index 18bfc401..9e69c819 100644 --- a/app/Http/Admin/Services/Question.php +++ b/app/Http/Admin/Services/Question.php @@ -162,6 +162,10 @@ class Question extends Service $data['keywords'] = $validator->checkKeywords($post['keywords']); } + if (isset($post['summary'])) { + $data['summary'] = $validator->checkSummary($post['keywords']); + } + if (isset($post['anonymous'])) { $data['anonymous'] = $validator->checkAnonymousStatus($post['anonymous']); } diff --git a/app/Http/Admin/Views/answer/edit.volt b/app/Http/Admin/Views/answer/edit.volt index 9f5d83a5..3e354819 100644 --- a/app/Http/Admin/Views/answer/edit.volt +++ b/app/Http/Admin/Views/answer/edit.volt @@ -7,16 +7,27 @@