diff --git a/CHANGELOG.md b/CHANGELOG.md index ca93d9a7..c7fa878f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,26 @@ +### [v1.3.6](https://gitee.com/koogua/course-tencent-cloud/releases/v1.3.6)(2021-06-04) + +### 更新 + +- 清理没有用到的引用 +- 优化界面和CSS样式 +- 优化视频无法获取时长处理逻辑 +- 优化视频无法转码处理逻辑 +- 优化评论审核机制 +- 优化评论相关数据更新逻辑 +- 优化文章,问答,评论数据更新 +- 优化内容标签的更新逻辑 +- 优化首页H5的跳转判断 +- 优化单页的浏览权限 +- 优化Model中的事件方法 +- 优化kg_parse_summary函数 +- 用户主页加入问答列表 +- 修复无法关闭问题讨论 +- 修复编辑群组的路由 +- 直播去除FLV方式拉流 +- xs.question.ini加入忽略列表 +- kg_user表增加comment_count字段 + ### [v1.3.5](https://gitee.com/koogua/course-tencent-cloud/releases/v1.3.5)(2021-05-20) ### 更新 diff --git a/README.md b/README.md index a9d3c94d..ab93e614 100644 --- a/README.md +++ b/README.md @@ -84,5 +84,5 @@ Tips: 请用手机注册一个新账号,用户中心 -> 关注订阅,扫码 ### 开源助力 -毫无保留的真开源不容易,如果对你有帮助,请给我们 **STAR** !!! +毫无保留的真开源不容易,不要吝啬您的赞许和鼓励,请给我们 **STAR** !!! diff --git a/app/Caches/App.php b/app/Caches/App.php deleted file mode 100644 index 479ca191..00000000 --- a/app/Caches/App.php +++ /dev/null @@ -1,31 +0,0 @@ -lifetime; - } - - public function getKey($id = null) - { - return "app:{$id}"; - } - - public function getContent($id = null) - { - $appRepo = new AppRepo(); - - $result = $appRepo->findByAppKey($id); - - return $result ?: null; - } - -} diff --git a/app/Caches/AppInfo.php b/app/Caches/AppInfo.php new file mode 100644 index 00000000..ec5dfd00 --- /dev/null +++ b/app/Caches/AppInfo.php @@ -0,0 +1,32 @@ +lifetime; + } + + public function getKey($id = null) + { + return "_APP_INFO_"; + } + + public function getContent($id = null) + { + $appInfo = new \App\Library\AppInfo(); + + return [ + 'name' => $appInfo->name, + 'alias' => $appInfo->alias, + 'link' => $appInfo->link, + 'version' => $appInfo->version, + ]; + } + +} diff --git a/app/Console/Tasks/VodEventTask.php b/app/Console/Tasks/VodEventTask.php index 49d86fc7..d752c46a 100644 --- a/app/Console/Tasks/VodEventTask.php +++ b/app/Console/Tasks/VodEventTask.php @@ -44,10 +44,12 @@ class VodEventTask extends Task protected function handleNewFileUploadEvent($event) { - $fileId = $event['FileUploadEvent']['FileId']; - $width = $event['FileUploadEvent']['MetaData']['Height']; - $height = $event['FileUploadEvent']['MetaData']['Width']; - $duration = $event['FileUploadEvent']['MetaData']['Duration']; + $fileId = $event['FileUploadEvent']['FileId'] ?? 0; + $width = $event['FileUploadEvent']['MetaData']['Height'] ?? 0; + $height = $event['FileUploadEvent']['MetaData']['Width'] ?? 0; + $duration = $event['FileUploadEvent']['MetaData']['Duration'] ?? 0; + + if ($fileId == 0) return; $chapterRepo = new ChapterRepo(); @@ -55,6 +57,18 @@ class VodEventTask extends Task if (!$chapter) return; + $attrs = $chapter->attrs; + + /** + * 获取不到时长视为失败 + */ + if ($duration == 0) { + $attrs['file']['id'] = $fileId; + $attrs['file']['status'] = ChapterModel::FS_FAILED; + $chapter->update(['attrs' => $attrs]); + return; + } + $vodService = new VodService(); if ($width == 0 && $height == 0) { @@ -63,13 +77,8 @@ class VodEventTask extends Task $vodService->createTransVideoTask($fileId); } - /** - * @var array $attrs - */ - $attrs = $chapter->attrs; - + $attrs['file']['id'] = $fileId; $attrs['file']['status'] = ChapterModel::FS_TRANSLATING; - $attrs['duration'] = (int)$duration; $chapter->update(['attrs' => $attrs]); @@ -79,9 +88,9 @@ class VodEventTask extends Task protected function handleProcedureStateChangedEvent($event) { - $fileId = $event['ProcedureStateChangeEvent']['FileId']; + $fileId = $event['ProcedureStateChangeEvent']['FileId'] ?? 0; - $processResult = $event['ProcedureStateChangeEvent']['MediaProcessResultSet']; + if ($fileId == 0) return; $chapterRepo = new ChapterRepo(); @@ -89,6 +98,20 @@ class VodEventTask extends Task if (!$chapter) return; + $attrs = $chapter->attrs; + + $processResult = $event['ProcedureStateChangeEvent']['MediaProcessResultSet'] ?? []; + + /** + * 获取不到处理结果视为失败 + */ + if (empty($processResult)) { + $attrs['file']['id'] = $fileId; + $attrs['file']['status'] = ChapterModel::FS_FAILED; + $chapter->update(['attrs' => $attrs]); + return; + } + $failCount = $successCount = 0; foreach ($processResult as $item) { @@ -112,15 +135,9 @@ class VodEventTask extends Task $fileStatus = ChapterModel::FS_FAILED; } - if ($fileStatus == ChapterModel::FS_TRANSLATING) { - return; - } - - /** - * @var array $attrs - */ - $attrs = $chapter->attrs; + if ($fileStatus == ChapterModel::FS_TRANSLATING) return; + $attrs['file']['id'] = $fileId; $attrs['file']['status'] = $fileStatus; $chapter->update(['attrs' => $attrs]); diff --git a/app/Http/Admin/Services/Answer.php b/app/Http/Admin/Services/Answer.php index 4eda7f57..ea79042b 100644 --- a/app/Http/Admin/Services/Answer.php +++ b/app/Http/Admin/Services/Answer.php @@ -14,6 +14,7 @@ use App\Repos\Answer as AnswerRepo; use App\Repos\Question as QuestionRepo; use App\Repos\Report as ReportRepo; use App\Repos\User as UserRepo; +use App\Services\Logic\Answer\AnswerDataTrait; use App\Services\Logic\Answer\AnswerInfo as AnswerInfoService; use App\Services\Logic\Notice\System\AnswerApproved as AnswerApprovedNotice; use App\Services\Logic\Notice\System\AnswerRejected as AnswerRejectedNotice; @@ -24,6 +25,8 @@ use App\Validators\Answer as AnswerValidator; class Answer extends Service { + use AnswerDataTrait; + public function getPublishTypes() { return AnswerModel::publishTypes(); @@ -94,13 +97,16 @@ class Answer extends Service $answer = new AnswerModel(); - $answer->owner_id = $user->id; - $answer->question_id = $question->id; $answer->published = AnswerModel::PUBLISH_APPROVED; + $answer->client_type = $this->getClientType(); + $answer->client_ip = $this->getClientIp(); $answer->content = $validator->checkContent($post['content']); + $answer->question_id = $question->id; + $answer->owner_id = $user->id; $answer->create(); + $this->saveDynamicAttrs($answer); $this->recountQuestionAnswers($question); $this->recountUserAnswers($user); $this->handleAnswerPostPoint($answer); @@ -126,20 +132,21 @@ class Answer extends Service } if (isset($post['published'])) { - $data['published'] = $validator->checkPublishStatus($post['published']); - - $question = $this->findQuestion($answer->question_id); - - $this->recountQuestionAnswers($question); - - $user = $this->findUser($answer->owner_id); - - $this->recountUserAnswers($user); } $answer->update($data); + $this->saveDynamicAttrs($answer); + + $question = $this->findQuestion($answer->question_id); + + $this->recountQuestionAnswers($question); + + $owner = $this->findUser($answer->owner_id); + + $this->recountUserAnswers($owner); + $this->eventsManager->fire('Answer:afterUpdate', $this, $answer); return $answer; diff --git a/app/Http/Admin/Services/Article.php b/app/Http/Admin/Services/Article.php index 5af24563..5bbc16eb 100644 --- a/app/Http/Admin/Services/Article.php +++ b/app/Http/Admin/Services/Article.php @@ -15,10 +15,10 @@ use App\Models\User as UserModel; use App\Repos\Article as ArticleRepo; use App\Repos\Category as CategoryRepo; use App\Repos\Report as ReportRepo; -use App\Repos\Tag as TagRepo; use App\Repos\User as UserRepo; use App\Services\Logic\Article\ArticleDataTrait; use App\Services\Logic\Article\ArticleInfo as ArticleInfoService; +use App\Services\Logic\Article\XmTagList as XmTagListService; use App\Services\Logic\Notice\System\ArticleApproved as ArticleApprovedNotice; use App\Services\Logic\Notice\System\ArticleRejected as ArticleRejectedNotice; use App\Services\Logic\Point\History\ArticlePost as ArticlePostPointHistory; @@ -32,33 +32,9 @@ class Article extends Service public function getXmTags($id) { - $tagRepo = new TagRepo(); + $service = new XmTagListService(); - $allTags = $tagRepo->findAll(['published' => 1]); - - if ($allTags->count() == 0) return []; - - $articleTagIds = []; - - if ($id > 0) { - $article = $this->findOrFail($id); - if (!empty($article->tags)) { - $articleTagIds = kg_array_column($article->tags, 'id'); - } - } - - $list = []; - - foreach ($allTags as $tag) { - $selected = in_array($tag->id, $articleTagIds); - $list[] = [ - 'name' => $tag->name, - 'value' => $tag->id, - 'selected' => $selected, - ]; - } - - return $list; + return $service->handle($id); } public function getCategories() @@ -152,11 +128,15 @@ class Article extends Service $article = new ArticleModel(); $article->published = ArticleModel::PUBLISH_APPROVED; + $article->client_type = $this->getClientType(); + $article->client_ip = $this->getClientIp(); $article->owner_id = $user->id; $article->title = $title; $article->create(); + $this->saveDynamicAttrs($article); + $this->recountUserArticles($user); $this->eventsManager->fire('Article:afterCreate', $this, $article); @@ -208,12 +188,7 @@ class Article extends Service } if (isset($post['published'])) { - $data['published'] = $validator->checkPublishStatus($post['published']); - - $owner = $this->findUser($article->owner_id); - - $this->recountUserArticles($owner); } if (isset($post['xm_tag_ids'])) { @@ -222,8 +197,14 @@ class Article extends Service $article->update($data); + $this->saveDynamicAttrs($article); + $this->rebuildArticleIndex($article); + $owner = $this->findUser($article->owner_id); + + $this->recountUserArticles($owner); + $this->eventsManager->fire('Article:afterUpdate', $this, $article); return $article; @@ -237,14 +218,14 @@ class Article extends Service $article->update(); - $userRepo = new UserRepo(); - - $owner = $userRepo->findById($article->owner_id); - - $this->recountUserArticles($owner); + $this->saveDynamicAttrs($article); $this->rebuildArticleIndex($article); + $owner = $this->findUser($article->owner_id); + + $this->recountUserArticles($owner); + $this->eventsManager->fire('Article:afterDelete', $this, $article); return $article; @@ -258,14 +239,14 @@ class Article extends Service $article->update(); - $userRepo = new UserRepo(); - - $owner = $userRepo->findById($article->owner_id); - - $this->recountUserArticles($owner); + $this->saveDynamicAttrs($article); $this->rebuildArticleIndex($article); + $owner = $this->findUser($article->owner_id); + + $this->recountUserArticles($owner); + $this->eventsManager->fire('Article:afterRestore', $this, $article); return $article; diff --git a/app/Http/Admin/Services/AuthMenu.php b/app/Http/Admin/Services/AuthMenu.php index 1d69cd21..89ec4be7 100644 --- a/app/Http/Admin/Services/AuthMenu.php +++ b/app/Http/Admin/Services/AuthMenu.php @@ -10,7 +10,6 @@ class AuthMenu extends Component protected $authInfo; protected $authNodes = []; - protected $ownedRoutes = []; protected $owned1stLevelIds = []; protected $owned2ndLevelIds = []; protected $owned3rdLevelIds = []; diff --git a/app/Http/Admin/Services/AuthNode.php b/app/Http/Admin/Services/AuthNode.php index 952d795b..e2735bc7 100644 --- a/app/Http/Admin/Services/AuthNode.php +++ b/app/Http/Admin/Services/AuthNode.php @@ -530,7 +530,7 @@ class AuthNode extends Service ], ], [ - 'id' => '2-10', + 'id' => '2-11', 'title' => '举报队列', 'type' => 'menu', 'children' => [ diff --git a/app/Http/Admin/Services/Index.php b/app/Http/Admin/Services/Index.php index 32e0e39b..2302b631 100644 --- a/app/Http/Admin/Services/Index.php +++ b/app/Http/Admin/Services/Index.php @@ -2,8 +2,9 @@ namespace App\Http\Admin\Services; -use App\Caches\SiteGlobalStat; -use App\Caches\SiteTodayStat; +use App\Caches\AppInfo as AppInfoCache; +use App\Caches\SiteGlobalStat as SiteGlobalStatCache; +use App\Caches\SiteTodayStat as SiteTodayStatCache; use App\Library\AppInfo; use App\Library\Utils\ServerInfo; use App\Repos\Stat as StatRepo; @@ -28,7 +29,17 @@ class Index extends Service public function getAppInfo() { - return new AppInfo(); + $cache = new AppInfoCache(); + + $content = $cache->get(); + + $appInfo = new AppInfo(); + + if ($appInfo->version != $content['version']) { + $cache->rebuild(); + } + + return $appInfo; } public function getServerInfo() @@ -42,14 +53,14 @@ class Index extends Service public function getGlobalStat() { - $cache = new SiteGlobalStat(); + $cache = new SiteGlobalStatCache(); return $cache->get(); } public function getTodayStat() { - $cache = new SiteTodayStat(); + $cache = new SiteTodayStatCache(); return $cache->get(); } diff --git a/app/Http/Admin/Services/Question.php b/app/Http/Admin/Services/Question.php index 61d7f368..bf0a8249 100644 --- a/app/Http/Admin/Services/Question.php +++ b/app/Http/Admin/Services/Question.php @@ -14,13 +14,13 @@ use App\Models\User as UserModel; use App\Repos\Category as CategoryRepo; use App\Repos\Question as QuestionRepo; use App\Repos\Report as ReportRepo; -use App\Repos\Tag as TagRepo; use App\Repos\User as UserRepo; use App\Services\Logic\Notice\System\QuestionApproved as QuestionApprovedNotice; use App\Services\Logic\Notice\System\QuestionRejected as QuestionRejectedNotice; 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; @@ -31,33 +31,9 @@ class Question extends Service public function getXmTags($id) { - $tagRepo = new TagRepo(); + $service = new XmTagListService(); - $allTags = $tagRepo->findAll(['published' => 1]); - - if ($allTags->count() == 0) return []; - - $questionTagIds = []; - - if ($id > 0) { - $question = $this->findOrFail($id); - if (!empty($question->tags)) { - $questionTagIds = kg_array_column($question->tags, 'id'); - } - } - - $list = []; - - foreach ($allTags as $tag) { - $selected = in_array($tag->id, $questionTagIds); - $list[] = [ - 'name' => $tag->name, - 'value' => $tag->id, - 'selected' => $selected, - ]; - } - - return $list; + return $service->handle($id); } public function getCategories() @@ -146,11 +122,15 @@ class Question extends Service $question = new QuestionModel(); $question->published = QuestionModel::PUBLISH_APPROVED; + $question->client_type = $this->getClientType(); + $question->client_ip = $this->getClientIp(); $question->owner_id = $user->id; $question->title = $title; $question->create(); + $this->saveDynamicAttrs($question); + $this->recountUserQuestions($user); $this->eventsManager->fire('Question:afterCreate', $this, $question); @@ -190,12 +170,7 @@ class Question extends Service } if (isset($post['published'])) { - $data['published'] = $validator->checkPublishStatus($post['published']); - - $owner = $this->findUser($question->owner_id); - - $this->recountUserQuestions($owner); } if (isset($post['xm_tag_ids'])) { @@ -204,8 +179,14 @@ class Question extends Service $question->update($data); + $this->saveDynamicAttrs($question); + $this->rebuildQuestionIndex($question); + $owner = $this->findUser($question->owner_id); + + $this->recountUserQuestions($owner); + $this->eventsManager->fire('Question:afterUpdate', $this, $question); return $question; @@ -219,14 +200,14 @@ class Question extends Service $question->update(); - $userRepo = new UserRepo(); - - $owner = $userRepo->findById($question->owner_id); - - $this->recountUserQuestions($owner); + $this->saveDynamicAttrs($question); $this->rebuildQuestionIndex($question); + $owner = $this->findUser($question->owner_id); + + $this->recountUserQuestions($owner); + $this->eventsManager->fire('Question:afterDelete', $this, $question); return $question; @@ -240,14 +221,12 @@ class Question extends Service $question->update(); - $userRepo = new UserRepo(); + $this->rebuildQuestionIndex($question); - $owner = $userRepo->findById($question->owner_id); + $owner = $this->findUser($question->owner_id); $this->recountUserQuestions($owner); - $this->rebuildQuestionIndex($question); - $this->eventsManager->fire('Question:afterRestore', $this, $question); return $question; diff --git a/app/Http/Admin/Views/article/edit_basic.volt b/app/Http/Admin/Views/article/edit_basic.volt index ebf4ea31..05659162 100644 --- a/app/Http/Admin/Views/article/edit_basic.volt +++ b/app/Http/Admin/Views/article/edit_basic.volt @@ -50,4 +50,4 @@ - \ No newline at end of file + diff --git a/app/Http/Admin/Views/category/list.volt b/app/Http/Admin/Views/category/list.volt index 1eab62ac..f4d7b5d1 100644 --- a/app/Http/Admin/Views/category/list.volt +++ b/app/Http/Admin/Views/category/list.volt @@ -4,7 +4,7 @@ {% set back_url = url({'for':'admin.category.list'},{'type':type}) %} {% set add_url = url({'for':'admin.category.add'},{'type':type,'parent_id':parent.id}) %} - {% set allow_add = (type == 1 and parent.level < 2) or (type == 2 and parent.level < 1) or (type == 3 and parent.level < 1) %} + {% set allow_add = (type == 1 and parent.level < 2) or (type == 2 and parent.level < 1) %}