mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-28 21:31:37 +08:00
v1.6.6
This commit is contained in:
parent
138b9d45ce
commit
ebd310caa6
10
CHANGELOG.md
10
CHANGELOG.md
@ -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)
|
||||
|
||||
|
@ -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")
|
||||
*/
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -8,6 +8,7 @@
|
||||
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;
|
||||
@ -404,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();
|
||||
|
@ -7,13 +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\Validators\Chapter as ChapterValidator;
|
||||
use App\Validators\Resource as ResourceValidator;
|
||||
use App\Validators\Upload as UploadValidator;
|
||||
|
||||
@ -24,10 +21,9 @@ 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']);
|
||||
|
||||
$upload = new UploadModel();
|
||||
|
||||
@ -43,12 +39,10 @@ class Resource extends Service
|
||||
$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;
|
||||
@ -82,11 +76,9 @@ class Resource extends Service
|
||||
$validator = new ResourceValidator();
|
||||
|
||||
$course = $validator->checkCourse($resource->course_id);
|
||||
$chapter = $validator->checkChapter($resource->chapter_id);
|
||||
|
||||
$resource->delete();
|
||||
|
||||
$this->recountChapterResources($chapter);
|
||||
$this->recountCourseResources($course);
|
||||
}
|
||||
|
||||
@ -97,48 +89,11 @@ 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) {
|
||||
if ($lesson->deleted == 0) {
|
||||
$resourceCount += $chapterRepo->countResources($lesson->id);
|
||||
}
|
||||
}
|
||||
|
||||
$parent->resource_count = $resourceCount;
|
||||
|
||||
$parent->update();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
$resourceCount = $courseRepo->countResources($course->id);
|
||||
|
||||
$course->resource_count = $resourceCount;
|
||||
|
||||
|
@ -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 %}
|
||||
|
@ -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>
|
||||
|
@ -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 %}
|
||||
|
||||
|
@ -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>
|
@ -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>
|
@ -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")
|
||||
*/
|
||||
|
@ -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")
|
||||
*/
|
||||
|
@ -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 %}
|
@ -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>
|
20
app/Http/Home/Views/course/resources.volt
Normal file
20
app/Http/Home/Views/course/resources.volt
Normal 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 %}
|
@ -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>
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -9,7 +9,6 @@ namespace App\Services\Logic\Course;
|
||||
|
||||
use App\Builders\ResourceList as ResourceListBuilder;
|
||||
use App\Repos\Course as CourseRepo;
|
||||
use App\Repos\Resource as ResourceRepo;
|
||||
use App\Services\Logic\CourseTrait;
|
||||
use App\Services\Logic\Service as LogicService;
|
||||
|
||||
@ -28,26 +27,7 @@ class ResourceList extends LogicService
|
||||
|
||||
$courseRepo = new CourseRepo();
|
||||
|
||||
$lessons = $courseRepo->findLessons($course->id);
|
||||
|
||||
if ($lessons->count() == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$lessonIds = [];
|
||||
|
||||
/**
|
||||
* 过滤掉未发布和已删除的课时
|
||||
*/
|
||||
foreach ($lessons as $lesson) {
|
||||
if ($lesson->published == 1 && $lesson->deleted == 0) {
|
||||
$lessonIds[] = $lesson->id;
|
||||
}
|
||||
}
|
||||
|
||||
$resourceRepo = new ResourceRepo();
|
||||
|
||||
$resources = $resourceRepo->findByCourseId($course->id);
|
||||
$resources = $courseRepo->findResources($course->id);
|
||||
|
||||
if ($resources->count() == 0) {
|
||||
return [];
|
||||
@ -57,12 +37,6 @@ class ResourceList extends LogicService
|
||||
|
||||
$relations = $resources->toArray();
|
||||
|
||||
foreach ($relations as $key => $relation) {
|
||||
if (!in_array($relation['chapter_id'], $lessonIds)) {
|
||||
unset($relations[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$uploads = $builder->getUploads($relations);
|
||||
|
||||
foreach ($uploads as $key => $upload) {
|
||||
|
@ -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');
|
@ -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
|
||||
|
@ -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'));
|
||||
|
Loading…
x
Reference in New Issue
Block a user