From 33fc75b9f8422841d6bd83c9a4a606d77bf5c36e Mon Sep 17 00:00:00 2001 From: xiaochong0302 Date: Wed, 27 Dec 2023 16:05:23 +0800 Subject: [PATCH] =?UTF-8?q?1.=E7=B2=BE=E7=AE=80chapter/lessons.volt=202.?= =?UTF-8?q?=E4=BD=BF=E7=94=A8ServiceTrait=E7=B2=BE=E7=AE=80=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 - app/Console/Migrations/Migration.php | 4 + app/Http/Admin/Views/chapter/lessons.volt | 113 ++++++++++++++++-- .../Admin/Views/chapter/lessons_live.volt | 88 -------------- .../Admin/Views/chapter/lessons_offline.volt | 65 ---------- .../Admin/Views/chapter/lessons_read.volt | 71 ----------- app/Http/Admin/Views/chapter/lessons_vod.volt | 89 -------------- app/Http/Api/Controllers/Controller.php | 5 - app/Listeners/Listener.php | 37 +----- app/Validators/Validator.php | 15 +-- 10 files changed, 113 insertions(+), 380 deletions(-) delete mode 100644 app/Http/Admin/Views/chapter/lessons_live.volt delete mode 100644 app/Http/Admin/Views/chapter/lessons_offline.volt delete mode 100644 app/Http/Admin/Views/chapter/lessons_read.volt delete mode 100644 app/Http/Admin/Views/chapter/lessons_vod.volt diff --git a/README.md b/README.md index 1b83845f..918714fd 100644 --- a/README.md +++ b/README.md @@ -34,12 +34,6 @@ H5手机端演示: 演示账号:13507083515 / 123456 -微信公众号演示: - -![公众号二维码](https://portal-1255691183.file.myqcloud.com/img/content/616f998270eca.png) - -演示账号:13507083515 / 123456 - 支付流程演示: - [MySQL提升课程全面讲解MySQL架构设计(0.01元)](https://ctc.koogua.com/order/confirm?item_id=1390&item_type=1) diff --git a/app/Console/Migrations/Migration.php b/app/Console/Migrations/Migration.php index 98d848d0..433999b8 100644 --- a/app/Console/Migrations/Migration.php +++ b/app/Console/Migrations/Migration.php @@ -7,7 +7,11 @@ namespace App\Console\Migrations; +use App\Traits\Service as ServiceTrait; + abstract class Migration { + use ServiceTrait; + abstract public function run(); } \ No newline at end of file diff --git a/app/Http/Admin/Views/chapter/lessons.volt b/app/Http/Admin/Views/chapter/lessons.volt index ceb10fb3..e0ea4ca6 100644 --- a/app/Http/Admin/Views/chapter/lessons.volt +++ b/app/Http/Admin/Views/chapter/lessons.volt @@ -2,6 +2,40 @@ {% block content %} + {{ partial('macros/course') }} + + {%- macro attrs_info(model,attrs) %} + {% if model == 1 %} + 类型:{{ model_type(model) }} + {% if attrs['duration'] > 0 %} + 时长:{{ attrs['duration']|duration }} + {% else %} + 时长:N/A + {% endif %} + {% elseif model == 2 %} + 类型:{{ model_type(model) }} + {% if attrs['start_time'] > 0 %} + 时间:{{ date('Y-m-d H:i',attrs['start_time']) }} + {% else %} + 时间:N/A + {% endif %} + {% elseif model == 3 %} + 类型:{{ model_type(model) }} + {% if attrs['word_count'] > 0 %} + 字数:{{ attrs['word_count'] }} + {% else %} + 字数:N/A + {% endif %} + {% elseif model == 4 %} + 类型:{{ model_type(model) }} + {% if attrs['start_time'] > 0 %} + 时间:{{ date('Y-m-d H:i',attrs['start_time']) }} + {% else %} + 时间:N/A + {% endif %} + {% endif %} + {%- endmacro %} + {% set back_url = url({'for':'admin.course.chapters','id':course.id}) %} {% set add_chapter_url = url({'for':'admin.chapter.add'},{'type':'chapter','course_id':course.id}) %} {% set add_lesson_url = url({'for':'admin.chapter.add'},{'type':'lesson','course_id':course.id,'parent_id':chapter.id}) %} @@ -21,14 +55,75 @@ - {% if course.model == 1 %} - {{ partial('chapter/lessons_vod') }} - {% elseif course.model == 2 %} - {{ partial('chapter/lessons_live') }} - {% elseif course.model == 3 %} - {{ partial('chapter/lessons_read') }} - {% elseif course.model == 4 %} - {{ partial('chapter/lessons_offline') }} - {% endif %} + + + + + + + + + + + + + + + + + + + + + + + + + {% for item in lessons %} + {% set chapter_url = url({'for':'home.chapter.show','id':item.id}) %} + {% set edit_url = url({'for':'admin.chapter.edit','id':item.id}) %} + {% set update_url = url({'for':'admin.chapter.update','id':item.id}) %} + {% set delete_url = url({'for':'admin.chapter.delete','id':item.id}) %} + {% set restore_url = url({'for':'admin.chapter.restore','id':item.id}) %} + {% set comment_url = url({'for':'admin.comment.list'},{'item_id':item.id,'item_type':1}) %} + + + + + + + + + + + {% endfor %} + +
名称学员点赞评论排序免费发布操作
+

+ {{ item.title }} + ({{ item.id }}) + +

+

{{ attrs_info(item.model,item.attrs) }}

+
{{ item.user_count }}{{ item.like_count }}{{ item.comment_count }} + +
+ + +
+
{% endblock %} \ No newline at end of file diff --git a/app/Http/Admin/Views/chapter/lessons_live.volt b/app/Http/Admin/Views/chapter/lessons_live.volt deleted file mode 100644 index e1bf3ba5..00000000 --- a/app/Http/Admin/Views/chapter/lessons_live.volt +++ /dev/null @@ -1,88 +0,0 @@ -{%- macro live_time_info(attrs) %} - {% if attrs['start_time'] > 0 %} -

开始:{{ date('Y-m-d H:i',attrs['start_time']) }}

-

结束:{{ date('Y-m-d H:i',attrs['end_time']) }}

- {% else %} - N/A - {% endif %} -{%- endmacro %} - -{%- macro live_status_info(status) %} - {% if status == 'active' %} - 活跃 - {% elseif status == 'inactive' %} - 沉默 - {% elseif status == 'forbid' %} - 禁播 - {% endif %} -{%- endmacro %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {% for item in lessons %} - {% set chapter_url = url({'for':'home.chapter.show','id':item.id}) %} - {% set edit_url = url({'for':'admin.chapter.edit','id':item.id}) %} - {% set update_url = url({'for':'admin.chapter.update','id':item.id}) %} - {% set delete_url = url({'for':'admin.chapter.delete','id':item.id}) %} - {% set restore_url = url({'for':'admin.chapter.restore','id':item.id}) %} - - - - - - - - - - - - - {% endfor %} - -
编号名称学员点赞时间推流排序免费发布操作
{{ item.id }} - {{ item.title }} - - {{ item.user_count }}{{ item.like_count }}{{ live_time_info(item.attrs) }}{{ live_status_info(item.attrs['stream']['status']) }} -
- -
    - {% if item.published == 1 %} -
  • 浏览
  • - {% endif %} -
  • 编辑
  • - {% if item.deleted == 0 %} -
  • 删除
  • - {% else %} -
  • 还原
  • - {% endif %} -
-
-
\ No newline at end of file diff --git a/app/Http/Admin/Views/chapter/lessons_offline.volt b/app/Http/Admin/Views/chapter/lessons_offline.volt deleted file mode 100644 index e9a8c6a5..00000000 --- a/app/Http/Admin/Views/chapter/lessons_offline.volt +++ /dev/null @@ -1,65 +0,0 @@ -{%- macro offline_time_info(attrs) %} - {% if attrs['start_time'] > 0 %} -

开始:{{ date('Y-m-d H:i',attrs['start_time']) }}

-

结束:{{ date('Y-m-d H:i',attrs['end_time']) }}

- {% else %} - N/A - {% endif %} -{%- endmacro %} - - - - - - - - - - - - - - - - - - - - - - - - {% for item in lessons %} - {% set edit_url = url({'for':'admin.chapter.edit','id':item.id}) %} - {% set update_url = url({'for':'admin.chapter.update','id':item.id}) %} - {% set delete_url = url({'for':'admin.chapter.delete','id':item.id}) %} - {% set restore_url = url({'for':'admin.chapter.restore','id':item.id}) %} - - - - - - - - - - {% endfor %} - -
编号名称时间排序免费发布操作
{{ item.id }} - {{ item.title }} - - {{ offline_time_info(item.attrs) }} -
- - -
-
\ No newline at end of file diff --git a/app/Http/Admin/Views/chapter/lessons_read.volt b/app/Http/Admin/Views/chapter/lessons_read.volt deleted file mode 100644 index 827aacf1..00000000 --- a/app/Http/Admin/Views/chapter/lessons_read.volt +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - {% for item in lessons %} - {% set chapter_url = url({'for':'home.chapter.show','id':item.id}) %} - {% set edit_url = url({'for':'admin.chapter.edit','id':item.id}) %} - {% set update_url = url({'for':'admin.chapter.update','id':item.id}) %} - {% set delete_url = url({'for':'admin.chapter.delete','id':item.id}) %} - {% set restore_url = url({'for':'admin.chapter.restore','id':item.id}) %} - {% set comments_url = url({'for':'admin.comment.list'},{'item_id':item.id,'item_type':1}) %} - - - - - - - - - - - - {% endfor %} - -
编号名称学员点赞评论排序免费发布操作
{{ item.id }} -

- {{ item.title }} - -

-
{{ item.user_count }}{{ item.like_count }}{{ item.comment_count }} -
- - -
-
\ No newline at end of file diff --git a/app/Http/Admin/Views/chapter/lessons_vod.volt b/app/Http/Admin/Views/chapter/lessons_vod.volt deleted file mode 100644 index 6f016903..00000000 --- a/app/Http/Admin/Views/chapter/lessons_vod.volt +++ /dev/null @@ -1,89 +0,0 @@ -{%- macro file_status(value) %} - {% if value == 'pending' %} - 待上传 - {% elseif value == 'uploaded' %} - 已上传 - {% elseif value == 'translating' %} - 转码中 - {% elseif value == 'translated' %} - 已转码 - {% elseif value == 'failed' %} - 已失败 - {% endif %} -{%- endmacro %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - {% for item in lessons %} - {% set chapter_url = url({'for':'home.chapter.show','id':item.id}) %} - {% set edit_url = url({'for':'admin.chapter.edit','id':item.id}) %} - {% set update_url = url({'for':'admin.chapter.update','id':item.id}) %} - {% set delete_url = url({'for':'admin.chapter.delete','id':item.id}) %} - {% set restore_url = url({'for':'admin.chapter.restore','id':item.id}) %} - {% set comments_url = url({'for':'admin.comment.list'},{'item_id':item.id,'item_type':1}) %} - - - - - - - - - - - - {% endfor %} - -
编号名称学员点赞评论排序免费发布操作
{{ item.id }} -

- {{ item.title }} - -

-

- 状态:{{ file_status(item.attrs['file']['status']) }} - 时长:{{ item.attrs['duration']|duration }} -

-
{{ item.user_count }}{{ item.like_count }}{{ item.comment_count }} -
- - -
-
\ No newline at end of file diff --git a/app/Http/Api/Controllers/Controller.php b/app/Http/Api/Controllers/Controller.php index f9677c20..60c3dac3 100644 --- a/app/Http/Api/Controllers/Controller.php +++ b/app/Http/Api/Controllers/Controller.php @@ -11,7 +11,6 @@ use App\Models\User as UserModel; use App\Services\Auth\Api as ApiAuth; use App\Traits\Response as ResponseTrait; use App\Traits\Security as SecurityTrait; -use App\Validators\Validator as AppValidator; use Phalcon\Mvc\Dispatcher; class Controller extends \Phalcon\Mvc\Controller @@ -31,10 +30,6 @@ class Controller extends \Phalcon\Mvc\Controller $this->setCors(); } - $validator = new AppValidator(); - - $validator->checkSiteStatus(); - $this->checkRateLimit(); return true; diff --git a/app/Listeners/Listener.php b/app/Listeners/Listener.php index 87f867f4..d305d6d7 100644 --- a/app/Listeners/Listener.php +++ b/app/Listeners/Listener.php @@ -8,50 +8,19 @@ namespace App\Listeners; use App\Services\Service as AppService; -use App\Traits\Auth as AuthTrait; +use App\Traits\Service as ServiceTrait; use Phalcon\Mvc\User\Plugin as UserPlugin; class Listener extends UserPlugin { - use AuthTrait; + use ServiceTrait; - public function getConfig() + public function getLogger($channel = 'listen') { $appService = new AppService(); - return $appService->getConfig(); - } - - - public function getCache() - { - $appService = new AppService(); - - return $appService->getCache(); - } - - public function getRedis() - { - $appService = new AppService(); - - return $appService->getRedis(); - } - - public function getLogger($channel = null) - { - $appService = new AppService(); - - $channel = $channel ?: 'listen'; - return $appService->getLogger($channel); } - public function getSettings($section) - { - $appService = new AppService(); - - return $appService->getSettings($section); - } - } diff --git a/app/Validators/Validator.php b/app/Validators/Validator.php index d395a851..9f93f4af 100644 --- a/app/Validators/Validator.php +++ b/app/Validators/Validator.php @@ -8,25 +8,14 @@ namespace App\Validators; use App\Exceptions\Forbidden as ForbiddenException; -use App\Exceptions\ServiceUnavailable; -use App\Exceptions\ServiceUnavailable as ServiceUnavailableException; use App\Exceptions\Unauthorized as UnauthorizedException; -use App\Services\Service as AppService; +use App\Traits\Service as ServiceTrait; use Phalcon\Di\Injectable; class Validator extends Injectable { - public function checkSiteStatus() - { - $service = new AppService(); - - $siteInfo = $service->getSettings('site'); - - if ($siteInfo['status'] == 'closed') { - throw new ServiceUnavailableException('sys.service_unavailable'); - } - } + use ServiceTrait; public function checkAuthUser($userId) {