diff --git a/CHANGELOG.md b/CHANGELOG.md index 90eadbb7..1029575e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ ### [v1.4.6](https://gitee.com/koogua/course-tencent-cloud/releases/v1.4.6)(2021-10-18) +- 更新README.md +- 优化分页查询参数过滤 +- 优化分页查询参数过滤 +- 优化后台学员添加和搜索 +- 优化后台学员课程过期管理 +- 增加后台会员特权过期管理 +- 增加编辑器内站外图片自动保存到本地 +- 增加CSRF放行白名单 +- 完善订单|交易|退款序号 + +### [v1.4.6](https://gitee.com/koogua/course-tencent-cloud/releases/v1.4.6)(2021-10-18) + - 完善首页文章缓存的获取条件 - 完善热门专题的获取条件 - 优化课程章节列表逻辑 diff --git a/README.md b/README.md index 16c93aba..0a5626ac 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## 酷瓜云课堂 - + ### 项目介绍 @@ -31,13 +31,13 @@ H5手机端演示: - + 演示账号:13507083515 / 123456 微信公众号演示: - + 演示账号:13507083515 / 123456 diff --git a/app/Http/Admin/Controllers/StudentController.php b/app/Http/Admin/Controllers/StudentController.php index c8470500..b846002f 100644 --- a/app/Http/Admin/Controllers/StudentController.php +++ b/app/Http/Admin/Controllers/StudentController.php @@ -24,7 +24,10 @@ class StudentController extends Controller $sourceTypes = $studentService->getSourceTypes(); + $xmCourses = $studentService->getXmCourses('all'); + $this->view->setVar('source_types', $sourceTypes); + $this->view->setVar('xm_courses', $xmCourses); } /** @@ -53,17 +56,11 @@ class StudentController extends Controller */ public function addAction() { - $courseId = $this->request->getQuery('course_id', 'int', 0); - $studentService = new StudentService(); - $course = null; + $xmCourses = $studentService->getXmCourses('charge'); - if ($courseId > 0) { - $course = $studentService->getCourse($courseId); - } - - $this->view->setVar('course', $course); + $this->view->setVar('xm_courses', $xmCourses); } /** diff --git a/app/Http/Admin/Controllers/UploadController.php b/app/Http/Admin/Controllers/UploadController.php index 57eda34b..268ec1a7 100644 --- a/app/Http/Admin/Controllers/UploadController.php +++ b/app/Http/Admin/Controllers/UploadController.php @@ -9,6 +9,7 @@ namespace App\Http\Admin\Controllers; use App\Services\MyStorage as StorageService; use App\Services\Vod as VodService; +use App\Validators\Validator as AppValidator; /** * @RoutePrefix("/admin/upload") @@ -16,6 +17,15 @@ use App\Services\Vod as VodService; class UploadController extends Controller { + public function initialize() + { + $authUser = $this->getAuthUser(); + + $validator = new AppValidator(); + + $validator->checkAuthUser($authUser->id); + } + /** * @Post("/icon/img", name="admin.upload.icon_img") */ @@ -100,6 +110,34 @@ class UploadController extends Controller return $this->jsonSuccess(['data' => $data]); } + /** + * @Post("/remote/img", name="admin.upload.remote_img") + */ + public function uploadRemoteImageAction() + { + $originalUrl = $this->request->getPost('url', ['trim', 'string']); + + $service = new StorageService(); + + $file = $service->uploadRemoteImage($originalUrl); + + $newUrl = $originalUrl; + + if ($file) { + $newUrl = $service->getImageUrl($file->path); + } + + /** + * 编辑器要求返回的数据结构 + */ + $data = [ + 'url' => $newUrl, + 'originalURL' => $originalUrl, + ]; + + return $this->jsonSuccess(['data' => $data]); + } + /** * @Post("/default/img", name="admin.upload.default_img") */ diff --git a/app/Http/Admin/Services/Course.php b/app/Http/Admin/Services/Course.php index 4c53af65..0cbf5d44 100644 --- a/app/Http/Admin/Services/Course.php +++ b/app/Http/Admin/Services/Course.php @@ -389,7 +389,10 @@ class Course extends Service } } - $items = $courseRepo->findAll(['published' => 1]); + $items = $courseRepo->findAll([ + 'published' => 1, + 'deleted' => 0, + ]); if ($items->count() == 0) return []; @@ -397,7 +400,7 @@ class Course extends Service foreach ($items as $item) { $result[] = [ - 'name' => sprintf('%s(¥%0.2f)', $item->title, $item->market_price), + 'name' => sprintf('%s - %s(¥%0.2f)', $item->id, $item->title, $item->market_price), 'value' => $item->id, 'selected' => in_array($item->id, $courseIds), ]; diff --git a/app/Http/Admin/Services/Package.php b/app/Http/Admin/Services/Package.php index e8ce12c4..adf44462 100644 --- a/app/Http/Admin/Services/Package.php +++ b/app/Http/Admin/Services/Package.php @@ -51,6 +51,7 @@ class Package extends Service 'model' => $model, 'free' => 0, 'published' => 1, + 'deleted' => 0, ]); if ($items->count() == 0) return []; @@ -59,7 +60,7 @@ class Package extends Service foreach ($items as $item) { $result[] = [ - 'name' => sprintf('%s(¥%0.2f)', $item->title, $item->market_price), + 'name' => sprintf('%s - %s(¥%0.2f)', $item->id, $item->title, $item->market_price), 'value' => $item->id, 'selected' => in_array($item->id, $courseIds), ]; diff --git a/app/Http/Admin/Services/Student.php b/app/Http/Admin/Services/Student.php index 7c80e3bb..a89fcc4c 100644 --- a/app/Http/Admin/Services/Student.php +++ b/app/Http/Admin/Services/Student.php @@ -24,6 +24,38 @@ use App\Validators\CourseUser as CourseUserValidator; class Student extends Service { + public function getXmCourses($scope = 'all') + { + $courseRepo = new CourseRepo(); + + $where = [ + 'published' => 1, + 'deleted' => 0, + ]; + + /** + * 过滤付费课程 + */ + if ($scope == 'charge') { + $where['free'] = 0; + } + + $items = $courseRepo->findAll($where); + + if ($items->count() == 0) return []; + + $result = []; + + foreach ($items as $item) { + $result[] = [ + 'name' => sprintf('%s - %s(¥%0.2f)', $item->id, $item->title, $item->market_price), + 'value' => $item->id, + ]; + } + + return $result; + } + public function getSourceTypes() { return CourseUserModel::sourceTypes(); @@ -51,6 +83,18 @@ class Student extends Service $params['role_type'] = CourseUserModel::ROLE_STUDENT; + $validator = new CourseUserValidator(); + + if (!empty($params['xm_course_id'])) { + $course = $validator->checkCourse($params['xm_course_id']); + $params['course_id'] = $course->id; + } + + if (!empty($params['xm_user_id'])) { + $user = $validator->checkUser($params['xm_user_id']); + $params['user_id'] = $user->id; + } + $sort = $pagerQuery->getSort(); $page = $pagerQuery->getPage(); $limit = $pagerQuery->getLimit(); @@ -95,15 +139,15 @@ class Student extends Service 'source_type' => CourseUserModel::SOURCE_IMPORT, ]; - $course = $validator->checkCourse($post['course_id']); - $user = $validator->checkUser($post['user_id']); + $course = $validator->checkCourse($post['xm_course_id']); + $user = $validator->checkUser($post['xm_user_id']); $expiryTime = $validator->checkExpiryTime($post['expiry_time']); $data['course_id'] = $course->id; $data['user_id'] = $user->id; $data['expiry_time'] = $expiryTime; - $validator->checkIfImported($post['course_id'], $post['user_id']); + $validator->checkIfImported($course->id, $user->id); $courseUser = new CourseUserModel(); diff --git a/app/Http/Admin/Services/Topic.php b/app/Http/Admin/Services/Topic.php index a299cb4c..5b336cb7 100644 --- a/app/Http/Admin/Services/Topic.php +++ b/app/Http/Admin/Services/Topic.php @@ -35,7 +35,10 @@ class Topic extends Service $courseRepo = new CourseRepo(); - $items = $courseRepo->findAll(['published' => 1]); + $items = $courseRepo->findAll([ + 'published' => 1, + 'deleted' => 0, + ]); if ($items->count() == 0) return []; @@ -43,7 +46,7 @@ class Topic extends Service foreach ($items as $item) { $result[] = [ - 'name' => sprintf('%s(¥%0.2f)', $item->title, $item->market_price), + 'name' => sprintf('%s - %s(¥%0.2f)', $item->id, $item->title, $item->market_price), 'value' => $item->id, 'selected' => in_array($item->id, $courseIds), ]; diff --git a/app/Http/Admin/Views/student/add.volt b/app/Http/Admin/Views/student/add.volt index 8dd037f2..40dbcd56 100644 --- a/app/Http/Admin/Views/student/add.volt +++ b/app/Http/Admin/Views/student/add.volt @@ -2,22 +2,20 @@ {% block content %} - {% set course_id = course ? course.id : '' %} -