diff --git a/CHANGELOG.md b/CHANGELOG.md index af6041a4..50174e64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### [v1.2.1](https://gitee.com/koogua/course-tencent-cloud/releases/v1.2.1)(2020-12-10) +- 增加QQ,微信,微博第三方登录 +- 代码优化以及问题修复 + ### [v1.2.0](https://gitee.com/koogua/course-tencent-cloud/releases/v1.2.0)(2020-11-25) - 增加客户端api - 代码优化以及问题修复 diff --git a/README.md b/README.md index 1d264fff..a6a49470 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ 酷瓜云课堂,依托腾讯云基础服务架构,采用C扩展框架Phalcon开发,GPL-2.0开源协议,致力开源网课系统,开源网校系统,开源在线教育系统。 - - - + + +  #### 系统功能 diff --git a/app/Console/Tasks/VodEventTask.php b/app/Console/Tasks/VodEventTask.php index 0189960b..49d86fc7 100644 --- a/app/Console/Tasks/VodEventTask.php +++ b/app/Console/Tasks/VodEventTask.php @@ -45,7 +45,8 @@ class VodEventTask extends Task protected function handleNewFileUploadEvent($event) { $fileId = $event['FileUploadEvent']['FileId']; - $format = $event['FileUploadEvent']['MediaBasicInfo']['Type']; + $width = $event['FileUploadEvent']['MetaData']['Height']; + $height = $event['FileUploadEvent']['MetaData']['Width']; $duration = $event['FileUploadEvent']['MetaData']['Duration']; $chapterRepo = new ChapterRepo(); @@ -56,7 +57,7 @@ class VodEventTask extends Task $vodService = new VodService(); - if ($this->isAudioFile($format)) { + if ($width == 0 && $height == 0) { $vodService->createTransAudioTask($fileId); } else { $vodService->createTransVideoTask($fileId); @@ -144,13 +145,6 @@ class VodEventTask extends Task return $vodService->confirmEvents($handles); } - protected function isAudioFile($format) - { - $formats = ['mp3', 'm4a', 'wav', 'flac', 'ogg']; - - return in_array(strtolower($format), $formats); - } - protected function updateVodAttrs(ChapterModel $chapter) { $courseStats = new CourseStatService(); diff --git a/app/Http/Admin/Controllers/ChapterController.php b/app/Http/Admin/Controllers/ChapterController.php index 9b0ff8e7..1c81ebbc 100644 --- a/app/Http/Admin/Controllers/ChapterController.php +++ b/app/Http/Admin/Controllers/ChapterController.php @@ -110,8 +110,6 @@ class ChapterController extends Controller $this->view->pick('chapter/edit_lesson'); - $resources = $chapterService->getResources($chapter->id); - $cos = $chapterService->getSettings('cos'); $this->view->setVar('cos', $cos); diff --git a/app/Http/Admin/Controllers/SettingController.php b/app/Http/Admin/Controllers/SettingController.php index 24c70aa3..71e41fc0 100644 --- a/app/Http/Admin/Controllers/SettingController.php +++ b/app/Http/Admin/Controllers/SettingController.php @@ -298,4 +298,33 @@ class SettingController extends Controller } } + /** + * @Route("/oauth", name="admin.setting.oauth") + */ + public function oauthAction() + { + $settingService = new SettingService(); + + if ($this->request->isPost()) { + + $section = $this->request->getPost('section', 'string'); + + $data = $this->request->getPost(); + + $settingService->updateSettings($section, $data); + + return $this->jsonSuccess(['msg' => '更新配置成功']); + + } else { + + $qqAuth = $settingService->getQQAuthSettings(); + $weixinAuth = $settingService->getWeixinAuthSettings(); + $weiboAuth = $settingService->getWeiboAuthSettings(); + + $this->view->setVar('qq_auth', $qqAuth); + $this->view->setVar('weixin_auth', $weixinAuth); + $this->view->setVar('weibo_auth', $weiboAuth); + } + } + } diff --git a/app/Http/Admin/Services/AuthNode.php b/app/Http/Admin/Services/AuthNode.php index 43fb64fd..427c9924 100644 --- a/app/Http/Admin/Services/AuthNode.php +++ b/app/Http/Admin/Services/AuthNode.php @@ -744,6 +744,12 @@ class AuthNode extends Service 'type' => 'menu', 'route' => 'admin.setting.im', ], + [ + 'id' => '5-1-12', + 'title' => '开放登录', + 'type' => 'menu', + 'route' => 'admin.setting.oauth', + ], ], ], ], diff --git a/app/Http/Admin/Services/Chapter.php b/app/Http/Admin/Services/Chapter.php index de9372e4..5a387d95 100644 --- a/app/Http/Admin/Services/Chapter.php +++ b/app/Http/Admin/Services/Chapter.php @@ -78,6 +78,7 @@ class Chapter extends Service $data['parent_id'] = $parent->id; $data['free'] = $validator->checkFreeStatus($post['free']); $data['priority'] = $chapterRepo->maxLessonPriority($post['parent_id']); + $parentId = $parent->id; } else { $data['priority'] = $chapterRepo->maxChapterPriority($post['course_id']); $data['parent_id'] = $parentId; @@ -120,7 +121,7 @@ class Chapter extends Service } if ($attrs === false) { - throw new \RuntimeException("Create Chapter {$course->model} Attrs Failed"); + throw new \RuntimeException("Create Chapter Related Attrs Failed"); } } diff --git a/app/Http/Admin/Services/ChapterContent.php b/app/Http/Admin/Services/ChapterContent.php index f02962d1..09fccf37 100644 --- a/app/Http/Admin/Services/ChapterContent.php +++ b/app/Http/Admin/Services/ChapterContent.php @@ -81,10 +81,20 @@ class ChapterContent extends Service $vod = $chapterRepo->findChapterVod($chapter->id); + /** + * 无新文件上传 + */ if ($fileId == $vod->file_id) { return; } + /** + * 删除旧文件 + */ + if ($vod->file_id) { + $this->deleteVodFile($vod->file_id); + } + $vod->update([ 'file_id' => $fileId, 'file_transcode' => '', @@ -102,10 +112,6 @@ class ChapterContent extends Service $chapter->update(['attrs' => $attrs]); $this->updateCourseVodAttrs($vod->course_id); - - if (!empty($vod->file_id)) { - $this->deleteVodFile($vod->file_id); - } } protected function updateChapterLive(ChapterModel $chapter) diff --git a/app/Http/Admin/Services/Course.php b/app/Http/Admin/Services/Course.php index 9dba1d7c..7f644d0d 100644 --- a/app/Http/Admin/Services/Course.php +++ b/app/Http/Admin/Services/Course.php @@ -8,6 +8,7 @@ use App\Caches\CourseCategoryList as CourseCategoryListCache; use App\Caches\CourseRelatedList as CourseRelatedListCache; use App\Caches\CourseTeacherList as CourseTeacherListCache; use App\Library\Paginator\Query as PagerQuery; +use App\Models\Category as CategoryModel; use App\Models\Course as CourseModel; use App\Models\CourseCategory as CourseCategoryModel; use App\Models\CourseRating as CourseRatingModel; @@ -224,7 +225,10 @@ class Course extends Service { $categoryRepo = new CategoryRepo(); - $allCategories = $categoryRepo->findAll(['deleted' => 0]); + $allCategories = $categoryRepo->findAll([ + 'type' => CategoryModel::TYPE_COURSE, + 'deleted' => 0, + ]); if ($allCategories->count() == 0) { return []; @@ -247,8 +251,11 @@ class Course extends Service $list = []; + /** + * 没有二级分类的不显示 + */ foreach ($allCategories as $category) { - if ($category->level == 1) { + if ($category->level == 1 && $category->child_count > 0) { $list[$category->id] = [ 'name' => $category->name, 'value' => $category->id, diff --git a/app/Http/Admin/Services/Setting.php b/app/Http/Admin/Services/Setting.php index d8c97936..3d2130fd 100644 --- a/app/Http/Admin/Services/Setting.php +++ b/app/Http/Admin/Services/Setting.php @@ -9,10 +9,39 @@ use App\Repos\Vip as VipRepo; class Setting extends Service { + public function getQQAuthSettings() + { + $oauth = $this->getSettings('oauth.qq'); + + $oauth['redirect_uri'] = $oauth['redirect_uri'] ?: kg_full_url(['for' => 'home.oauth.qq_callback']); + + return $oauth; + } + + public function getWeixinAuthSettings() + { + $oauth = $this->getSettings('oauth.weixin'); + + $oauth['redirect_uri'] = $oauth['redirect_uri'] ?: kg_full_url(['for' => 'home.oauth.weixin_callback']); + + return $oauth; + } + + public function getWeiboAuthSettings() + { + $oauth = $this->getSettings('oauth.weibo'); + + $oauth['redirect_uri'] = $oauth['redirect_uri'] ?: kg_full_url(['for' => 'home.oauth.weibo_callback']); + $oauth['refuse_uri'] = $oauth['refuse_uri'] ?: kg_full_url(['for' => 'home.oauth.weibo_refuse']); + + return $oauth; + } + public function getAlipaySettings() { $alipay = $this->getSettings('pay.alipay'); + $alipay['return_url'] = $alipay['return_url'] ?: kg_full_url(['for' => 'home.alipay_callback']); $alipay['notify_url'] = $alipay['notify_url'] ?: kg_full_url(['for' => 'home.alipay_notify']); return $alipay; @@ -22,6 +51,7 @@ class Setting extends Service { $wxpay = $this->getSettings('pay.wxpay'); + $wxpay['return_url'] = $wxpay['return_url'] ?: kg_full_url(['for' => 'home.wxpay_callback']); $wxpay['notify_url'] = $wxpay['notify_url'] ?: kg_full_url(['for' => 'home.wxpay_notify']); return $wxpay; diff --git a/app/Http/Admin/Views/chapter/edit_lesson_vod.volt b/app/Http/Admin/Views/chapter/edit_lesson_vod.volt index 95be1e74..6dceb8ef 100644 --- a/app/Http/Admin/Views/chapter/edit_lesson_vod.volt +++ b/app/Http/Admin/Views/chapter/edit_lesson_vod.volt @@ -1,3 +1,5 @@ +{% set file_id = vod ? vod.file_id : '' %} + {% if play_urls %}