1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-25 12:09:09 +08:00

Merge branch 'koogua/v1.6.6' into demo

This commit is contained in:
xiaochong0302 2023-08-31 17:19:47 +08:00
commit 10ff834cc0
46 changed files with 674 additions and 455 deletions

View File

@ -1,4 +1,12 @@
### [v1.6.6](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.6)(2023-08-15)
### [v1.6.6](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.6)(2023-08-30)
- 还原意外删除的AnswerList.php文件
- 修正邮箱注册提交按钮不可用问题
- 去除删除远程课件逻辑
- 增加课程课件资料总览
- 优化cleanDemoDataTask脚本
- 优化tag表migration脚本
- 命名结构等常规优化
### [v1.6.5](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.5)(2023-07-15)

View File

@ -0,0 +1,58 @@
<?php
/**
* @copyright Copyright (c) 2023 深圳市酷瓜软件有限公司
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* @link https://www.koogua.com
*/
namespace App\Console\Migrations;
use App\Models\Course as CourseModel;
use App\Repos\Chapter as ChapterRepo;
use App\Repos\Course as CourseRepo;
class V20230817240809 extends Migration
{
public function run()
{
$this->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();
}
}

View File

@ -38,7 +38,7 @@ class CleanDemoDataTask extends Task
echo '------ start truncate tables ------' . PHP_EOL;
$excludeTables = [
'kg_area', 'kg_migration', 'kg_nav', 'kg_page',
'kg_area', 'kg_migration', 'kg_migration_task', 'kg_nav', 'kg_page',
'kg_reward', 'kg_role', 'kg_setting', 'kg_vip',
];

View File

@ -20,19 +20,6 @@ use Phalcon\Mvc\View;
class ChapterController extends Controller
{
/**
* @Get("/{id:[0-9]+}/resources", name="admin.chapter.resources")
*/
public function resourcesAction($id)
{
$chapterService = new ChapterService();
$resources = $chapterService->getResources($id);
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
$this->view->setVar('resources', $resources);
}
/**
* @Get("/{id:[0-9]+}/lessons", name="admin.chapter.lessons")
*/

View File

@ -9,6 +9,7 @@ namespace App\Http\Admin\Controllers;
use App\Http\Admin\Services\Course as CourseService;
use App\Models\Category as CategoryModel;
use Phalcon\Mvc\View;
/**
* @RoutePrefix("/admin/course")
@ -100,6 +101,7 @@ class CourseController extends Controller
{
$courseService = new CourseService();
$cos = $courseService->getSettings('cos');
$course = $courseService->getCourse($id);
$xmTeachers = $courseService->getXmTeachers($id);
$xmCategories = $courseService->getXmCategories($id);
@ -107,6 +109,7 @@ class CourseController extends Controller
$studyExpiryOptions = $courseService->getStudyExpiryOptions();
$refundExpiryOptions = $courseService->getRefundExpiryOptions();
$this->view->setVar('cos', $cos);
$this->view->setVar('course', $course);
$this->view->setVar('xm_teachers', $xmTeachers);
$this->view->setVar('xm_categories', $xmCategories);
@ -177,4 +180,17 @@ class CourseController extends Controller
$this->view->setVar('chapters', $chapters);
}
/**
* @Get("/{id:[0-9]+}/resources", name="admin.course.resources")
*/
public function resourcesAction($id)
{
$courseService = new CourseService();
$resources = $courseService->getResources($id);
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
$this->view->setVar('resources', $resources);
}
}

View File

@ -59,7 +59,7 @@ class PageController extends Controller
*/
public function editAction($id)
{
$pageService = new PageService;
$pageService = new PageService();
$page = $pageService->getPage($id);

View File

@ -9,6 +9,7 @@ namespace App\Http\Admin\Services;
use App\Builders\ArticleList as ArticleListBuilder;
use App\Builders\ReportList as ReportListBuilder;
use App\Caches\Article as ArticleCache;
use App\Library\Paginator\Query as PagerQuery;
use App\Library\Utils\Word as WordUtil;
use App\Models\Article as ArticleModel;
@ -26,6 +27,7 @@ use App\Services\Logic\Article\XmTagList as XmTagListService;
use App\Services\Logic\Notice\Internal\ArticleApproved as ArticleApprovedNotice;
use App\Services\Logic\Notice\Internal\ArticleRejected as ArticleRejectedNotice;
use App\Services\Logic\Point\History\ArticlePost as ArticlePostPointHistory;
use App\Services\Sync\ArticleIndex as ArticleIndexSync;
use App\Validators\Article as ArticleValidator;
class Article extends Service
@ -140,7 +142,8 @@ class Article extends Service
$article->create();
$this->saveDynamicAttrs($article);
$this->rebuildArticleCache($article);
$this->rebuildArticleIndex($article);
$this->recountUserArticles($user);
$this->eventsManager->fire('Article:afterCreate', $this, $article);
@ -205,10 +208,11 @@ class Article extends Service
$article->update($data);
$this->saveDynamicAttrs($article);
$owner = $this->findUser($article->owner_id);
$this->saveDynamicAttrs($article);
$this->rebuildArticleCache($article);
$this->rebuildArticleIndex($article);
$this->recountUserArticles($owner);
$this->eventsManager->fire('Article:afterUpdate', $this, $article);
@ -224,10 +228,11 @@ class Article extends Service
$article->update();
$this->saveDynamicAttrs($article);
$owner = $this->findUser($article->owner_id);
$this->saveDynamicAttrs($article);
$this->rebuildArticleCache($article);
$this->rebuildArticleIndex($article);
$this->recountUserArticles($owner);
$this->eventsManager->fire('Article:afterDelete', $this, $article);
@ -243,10 +248,11 @@ class Article extends Service
$article->update();
$this->saveDynamicAttrs($article);
$owner = $this->findUser($article->owner_id);
$this->saveDynamicAttrs($article);
$this->rebuildArticleCache($article);
$this->rebuildArticleIndex($article);
$this->recountUserArticles($owner);
$this->eventsManager->fire('Article:afterRestore', $this, $article);
@ -278,6 +284,8 @@ class Article extends Service
$owner = $this->findUser($article->owner_id);
$this->rebuildArticleCache($article);
$this->rebuildArticleIndex($article);
$this->recountUserArticles($owner);
$sender = $this->getLoginUser();
@ -331,6 +339,12 @@ class Article extends Service
}
$article->update();
$owner = $this->findUser($article->owner_id);
$this->rebuildArticleCache($article);
$this->rebuildArticleIndex($article);
$this->recountUserArticles($owner);
}
protected function findOrFail($id)
@ -347,6 +361,54 @@ class Article extends Service
return $userRepo->findById($id);
}
protected function rebuildArticleCache(ArticleModel $article)
{
$cache = new ArticleCache();
$cache->rebuild($article->id);
}
protected function rebuildArticleIndex(ArticleModel $article)
{
$sync = new ArticleIndexSync();
$sync->addItem($article->id);
}
protected function recountUserArticles(UserModel $user)
{
$userRepo = new UserRepo();
$articleCount = $userRepo->countArticles($user->id);
$user->article_count = $articleCount;
$user->update();
}
protected function handleArticlePostPoint(ArticleModel $article)
{
if ($article->published != ArticleModel::PUBLISH_APPROVED) return;
$service = new ArticlePostPointHistory();
$service->handle($article);
}
protected function handleArticleApprovedNotice(ArticleModel $article, UserModel $sender)
{
$notice = new ArticleApprovedNotice();
$notice->handle($article, $sender);
}
protected function handleArticleRejectedNotice(ArticleModel $article, UserModel $sender, $reason)
{
$notice = new ArticleRejectedNotice();
$notice->handle($article, $sender, $reason);
}
protected function handleArticles($pager)
{
if ($pager->total_items > 0) {
@ -383,38 +445,4 @@ class Article extends Service
return $pager;
}
protected function recountUserArticles(UserModel $user)
{
$userRepo = new UserRepo();
$articleCount = $userRepo->countArticles($user->id);
$user->article_count = $articleCount;
$user->update();
}
protected function handleArticlePostPoint(ArticleModel $article)
{
if ($article->published != ArticleModel::PUBLISH_APPROVED) return;
$service = new ArticlePostPointHistory();
$service->handle($article);
}
protected function handleArticleApprovedNotice(ArticleModel $article, UserModel $sender)
{
$notice = new ArticleApprovedNotice();
$notice->handle($article, $sender);
}
protected function handleArticleRejectedNotice(ArticleModel $article, UserModel $sender, $reason)
{
$notice = new ArticleRejectedNotice();
$notice->handle($article, $sender, $reason);
}
}

View File

@ -7,37 +7,18 @@
namespace App\Http\Admin\Services;
use App\Builders\ResourceList as ResourceListBuilder;
use App\Caches\Chapter as ChapterCache;
use App\Caches\CourseChapterList as CatalogCache;
use App\Models\Chapter as ChapterModel;
use App\Models\Course as CourseModel;
use App\Repos\Chapter as ChapterRepo;
use App\Repos\Course as CourseRepo;
use App\Repos\Resource as ResourceRepo;
use App\Services\CourseStat as CourseStatService;
use App\Validators\Chapter as ChapterValidator;
class Chapter extends Service
{
public function getResources($id)
{
$resourceRepo = new ResourceRepo();
$resources = $resourceRepo->findByChapterId($id);
if ($resources->count() == 0) return [];
$builder = new ResourceListBuilder();
$items = $resources->toArray();
$items = $builder->handleUploads($items);
return $builder->objects($items);
}
public function getLessons($parentId)
{
$deleted = $this->request->getQuery('deleted', 'int', 0);
@ -103,8 +84,9 @@ class Chapter extends Service
$this->db->commit();
$this->updateChapterStats($chapter);
$this->updateCourseStat($chapter);
$this->rebuildCatalogCache($chapter);
$this->rebuildChapterCache($chapter);
return $chapter;
@ -160,10 +142,9 @@ class Chapter extends Service
$chapter->update($data);
$this->updateChapterStats($chapter);
$this->updateCourseStat($chapter);
$this->rebuildCatalogCache($chapter);
$this->rebuildChapterCache($chapter);
return $chapter;
}
@ -181,10 +162,9 @@ class Chapter extends Service
$chapter->update();
$this->updateChapterStats($chapter);
$this->updateCourseStat($chapter);
$this->rebuildCatalogCache($chapter);
$this->rebuildChapterCache($chapter);
return $chapter;
}
@ -198,14 +178,20 @@ class Chapter extends Service
$chapter->update();
$this->updateChapterStats($chapter);
$this->updateCourseStat($chapter);
$this->rebuildCatalogCache($chapter);
$this->rebuildChapterCache($chapter);
return $chapter;
}
protected function findOrFail($id)
{
$validator = new ChapterValidator();
return $validator->checkChapter($id);
}
protected function updateChapterStats(ChapterModel $chapter)
{
$chapterRepo = new ChapterRepo();
@ -254,11 +240,4 @@ class Chapter extends Service
$cache->rebuild($chapter->course_id);
}
protected function findOrFail($id)
{
$validator = new ChapterValidator();
return $validator->checkChapter($id);
}
}

View File

@ -8,6 +8,8 @@
namespace App\Http\Admin\Services;
use App\Builders\CourseList as CourseListBuilder;
use App\Builders\ResourceList as ResourceListBuilder;
use App\Caches\Course as CourseCache;
use App\Caches\CourseCategoryList as CourseCategoryListCache;
use App\Caches\CourseRelatedList as CourseRelatedListCache;
use App\Caches\CourseTeacherList as CourseTeacherListCache;
@ -24,6 +26,7 @@ use App\Repos\CourseCategory as CourseCategoryRepo;
use App\Repos\CourseRelated as CourseRelatedRepo;
use App\Repos\CourseUser as CourseUserRepo;
use App\Repos\User as UserRepo;
use App\Services\Sync\CourseIndex as CourseIndexSync;
use App\Validators\Course as CourseValidator;
use App\Validators\CourseOffline as CourseOfflineValidator;
@ -86,6 +89,9 @@ class Course extends Service
$this->db->commit();
$this->rebuildCourseCache($course);
$this->rebuildCourseIndex($course);
return $course;
} catch (\Exception $e) {
@ -208,6 +214,9 @@ class Course extends Service
$course->update($data);
$this->rebuildCourseCache($course);
$this->rebuildCourseIndex($course);
return $course;
}
@ -219,6 +228,9 @@ class Course extends Service
$course->update();
$this->rebuildCourseCache($course);
$this->rebuildCourseIndex($course);
return $course;
}
@ -230,6 +242,9 @@ class Course extends Service
$course->update();
$this->rebuildCourseCache($course);
$this->rebuildCourseIndex($course);
return $course;
}
@ -390,6 +405,23 @@ class Course extends Service
]);
}
public function getResources($id)
{
$courseRepo = new CourseRepo();
$resources = $courseRepo->findResources($id);
if ($resources->count() == 0) return [];
$builder = new ResourceListBuilder();
$items = $resources->toArray();
$items = $builder->handleUploads($items);
return $builder->objects($items);
}
protected function findOrFail($id)
{
$validator = new CourseValidator();
@ -562,6 +594,20 @@ class Course extends Service
$cache->rebuild($course->id);
}
protected function rebuildCourseCache(CourseModel $course)
{
$cache = new CourseCache();
$cache->rebuild($course->id);
}
protected function rebuildCourseIndex(CourseModel $course)
{
$sync = new CourseIndexSync();
$sync->addItem($course->id);
}
protected function handleCourses($pager)
{
if ($pager->total_items > 0) {

View File

@ -7,6 +7,7 @@
namespace App\Http\Admin\Services;
use App\Caches\FlashSale as FlashSaleCache;
use App\Library\Paginator\Query as PagerQuery;
use App\Models\Course as CourseModel;
use App\Models\FlashSale as FlashSaleModel;
@ -157,6 +158,8 @@ class FlashSale extends Service
break;
}
$this->rebuildFlashSaleCache($sale);
return $sale;
}
@ -198,7 +201,8 @@ class FlashSale extends Service
$sale->update($data);
$this->initFlashSaleQueue($sale->id);
$this->initFlashSaleQueue($sale);
$this->rebuildFlashSaleCache($sale);
return $sale;
}
@ -211,6 +215,8 @@ class FlashSale extends Service
$sale->update();
$this->rebuildFlashSaleCache($sale);
return $sale;
}
@ -222,9 +228,32 @@ class FlashSale extends Service
$sale->update();
$this->rebuildFlashSaleCache($sale);
return $sale;
}
protected function findOrFail($id)
{
$validator = new FlashSaleValidator();
return $validator->checkFlashSale($id);
}
protected function initFlashSaleQueue(FlashSaleModel $sale)
{
$queue = new FlashSaleQueue();
$queue->init($sale->id);
}
protected function rebuildFlashSaleCache(FlashSaleModel $sale)
{
$cache = new FlashSaleCache();
$cache->rebuild($sale->id);
}
protected function createCourseFlashSale($post)
{
$validator = new FlashSaleValidator();
@ -348,18 +377,4 @@ class FlashSale extends Service
return $result;
}
protected function initFlashSaleQueue($id)
{
$queue = new FlashSaleQueue();
$queue->init($id);
}
protected function findOrFail($id)
{
$validator = new FlashSaleValidator();
return $validator->checkFlashSale($id);
}
}

View File

@ -8,6 +8,7 @@
namespace App\Http\Admin\Services;
use App\Builders\HelpList as HelpListBuilder;
use App\Caches\Help as HelpCache;
use App\Caches\HelpList as HelpListCache;
use App\Models\Category as CategoryModel;
use App\Models\Help as HelpModel;
@ -75,6 +76,7 @@ class Help extends Service
$help->create($data);
$this->rebuildHelpCache($help);
$this->rebuildHelpListCache();
return $help;
@ -117,6 +119,7 @@ class Help extends Service
$help->update($data);
$this->rebuildHelpCache($help);
$this->rebuildHelpListCache();
return $help;
@ -130,6 +133,7 @@ class Help extends Service
$help->update();
$this->rebuildHelpCache($help);
$this->rebuildHelpListCache();
return $help;
@ -143,18 +147,12 @@ class Help extends Service
$help->update();
$this->rebuildHelpCache($help);
$this->rebuildHelpListCache();
return $help;
}
protected function rebuildHelpListCache()
{
$cache = new HelpListCache();
$cache->rebuild();
}
protected function findOrFail($id)
{
$validator = new HelpValidator();
@ -162,6 +160,20 @@ class Help extends Service
return $validator->checkHelp($id);
}
protected function rebuildHelpCache(HelpModel $help)
{
$cache = new HelpCache();
$cache->rebuild($help->id);
}
protected function rebuildHelpListCache()
{
$cache = new HelpListCache();
$cache->rebuild();
}
/**
* @param Resultset $helps
* @return array|object

View File

@ -186,6 +186,13 @@ class Package extends Service
return $package;
}
protected function findOrFail($id)
{
$validator = new PackageValidator();
return $validator->checkPackage($id);
}
protected function saveCourses(PackageModel $package, $courseIds)
{
$packageRepo = new PackageRepo();
@ -297,11 +304,4 @@ class Package extends Service
$course->update();
}
protected function findOrFail($id)
{
$validator = new PackageValidator();
return $validator->checkPackage($id);
}
}

View File

@ -7,6 +7,7 @@
namespace App\Http\Admin\Services;
use App\Caches\Page as PageCache;
use App\Library\Paginator\Query as PagerQuery;
use App\Models\Page as PageModel;
use App\Repos\Page as PageRepo;
@ -52,6 +53,8 @@ class Page extends Service
$page->create($data);
$this->rebuildPageCache($page);
return $page;
}
@ -93,6 +96,8 @@ class Page extends Service
$page->update($data);
$this->rebuildPageCache($page);
return $page;
}
@ -104,6 +109,8 @@ class Page extends Service
$page->update();
$this->rebuildPageCache($page);
return $page;
}
@ -115,6 +122,8 @@ class Page extends Service
$page->update();
$this->rebuildPageCache($page);
return $page;
}
@ -125,4 +134,11 @@ class Page extends Service
return $validator->checkPage($id);
}
protected function rebuildPageCache(PageModel $page)
{
$cache = new PageCache();
$cache->rebuild($page->id);
}
}

View File

@ -7,6 +7,7 @@
namespace App\Http\Admin\Services;
use App\Caches\PointGift as PointGiftCache;
use App\Library\Paginator\Query as PagerQuery;
use App\Models\PointGift as PointGiftModel;
use App\Repos\Course as CourseRepo;
@ -115,6 +116,8 @@ class PointGift extends Service
break;
}
$this->rebuildPointGiftCache($gift);
return $gift;
}
@ -162,6 +165,8 @@ class PointGift extends Service
$gift->update($data);
$this->rebuildPointGiftCache($gift);
return $gift;
}
@ -173,6 +178,8 @@ class PointGift extends Service
$gift->update();
$this->rebuildPointGiftCache($gift);
return $gift;
}
@ -184,9 +191,25 @@ class PointGift extends Service
$gift->update();
$this->rebuildPointGiftCache($gift);
return $gift;
}
protected function findOrFail($id)
{
$validator = new PointGiftValidator();
return $validator->checkPointGift($id);
}
protected function rebuildPointGiftCache(PointGiftModel $gift)
{
$cache = new PointGiftCache();
$cache->rebuild($gift->id);
}
protected function createCoursePointGift($post)
{
$validator = new PointGiftValidator();
@ -257,11 +280,4 @@ class PointGift extends Service
return $gift;
}
protected function findOrFail($id)
{
$validator = new PointGiftValidator();
return $validator->checkPointGift($id);
}
}

View File

@ -9,6 +9,7 @@ namespace App\Http\Admin\Services;
use App\Builders\QuestionList as QuestionListBuilder;
use App\Builders\ReportList as ReportListBuilder;
use App\Caches\Question as QuestionCache;
use App\Library\Paginator\Query as PagerQuery;
use App\Models\Category as CategoryModel;
use App\Models\Question as QuestionModel;
@ -25,6 +26,7 @@ use App\Services\Logic\Point\History\QuestionPost as QuestionPostPointHistory;
use App\Services\Logic\Question\QuestionDataTrait;
use App\Services\Logic\Question\QuestionInfo as QuestionInfoService;
use App\Services\Logic\Question\XmTagList as XmTagListService;
use App\Services\Sync\QuestionIndex as QuestionIndexSync;
use App\Validators\Question as QuestionValidator;
class Question extends Service
@ -134,7 +136,8 @@ class Question extends Service
$question->create();
$this->saveDynamicAttrs($question);
$this->rebuildQuestionCache($question);
$this->rebuildQuestionIndex($question);
$this->recountUserQuestions($user);
$this->eventsManager->fire('Question:afterCreate', $this, $question);
@ -187,10 +190,11 @@ class Question extends Service
$question->update($data);
$this->saveDynamicAttrs($question);
$owner = $this->findUser($question->owner_id);
$this->saveDynamicAttrs($question);
$this->rebuildQuestionCache($question);
$this->rebuildQuestionIndex($question);
$this->recountUserQuestions($owner);
$this->eventsManager->fire('Question:afterUpdate', $this, $question);
@ -206,10 +210,11 @@ class Question extends Service
$question->update();
$this->saveDynamicAttrs($question);
$owner = $this->findUser($question->owner_id);
$this->saveDynamicAttrs($question);
$this->rebuildQuestionCache($question);
$this->rebuildQuestionIndex($question);
$this->recountUserQuestions($owner);
$this->eventsManager->fire('Question:afterDelete', $this, $question);
@ -227,6 +232,8 @@ class Question extends Service
$owner = $this->findUser($question->owner_id);
$this->rebuildQuestionCache($question);
$this->rebuildQuestionIndex($question);
$this->recountUserQuestions($owner);
$this->eventsManager->fire('Question:afterRestore', $this, $question);
@ -254,6 +261,8 @@ class Question extends Service
$owner = $this->findUser($question->owner_id);
$this->rebuildQuestionCache($question);
$this->rebuildQuestionIndex($question);
$this->recountUserQuestions($owner);
$sender = $this->getLoginUser();
@ -307,6 +316,12 @@ class Question extends Service
}
$question->update();
$owner = $this->findUser($question->owner_id);
$this->rebuildQuestionCache($question);
$this->rebuildQuestionIndex($question);
$this->recountUserQuestions($owner);
}
protected function findOrFail($id)
@ -323,6 +338,54 @@ class Question extends Service
return $userRepo->findById($id);
}
protected function rebuildQuestionCache(QuestionModel $question)
{
$cache = new QuestionCache();
$cache->rebuild($question->id);
}
protected function rebuildQuestionIndex(QuestionModel $question)
{
$sync = new QuestionIndexSync();
$sync->addItem($question->id);
}
protected function recountUserQuestions(UserModel $user)
{
$userRepo = new UserRepo();
$questionCount = $userRepo->countQuestions($user->id);
$user->question_count = $questionCount;
$user->update();
}
protected function handleQuestionPostPoint(QuestionModel $question)
{
if ($question->published != QuestionModel::PUBLISH_APPROVED) return;
$service = new QuestionPostPointHistory();
$service->handle($question);
}
protected function handleQuestionApprovedNotice(QuestionModel $question, UserModel $sender)
{
$notice = new QuestionApprovedNotice();
$notice->handle($question, $sender);
}
protected function handleQuestionRejectedNotice(QuestionModel $question, UserModel $sender, $reason)
{
$notice = new QuestionRejectedNotice();
$notice->handle($question, $sender, $reason);
}
protected function handleQuestions($pager)
{
if ($pager->total_items > 0) {
@ -359,38 +422,4 @@ class Question extends Service
return $pager;
}
protected function recountUserQuestions(UserModel $user)
{
$userRepo = new UserRepo();
$questionCount = $userRepo->countQuestions($user->id);
$user->question_count = $questionCount;
$user->update();
}
protected function handleQuestionPostPoint(QuestionModel $question)
{
if ($question->published != QuestionModel::PUBLISH_APPROVED) return;
$service = new QuestionPostPointHistory();
$service->handle($question);
}
protected function handleQuestionApprovedNotice(QuestionModel $question, UserModel $sender)
{
$notice = new QuestionApprovedNotice();
$notice->handle($question, $sender);
}
protected function handleQuestionRejectedNotice(QuestionModel $question, UserModel $sender, $reason)
{
$notice = new QuestionRejectedNotice();
$notice->handle($question, $sender, $reason);
}
}

View File

@ -7,15 +7,10 @@
namespace App\Http\Admin\Services;
use App\Models\Chapter as ChapterModel;
use App\Models\Course as CourseModel;
use App\Models\Resource as ResourceModel;
use App\Models\Upload as UploadModel;
use App\Repos\Chapter as ChapterRepo;
use App\Repos\Course as CourseRepo;
use App\Repos\Upload as UploadRepo;
use App\Services\Storage as StorageService;
use App\Validators\Chapter as ChapterValidator;
use App\Validators\Resource as ResourceValidator;
use App\Validators\Upload as UploadValidator;
@ -26,41 +21,28 @@ class Resource extends Service
{
$post = $this->request->getPost();
$validator = new ChapterValidator();
$validator = new ResourceValidator();
$chapter = $validator->checkChapter($post['chapter_id']);
$course = $validator->checkCourse($chapter->course_id);
$course = $validator->checkCourse($post['course_id']);
$uploadRepo = new UploadRepo();
$upload = new UploadModel();
$upload = $uploadRepo->findByMd5($post['upload']['md5']);
$upload->type = UploadModel::TYPE_RESOURCE;
$upload->name = $post['upload']['name'];
$upload->size = $post['upload']['size'];
$upload->path = $post['upload']['path'];
$upload->md5 = $post['upload']['md5'];
$upload->mime = $post['upload']['mime'];
/**
* 腾讯COS存储可能不会返回文件md5值
*/
if (!$upload || empty($post['upload']['md5'])) {
$upload = new UploadModel();
$upload->type = UploadModel::TYPE_RESOURCE;
$upload->name = $post['upload']['name'];
$upload->size = $post['upload']['size'];
$upload->path = $post['upload']['path'];
$upload->md5 = $post['upload']['md5'];
$upload->mime = $post['upload']['mime'];
$upload->create();
}
$upload->create();
$resource = new ResourceModel();
$resource->course_id = $course->id;
$resource->chapter_id = $chapter->id;
$resource->upload_id = $upload->id;
$resource->create();
$this->recountChapterResources($chapter);
$this->recountCourseResources($course);
return $upload;
@ -94,19 +76,9 @@ class Resource extends Service
$validator = new ResourceValidator();
$course = $validator->checkCourse($resource->course_id);
$chapter = $validator->checkChapter($resource->chapter_id);
$validator = new UploadValidator();
$upload = $validator->checkUpload($resource->upload_id);
$storageService = new StorageService();
$storageService->deleteObject($upload->path);
$resource->delete();
$this->recountChapterResources($chapter);
$this->recountCourseResources($course);
}
@ -117,34 +89,13 @@ class Resource extends Service
return $validator->checkResource($id);
}
protected function recountChapterResources(ChapterModel $chapter)
{
$chapterRepo = new ChapterRepo();
$chapter->resource_count = $chapterRepo->countResources($chapter->id);
$chapter->update();
$parent = $chapterRepo->findById($chapter->parent_id);
$lessons = $chapterRepo->findLessons($parent->id);
$resourceCount = 0;
foreach ($lessons as $lesson) {
$resourceCount += $chapterRepo->countResources($lesson->id);
}
$parent->resource_count = $resourceCount;
$parent->update();
}
protected function recountCourseResources(CourseModel $course)
{
$courseRepo = new CourseRepo();
$course->resource_count = $courseRepo->countResources($course->id);
$resourceCount = $courseRepo->countResources($course->id);
$course->resource_count = $resourceCount;
$course->update();
}

View File

@ -105,7 +105,7 @@ class Slide extends Service
$slide = $this->createLinkSlide($post);
}
$this->rebuildSlideCache();
$this->rebuildIndexSlideListCache();
return $slide;
}
@ -138,7 +138,7 @@ class Slide extends Service
$slide->update($data);
$this->rebuildSlideCache();
$this->rebuildIndexSlideListCache();
return $slide;
}
@ -151,7 +151,7 @@ class Slide extends Service
$slide->update();
$this->rebuildSlideCache();
$this->rebuildIndexSlideListCache();
return $slide;
}
@ -164,7 +164,7 @@ class Slide extends Service
$slide->update();
$this->rebuildSlideCache();
$this->rebuildIndexSlideListCache();
return $slide;
}
@ -236,7 +236,7 @@ class Slide extends Service
return $slide;
}
protected function rebuildSlideCache()
protected function rebuildIndexSlideListCache()
{
$cache = new IndexSlideListCache();

View File

@ -162,6 +162,13 @@ class Topic extends Service
return $topic;
}
protected function findOrFail($id)
{
$validator = new TopicValidator();
return $validator->checkTopic($id);
}
protected function saveCourses(TopicModel $topic, $courseIds)
{
$topicRepo = new TopicRepo();
@ -220,11 +227,4 @@ class Topic extends Service
$cache->rebuild($topic->id);
}
protected function findOrFail($id)
{
$validator = new TopicValidator();
return $validator->checkTopic($id);
}
}

View File

@ -11,6 +11,7 @@ use App\Builders\UserList as UserListBuilder;
use App\Caches\User as UserCache;
use App\Library\Paginator\Query as PaginateQuery;
use App\Library\Utils\Password as PasswordUtil;
use App\Library\Validators\Common as CommonValidator;
use App\Models\Account as AccountModel;
use App\Models\User as UserModel;
use App\Repos\Account as AccountRepo;
@ -61,6 +62,24 @@ class User extends Service
$pageQuery = new PaginateQuery();
$params = $pageQuery->getParams();
$accountRepo = new AccountRepo();
/**
* 兼容用户编号|手机号码|邮箱地址查询
*/
if (!empty($params['id'])) {
if (CommonValidator::phone($params['id'])) {
$account = $accountRepo->findByPhone($params['id']);
$params['id'] = $account ? $account->id : -1000;
} elseif (CommonValidator::email($params['id'])) {
$account = $accountRepo->findByEmail($params['id']);
$params['id'] = $account ? $account->id : -1000;
}
}
$params['deleted'] = $params['deleted'] ?? 0;
$sort = $pageQuery->getSort();
$page = $pageQuery->getPage();
$limit = $pageQuery->getLimit();
@ -132,6 +151,8 @@ class User extends Service
$this->updateAdminUserCount($adminRole);
}
$this->rebuildUserCache($user);
} catch (\Exception $e) {
$this->db->rollback();
@ -223,6 +244,8 @@ class User extends Service
$this->updateAdminUserCount($user->admin_role);
}
$this->rebuildUserCache($user);
return $user;
}

View File

@ -22,7 +22,6 @@
<ul class="layui-tab-title kg-tab-title">
<li class="layui-this">基本信息</li>
<li>{{ content_title(course.model) }}</li>
<li>课件资料</li>
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
@ -39,9 +38,6 @@
{{ partial('chapter/edit_lesson_offline') }}
{% endif %}
</div>
<div class="layui-tab-item">
{{ partial('chapter/edit_resource') }}
</div>
</div>
</div>
@ -65,9 +61,6 @@
{% endif %}
{{ js_include('lib/cos-js-sdk-v5.min.js') }}
{{ js_include('admin/js/chapter.resource.js') }}
{% endblock %}
{% block inline_js %}

View File

@ -29,7 +29,6 @@
<col>
<col>
<col>
<col>
<col width="10%">
</colgroup>
<thead>
@ -37,7 +36,6 @@
<th>编号</th>
<th>名称</th>
<th>课时</th>
<th>课件</th>
<th>学员</th>
<th>点赞</th>
<th>评论</th>
@ -59,7 +57,6 @@
<span class="layui-badge layui-bg-green">章</span>
</td>
<td>{{ item.lesson_count }}</td>
<td>{{ item.resource_count }}</td>
<td>{{ item.user_count }}</td>
<td>{{ item.like_count }}</td>
<td>{{ item.comment_count }}</td>

View File

@ -14,6 +14,7 @@
{% endif %}
<li>课程介绍</li>
<li>营销设置</li>
<li>课件资料</li>
<li>相关课程</li>
</ul>
<div class="layui-tab-content">
@ -31,6 +32,9 @@
<div class="layui-tab-item">
{{ partial('course/edit_sale') }}
</div>
<div class="layui-tab-item">
{{ partial('course/edit_resource') }}
</div>
<div class="layui-tab-item">
{{ partial('course/edit_related') }}
</div>
@ -42,10 +46,12 @@
{% block include_js %}
{{ js_include('lib/xm-select.js') }}
{{ js_include('lib/cos-js-sdk-v5.min.js') }}
{{ js_include('lib/kindeditor/kindeditor.min.js') }}
{{ js_include('lib/kindeditor/lang/zh-CN.js') }}
{{ js_include('admin/js/content.editor.js') }}
{{ js_include('admin/js/cover.upload.js') }}
{{ js_include('admin/js/course.resource.js') }}
{% endblock %}

View File

@ -1,4 +1,4 @@
{% set res_list_url = url({'for':'admin.chapter.resources','id':chapter.id}) %}
{% set res_list_url = url({'for':'admin.course.resources','id':course.id}) %}
<fieldset class="layui-elem-field layui-field-title">
<legend>资料列表</legend>
@ -17,7 +17,7 @@
<input class="layui-hide" type="file" name="res_file" accept="*/*">
</div>
</div>
<div class="layui-form-item layui-hide" id="res-progress-block">
<div class="layui-form-item layui-hide" id="res-upload-progress-block">
<label class="layui-form-label">上传进度</label>
<div class="layui-input-block">
<div class="layui-progress layui-progress-big" lay-showpercent="yes" lay-filter="res-upload-progress" style="top:10px;">
@ -26,7 +26,7 @@
</div>
</div>
<div class="layui-hide">
<input type="hidden" name="chapter_id" value="{{ chapter.id }}">
<input type="hidden" name="course_id" value="{{ course.id }}">
<input type="hidden" name="bucket" value="{{ cos.bucket }}">
<input type="hidden" name="region" value="{{ cos.region }}">
</div>

View File

@ -1,4 +1,5 @@
{% if resources %}
{% if resources|length > 0 %}
<br>
<table class="kg-table layui-table">
<tr>
<th>名称</th>
@ -16,7 +17,7 @@
<td>{{ item.upload.size|human_size }}</td>
<td>{{ date('Y-m-d H:i:s',item.create_time) }}</td>
<td>
<a class="layui-btn layui-btn-sm layui-bg-red res-btn-delete" href="javascript:" data-url="{{ delete_url }}">删除</a>
<a class="layui-btn layui-btn-sm layui-btn-danger res-btn-delete" href="javascript:" data-url="{{ delete_url }}">删除</a>
<a class="layui-btn layui-btn-sm" href="{{ item.upload.url }}" target="_blank">下载</a>
</td>
</tr>

View File

@ -2,46 +2,26 @@
{% block content %}
<form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.topic.update','id':topic.id}) }}">
<fieldset class="layui-elem-field layui-field-title">
<legend>编辑专题</legend>
</fieldset>
<div class="layui-form-item">
<label class="layui-form-label">标题</label>
<div class="layui-input-block">
<input class="layui-input" type="text" name="title" value="{{ topic.title }}" lay-verify="required">
{% set action_url = url({'for':'admin.topic.update','id':topic.id}) %}
<fieldset class="layui-elem-field layui-field-title">
<legend>编辑专题</legend>
</fieldset>
<div class="layui-tab layui-tab-brief">
<ul class="layui-tab-title kg-tab-title">
<li class="layui-this">基本信息</li>
<li>相关课程</li>
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
{{ partial('topic/edit_basic') }}
</div>
<div class="layui-tab-item">
{{ partial('topic/edit_course') }}
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">封面</label>
<div class="layui-input-inline">
<img id="img-cover" class="kg-cover" src="{{ topic.cover }}">
<input type="hidden" name="cover" value="{{ topic.cover }}">
</div>
<div class="layui-input-inline" style="padding-top:35px;">
<button id="change-cover" class="layui-btn layui-btn-sm" type="button">更换</button>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">简介</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="summary">{{ topic.summary }}</textarea>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">相关课程</label>
<div class="layui-input-block">
<div id="xm-course-ids"></div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label"></label>
<div class="layui-input-block">
<button class="kg-submit layui-btn" lay-submit="true" lay-filter="go">提交</button>
<button type="button" class="kg-back layui-btn layui-btn-primary">返回</button>
</div>
</div>
</form>
</div>
{% endblock %}

View File

@ -0,0 +1,38 @@
<form class="layui-form kg-form" method="POST" action="{{ action_url }}">
<div class="layui-form-item">
<label class="layui-form-label">标题</label>
<div class="layui-input-block">
<input class="layui-input" type="text" name="title" value="{{ topic.title }}" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">封面</label>
<div class="layui-input-inline">
<img id="img-cover" class="kg-cover" src="{{ topic.cover }}">
<input type="hidden" name="cover" value="{{ topic.cover }}">
</div>
<div class="layui-input-inline" style="padding-top:35px;">
<button id="change-cover" class="layui-btn layui-btn-sm" type="button">更换</button>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">简介</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="summary">{{ topic.summary }}</textarea>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">发布</label>
<div class="layui-input-block">
<input type="radio" name="published" value="1" title="是" {% if topic.published == 1 %}checked="checked"{% endif %}>
<input type="radio" name="published" value="0" title="否" {% if topic.published == 0 %}checked="checked"{% endif %}>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label"></label>
<div class="layui-input-block">
<button class="kg-submit layui-btn" lay-submit="true" lay-filter="go">提交</button>
<button type="button" class="kg-back layui-btn layui-btn-primary">返回</button>
</div>
</div>
</form>

View File

@ -0,0 +1,15 @@
<form class="layui-form kg-form" method="POST" action="{{ action_url }}">
<div class="layui-form-item">
<label class="layui-form-label">相关课程</label>
<div class="layui-input-block">
<div id="xm-course-ids"></div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label"></label>
<div class="layui-input-block">
<button class="kg-submit layui-btn" lay-submit="true" lay-filter="go">提交</button>
<button type="button" class="kg-back layui-btn layui-btn-primary">返回</button>
</div>
</div>
</form>

View File

@ -7,15 +7,15 @@
<legend>搜索用户</legend>
</fieldset>
<div class="layui-form-item">
<label class="layui-form-label">号</label>
<label class="layui-form-label">用户帐号</label>
<div class="layui-input-block">
<input class="layui-input" type="text" name="id" placeholder="编号精确匹配">
<input class="layui-input" type="text" name="id" placeholder="用户编号 / 手机号码 / 邮箱地址 精确匹配">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">昵称</label>
<label class="layui-form-label">用户昵称</label>
<div class="layui-input-block">
<input class="layui-input" type="text" name="name" placeholder="昵称模糊匹配">
<input class="layui-input" type="text" name="name" placeholder="用户昵称模糊匹配">
</div>
</div>
<div class="layui-form-item">

View File

@ -13,7 +13,6 @@ use App\Models\Course as CourseModel;
use App\Services\Logic\Chapter\ChapterInfo as ChapterInfoService;
use App\Services\Logic\Chapter\ChapterLike as ChapterLikeService;
use App\Services\Logic\Chapter\Learning as ChapterLearningService;
use App\Services\Logic\Chapter\ResourceList as ChapterResourceListService;
use App\Services\Logic\Course\BasicInfo as CourseInfoService;
use App\Services\Logic\Course\ChapterList as CourseChapterListService;
@ -23,18 +22,6 @@ use App\Services\Logic\Course\ChapterList as CourseChapterListService;
class ChapterController extends Controller
{
/**
* @Get("/{id:[0-9]+}/resources", name="home.chapter.resources")
*/
public function resourcesAction($id)
{
$service = new ChapterResourceListService();
$items = $service->handle($id);
$this->view->setVar('items', $items);
}
/**
* @Get("/{id:[0-9]+}", name="home.chapter.show")
*/

View File

@ -17,6 +17,7 @@ use App\Services\Logic\Course\CourseList as CourseListService;
use App\Services\Logic\Course\PackageList as CoursePackageListService;
use App\Services\Logic\Course\RecommendedList as CourseRecommendedListService;
use App\Services\Logic\Course\RelatedList as CourseRelatedListService;
use App\Services\Logic\Course\ResourceList as CourseResourceListService;
use App\Services\Logic\Course\ReviewList as CourseReviewListService;
use App\Services\Logic\Course\TopicList as CourseTopicListService;
use App\Services\Logic\Reward\OptionList as RewardOptionList;
@ -160,6 +161,19 @@ class CourseController extends Controller
$this->view->setVar('pager', $pager);
}
/**
* @Get("/{id:[0-9]+}/resources", name="home.course.resources")
*/
public function resourcesAction($id)
{
$service = new CourseResourceListService();
$items = $service->handle($id);
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
$this->view->setVar('items', $items);
}
/**
* @Get("/{id:[0-9]+}/recommended", name="home.course.recommended")
*/

View File

@ -278,35 +278,6 @@ class UserConsoleController extends Controller
$this->view->setVar('pager', $pager);
}
/**
* @Get("/friends", name="home.uc.friends")
*/
public function friendsAction()
{
$service = new FriendListService();
$pager = $service->handle();
$this->view->pick('user/console/friends');
$this->view->setVar('pager', $pager);
}
/**
* @Get("/groups", name="home.uc.groups")
*/
public function groupsAction()
{
$scope = $this->request->getQuery('scope', 'string', 'joined');
$service = new GroupListService();
$pager = $service->handle($scope);
$this->view->pick('user/console/groups');
$this->view->setVar('scope', $scope);
$this->view->setVar('pager', $pager);
}
/**
* @Get("/notifications", name="home.uc.notifications")
*/

View File

@ -1,29 +0,0 @@
{% extends 'templates/layer.volt' %}
{% block content %}
<table class="kg-table layui-table">
<tr>
<th>名称</th>
<th>大小</th>
<th width="15%">操作</th>
</tr>
{% for item in items %}
<tr>
<td>{{ item.name }}</td>
<td>{{ item.size|human_size }}</td>
<td><a class="layui-btn layui-btn-sm" href="{{ item.url }}" target="_blank">下载</a></td>
</tr>
{% endfor %}
</table>
{% endblock %}
{% block inline_js %}
<script>
var index = parent.layer.getFrameIndex(window.name);
parent.layer.iframeAuto(index);
</script>
{% endblock %}

View File

@ -1,5 +1,3 @@
{% set download_url = url({'for':'home.chapter.resources','id':chapter.id}) %}
{% set consult_url = url({'for':'home.consult.add'},{'chapter_id':chapter.id}) %}
{% set like_url = url({'for':'home.chapter.like','id':chapter.id}) %}
{% set like_title = chapter.me.liked == 1 ? '取消点赞' : '点赞支持' %}
{% set like_class = chapter.me.liked == 1 ? 'active' : '' %}
@ -23,20 +21,4 @@
</div>
<div class="text" data-count="{{ chapter.comment_count }}">{{ chapter.comment_count }}</div>
</div>
{% if chapter.resource_count > 0 %}
<div class="item">
<div class="icon" title="学习资料" data-url="{{ download_url }}">
<i class="layui-icon layui-icon-download-circle icon-download"></i>
</div>
<div class="text">资料</div>
</div>
{% endif %}
{% if course.market_price > 0 %}
<div class="item">
<div class="icon" title="课程咨询" data-url="{{ consult_url }}">
<i class="layui-icon layui-icon-help icon-help"></i>
</div>
<div class="text">咨询</div>
</div>
{% endif %}
</div>

View File

@ -0,0 +1,20 @@
{% if items|length > 0 %}
<table class="layui-table" lay-skin="line">
<tr>
<th>名称</th>
<th>大小</th>
<th width="15%">操作</th>
</tr>
{% for item in items %}
<tr>
<td>{{ item.name }}</td>
<td>{{ item.size|human_size }}</td>
{% if item.me.owned == 1 and auth_user.id > 0 %}
<td><a class="layui-btn layui-btn-sm" href="{{ item.url }}" target="_blank">下载</a></td>
{% else %}
<td><a class="layui-btn layui-btn-sm layui-btn-disabled">下载</a></td>
{% endif %}
</tr>
{% endfor %}
</table>
{% endif %}

View File

@ -28,6 +28,7 @@
{% set show_tab_packages = course.package_count > 0 %}
{% set show_tab_consults = course.consult_count > 0 %}
{% set show_tab_reviews = course.review_count > 0 %}
{% set show_tab_resources = course.resource_count > 0 %}
<div class="layout-content">
<div class="course-tab-wrap wrap">
@ -44,6 +45,9 @@
{% if show_tab_reviews %}
<li>评价<span class="tab-count">{{ course.review_count }}</span></li>
{% endif %}
{% if show_tab_resources %}
<li>课件<span class="tab-count">{{ course.resource_count }}</span></li>
{% endif %}
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
@ -64,6 +68,10 @@
{% set reviews_url = url({'for':'home.course.reviews','id':course.id}) %}
<div class="layui-tab-item" id="tab-reviews" data-url="{{ reviews_url }}"></div>
{% endif %}
{% if show_tab_resources %}
{% set resources_url = url({'for':'home.course.resources','id':course.id}) %}
<div class="layui-tab-item" id="tab-resources" data-url="{{ resources_url }}"></div>
{% endif %}
</div>
</div>
</div>

View File

@ -305,6 +305,17 @@ class Course extends Repository
->execute();
}
/**
* @param int $courseId
* @return ResultsetInterface|Resultset|ResourceModel[]
*/
public function findResources($courseId)
{
return ResourceModel::query()
->where('course_id = :course_id:', ['course_id' => $courseId])
->execute();
}
/**
* @param int $courseId
* @param int $userId

View File

@ -1,39 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
namespace App\Services\Logic\Chapter;
use App\Builders\ResourceList as ResourceListBuilder;
use App\Repos\Resource as ResourceRepo;
use App\Services\Logic\ChapterTrait;
use App\Services\Logic\Service as LogicService;
class ResourceList extends LogicService
{
use ChapterTrait;
public function handle($id)
{
$chapter = $this->checkChapter($id);
$resourceRepo = new ResourceRepo();
$resources = $resourceRepo->findByChapterId($chapter->id);
if ($resources->count() == 0) {
return [];
}
$builder = new ResourceListBuilder();
$relations = $resources->toArray();
return $builder->getUploads($relations);
}
}

View File

@ -0,0 +1,49 @@
<?php
/**
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
namespace App\Services\Logic\Course;
use App\Builders\ResourceList as ResourceListBuilder;
use App\Repos\Course as CourseRepo;
use App\Services\Logic\CourseTrait;
use App\Services\Logic\Service as LogicService;
class ResourceList extends LogicService
{
use CourseTrait;
public function handle($id)
{
$course = $this->checkCourse($id);
$user = $this->getCurrentUser(true);
$this->setCourseUser($course, $user);
$courseRepo = new CourseRepo();
$resources = $courseRepo->findResources($course->id);
if ($resources->count() == 0) {
return [];
}
$builder = new ResourceListBuilder();
$relations = $resources->toArray();
$uploads = $builder->getUploads($relations);
foreach ($uploads as $key => $upload) {
$uploads[$key]['me'] = ['owned' => $this->ownedCourse ? 1 : 0];
}
return array_values($uploads);
}
}

View File

@ -61,6 +61,8 @@ class FavoriteList extends LogicService
return $this->handleQuestions($pager);
}
return null;
}
protected function handleCourses($pager)

View File

@ -39,7 +39,7 @@ class Account extends Validator
$account = $accountRepo->findById($name);
}
if (!$account) {
if (!$account || $account->deleted == 1) {
throw new BadRequestException('account.not_found');
}
@ -144,7 +144,13 @@ class Account extends Validator
$userRepo = new UserRepo();
return $userRepo->findById($account->id);
$user = $userRepo->findById($account->id);
if ($user->deleted == 1) {
throw new BadRequestException('user.not_found');
}
return $user;
}
public function checkUserLogin($name, $password)
@ -161,7 +167,13 @@ class Account extends Validator
$userRepo = new UserRepo();
return $userRepo->findById($account->id);
$user = $userRepo->findById($account->id);
if ($user->deleted == 1) {
throw new BadRequestException('user.not_found');
}
return $user;
}
public function checkAdminLogin($name, $password)

View File

@ -65,7 +65,6 @@ $error['account.login_pwd_incorrect'] = '登录密码不正确';
$error['user.not_found'] = '用户不存在';
$error['user.name_taken'] = '用户名被占用';
$error['user.title_too_long'] = '头衔过长超过30个字符';
$error['user.sign_too_long'] = '签名过长超过50个字符';
$error['user.about_too_long'] = '简介过长超过255个字符';
$error['user.invalid_gender'] = '无效的性别类型';
$error['user.invalid_area'] = '无效的省市地区';

View File

@ -141,7 +141,7 @@ final class V20210720153027 extends AbstractMigration
if (!$table->hasColumn('scopes')) {
$table->addColumn('scopes', 'string', [
'null' => false,
'default' => '',
'default' => 'all',
'limit' => 100,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',

View File

@ -0,0 +1,37 @@
<?php
/**
* @copyright Copyright (c) 2023 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
use Phinx\Db\Adapter\MysqlAdapter;
use Phinx\Migration\AbstractMigration;
final class V20230816234130 extends AbstractMigration
{
public function up()
{
$this->alterReviewLikeTable();
}
protected function alterReviewLikeTable()
{
$table = $this->table('kg_review_like');
if (!$table->hasColumn('deleted')) {
$table->addColumn('deleted', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '删除标识',
'after' => 'user_id',
]);
}
$table->save();
}
}

View File

@ -8,7 +8,7 @@ layui.use(['jquery', 'element', 'layer'], function () {
var $resFile = $('input[name=res_file]');
var $uploadBlock = $('#res-upload-block');
var $progressBlock = $('#res-progress-block');
var chapterId = $('input[name=chapter_id]').val();
var courseId = $('input[name=course_id]').val();
var myConfig = {
bucket: $('input[name=bucket]').val(),
@ -70,7 +70,7 @@ layui.use(['jquery', 'element', 'layer'], function () {
path: keyName,
md5: data.ETag ? data.ETag.replace(/"/g, '') : ''
},
chapter_id: chapterId,
course_id: courseId,
}, function () {
$uploadBlock.removeClass('layui-hide');
$progressBlock.addClass('layui-hide');

View File

@ -34,30 +34,6 @@ layui.use(['jquery', 'helper'], function () {
});
});
$('.icon-help').on('click', function () {
var url = $(this).parent().data('url');
helper.checkLogin(function () {
layer.open({
type: 2,
title: '课程咨询',
content: [url, 'no'],
area: ['640px', '300px']
});
});
});
$('.icon-download').on('click', function () {
var url = $(this).parent().data('url');
helper.checkLogin(function () {
layer.open({
type: 2,
title: '资料下载',
content: [url, 'no'],
area: ['640px', '300px']
});
});
});
$('.icon-reply').on('click', function () {
$('html').animate({
scrollTop: $('#comment-anchor').offset().top

View File

@ -135,6 +135,11 @@ layui.use(['jquery', 'layer', 'helper'], function () {
helper.ajaxLoadHtml($tabReviews.data('url'), $tabReviews.attr('id'));
}
if ($('#tab-resources').length > 0) {
var $tabResources = $('#tab-resources');
helper.ajaxLoadHtml($tabResources.data('url'), $tabResources.attr('id'));
}
if ($('#sidebar-topics').length > 0) {
var $sdTopics = $('#sidebar-topics');
helper.ajaxLoadHtml($sdTopics.data('url'), $sdTopics.attr('id'));