diff --git a/app/Console/Tasks/MaintainTask.php b/app/Console/Tasks/MaintainTask.php index 4b526448..f360db8f 100644 --- a/app/Console/Tasks/MaintainTask.php +++ b/app/Console/Tasks/MaintainTask.php @@ -5,10 +5,19 @@ namespace App\Console\Tasks; use App\Caches\IndexFreeCourseList as IndexFreeCourseListCache; use App\Caches\IndexNewCourseList as IndexNewCourseListCache; use App\Caches\IndexVipCourseList as IndexVipCourseListCache; +use App\Http\Admin\Services\Setting as SettingService; +use App\Library\Utils\Password as PasswordUtil; +use App\Validators\Account as AccountValidator; class MaintainTask extends Task { + /** + * 重建首页课程缓存 + * + * @param array $params + * @command: php console.php maintain reset_index_course_cache + */ public function rebuildIndexCourseCacheAction($params) { $section = $params[0] ?? null; @@ -29,4 +38,63 @@ class MaintainTask extends Task } } + /** + * 修改密码 + * + * @param array $params + * @command: php console.php maintain reset_password 13507083515 123456 + */ + public function resetPasswordAction($params) + { + if (empty($params[0])) { + echo 'account is required' . PHP_EOL; + } + + if (empty($params[1])) { + echo 'password is required' . PHP_EOL; + } + + $validator = new AccountValidator(); + + $account = $validator->checkAccount($params[0]); + + $salt = PasswordUtil::salt(); + $hash = PasswordUtil::hash($params[1], $salt); + + $account->salt = $salt; + $account->password = $hash; + + $account->update(); + + echo 'reset password success' . PHP_EOL; + } + + /** + * 关闭验证码 + * + * @command: php console.php maintain disable_captcha + */ + public function disableCaptchaAction() + { + $service = new SettingService(); + + $service->updateSettings('captcha', ['enabled' => 0]); + + echo 'disable captcha success' . PHP_EOL; + } + + /** + * 启用验证码 + * + * @command: php console.php maintain enable_captcha + */ + public function enableCaptchaAction() + { + $service = new SettingService(); + + $service->updateSettings('captcha', ['enabled' => 1]); + + echo 'enable captcha success' . PHP_EOL; + } + } diff --git a/app/Console/Tasks/VodEventTask.php b/app/Console/Tasks/VodEventTask.php index c51e0c1d..0189960b 100644 --- a/app/Console/Tasks/VodEventTask.php +++ b/app/Console/Tasks/VodEventTask.php @@ -28,6 +28,8 @@ class VodEventTask extends Task $this->handleNewFileUploadEvent($event); } elseif ($event['EventType'] == 'ProcedureStateChanged') { $this->handleProcedureStateChangedEvent($event); + } elseif ($event['EventType'] == 'FileDeleted') { + $this->handleFileDeletedEvent($event); } $count++; @@ -123,6 +125,11 @@ class VodEventTask extends Task $chapter->update(['attrs' => $attrs]); } + protected function handleFileDeletedEvent($event) + { + + } + protected function pullEvents() { $vodService = new VodService(); diff --git a/app/Http/Admin/Services/ChapterContent.php b/app/Http/Admin/Services/ChapterContent.php index 665992bf..f02962d1 100644 --- a/app/Http/Admin/Services/ChapterContent.php +++ b/app/Http/Admin/Services/ChapterContent.php @@ -10,6 +10,7 @@ use App\Repos\Chapter as ChapterRepo; use App\Repos\Course as CourseRepo; use App\Services\ChapterVod as ChapterVodService; use App\Services\CourseStat as CourseStatService; +use App\Services\Vod as VodService; use App\Validators\ChapterLive as ChapterLiveValidator; use App\Validators\ChapterRead as ChapterReadValidator; use App\Validators\ChapterVod as ChapterVodValidator; @@ -100,9 +101,11 @@ class ChapterContent extends Service $chapter->update(['attrs' => $attrs]); - $courseStats = new CourseStatService(); + $this->updateCourseVodAttrs($vod->course_id); - $courseStats->updateVodAttrs($chapter->course_id); + if (!empty($vod->file_id)) { + $this->deleteVodFile($vod->file_id); + } } protected function updateChapterLive(ChapterModel $chapter) @@ -135,9 +138,7 @@ class ChapterContent extends Service $chapter->update(['attrs' => $attrs]); - $courseStats = new CourseStatService(); - - $courseStats->updateLiveAttrs($chapter->course_id); + $this->updateCourseLiveAttrs($live->course_id); } protected function updateChapterRead(ChapterModel $chapter) @@ -164,9 +165,35 @@ class ChapterContent extends Service $chapter->update(['attrs' => $attrs]); - $courseStats = new CourseStatService(); + $this->updateCourseReadAttrs($read->course_id); + } - $courseStats->updateReadAttrs($chapter->course_id); + protected function updateCourseVodAttrs($courseId) + { + $statService = new CourseStatService(); + + $statService->updateVodAttrs($courseId); + } + + protected function updateCourseLiveAttrs($courseId) + { + $statService = new CourseStatService(); + + $statService->updateLiveAttrs($courseId); + } + + protected function updateCourseReadAttrs($courseId) + { + $statService = new CourseStatService(); + + $statService->updateReadAttrs($courseId); + } + + protected function deleteVodFile($fileId) + { + $vodService = new VodService(); + + $vodService->deleteMedia($fileId); } protected function rebuildCatalogCache(ChapterModel $chapter) diff --git a/app/Http/Admin/Views/public/login.volt b/app/Http/Admin/Views/public/login.volt index d2afecea..9b51cbd7 100644 --- a/app/Http/Admin/Views/public/login.volt +++ b/app/Http/Admin/Views/public/login.volt @@ -2,6 +2,9 @@ {% block content %} + {% set disabled_submit = captcha.enabled == 1 ? 'disabled="disabled"' : '' %} + {% set disabled_class = captcha.enabled == 1 ? 'layui-btn-disabled' : '' %} +