diff --git a/CHANGELOG.md b/CHANGELOG.md
index 505a5ed3..091cff25 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,6 @@
+### [v1.6.7](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.7)(2023-10-30)
+
+
### [v1.6.6](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.6)(2023-08-30)
- 还原意外删除的AnswerList.php文件
diff --git a/app/Builders/ArticleList.php b/app/Builders/ArticleList.php
index 7ef8ca46..68a78f5d 100644
--- a/app/Builders/ArticleList.php
+++ b/app/Builders/ArticleList.php
@@ -7,7 +7,7 @@
namespace App\Builders;
-use App\Caches\CategoryList as CategoryListCache;
+use App\Caches\CategoryAllList as CategoryAllListCache;
use App\Models\Category as CategoryModel;
use App\Repos\User as UserRepo;
@@ -47,7 +47,7 @@ class ArticleList extends Builder
public function getCategories()
{
- $cache = new CategoryListCache();
+ $cache = new CategoryAllListCache();
$items = $cache->get(CategoryModel::TYPE_ARTICLE);
diff --git a/app/Builders/CourseList.php b/app/Builders/CourseList.php
index e5a3c383..d0dffdf4 100644
--- a/app/Builders/CourseList.php
+++ b/app/Builders/CourseList.php
@@ -7,7 +7,7 @@
namespace App\Builders;
-use App\Caches\CategoryList as CategoryListCache;
+use App\Caches\CategoryAllList as CategoryAllListCache;
use App\Models\Category as CategoryModel;
use App\Repos\User as UserRepo;
@@ -38,7 +38,7 @@ class CourseList extends Builder
public function getCategories()
{
- $cache = new CategoryListCache();
+ $cache = new CategoryAllListCache();
$items = $cache->get(CategoryModel::TYPE_COURSE);
diff --git a/app/Builders/HelpList.php b/app/Builders/HelpList.php
index f451548d..bc0ee1c2 100644
--- a/app/Builders/HelpList.php
+++ b/app/Builders/HelpList.php
@@ -7,7 +7,7 @@
namespace App\Builders;
-use App\Caches\CategoryList as CategoryListCache;
+use App\Caches\CategoryAllList as CategoryAllListCache;
use App\Models\Category as CategoryModel;
class HelpList extends Builder
@@ -26,7 +26,7 @@ class HelpList extends Builder
public function getCategories()
{
- $cache = new CategoryListCache();
+ $cache = new CategoryAllListCache();
$items = $cache->get(CategoryModel::TYPE_HELP);
diff --git a/app/Builders/QuestionList.php b/app/Builders/QuestionList.php
index aeabd0e8..acd093f3 100644
--- a/app/Builders/QuestionList.php
+++ b/app/Builders/QuestionList.php
@@ -7,7 +7,7 @@
namespace App\Builders;
-use App\Caches\CategoryList as CategoryListCache;
+use App\Caches\CategoryAllList as CategoryAllListCache;
use App\Models\Category as CategoryModel;
use App\Repos\User as UserRepo;
@@ -48,7 +48,7 @@ class QuestionList extends Builder
public function getCategories()
{
- $cache = new CategoryListCache();
+ $cache = new CategoryAllListCache();
$items = $cache->get(CategoryModel::TYPE_QUESTION);
diff --git a/app/Caches/CategoryAllList.php b/app/Caches/CategoryAllList.php
new file mode 100644
index 00000000..5fdfbc08
--- /dev/null
+++ b/app/Caches/CategoryAllList.php
@@ -0,0 +1,50 @@
+lifetime;
+ }
+
+ public function getKey($type = null)
+ {
+ return "category_all_list:{$type}";
+ }
+
+ /**
+ * @param null $type
+ * @return array
+ */
+ public function getContent($type = null)
+ {
+ /**
+ * @var Resultset $categories
+ */
+ $categories = CategoryModel::query()
+ ->columns(['id', 'parent_id', 'name', 'priority', 'level', 'path'])
+ ->where('type = :type:', ['type' => $type])
+ ->orderBy('level ASC, priority ASC')
+ ->execute();
+
+ if ($categories->count() == 0) {
+ return [];
+ }
+
+ return $categories->toArray();
+ }
+
+}
diff --git a/app/Http/Admin/Services/Category.php b/app/Http/Admin/Services/Category.php
index 92e8caf8..2401fa99 100644
--- a/app/Http/Admin/Services/Category.php
+++ b/app/Http/Admin/Services/Category.php
@@ -8,6 +8,7 @@
namespace App\Http\Admin\Services;
use App\Caches\Category as CategoryCache;
+use App\Caches\CategoryAllList as CategoryAllListCache;
use App\Caches\CategoryList as CategoryListCache;
use App\Caches\CategoryTreeList as CategoryTreeListCache;
use App\Models\Category as CategoryModel;
@@ -140,7 +141,6 @@ class Category extends Service
$category->update();
$this->updateCategoryStats($category);
-
$this->rebuildCategoryCache($category);
return $category;
@@ -182,7 +182,6 @@ class Category extends Service
$category->update($data);
$this->updateCategoryStats($category);
-
$this->rebuildCategoryCache($category);
return $category;
@@ -201,7 +200,6 @@ class Category extends Service
$category->update();
$this->updateCategoryStats($category);
-
$this->rebuildCategoryCache($category);
return $category;
@@ -216,7 +214,6 @@ class Category extends Service
$category->update();
$this->updateCategoryStats($category);
-
$this->rebuildCategoryCache($category);
return $category;
@@ -250,6 +247,10 @@ class Category extends Service
$cache = new CategoryTreeListCache();
$cache->rebuild($category->type);
+
+ $cache = new CategoryAllListCache();
+
+ $cache->rebuild($category->type);
}
protected function enableChildCategories($parentId)
diff --git a/app/Http/Admin/Services/Chapter.php b/app/Http/Admin/Services/Chapter.php
index 5b01ce92..5df3290a 100644
--- a/app/Http/Admin/Services/Chapter.php
+++ b/app/Http/Admin/Services/Chapter.php
@@ -201,7 +201,9 @@ class Chapter extends Service
}
$lessonCount = $chapterRepo->countLessons($chapter->id);
+
$chapter->lesson_count = $lessonCount;
+
$chapter->update();
}
diff --git a/app/Http/Admin/Services/Course.php b/app/Http/Admin/Services/Course.php
index 7e8bd99f..7e98d612 100644
--- a/app/Http/Admin/Services/Course.php
+++ b/app/Http/Admin/Services/Course.php
@@ -453,6 +453,7 @@ class Course extends Service
$courseTeacher->user_id = $teacherId;
$courseTeacher->role_type = CourseUserModel::ROLE_TEACHER;
$courseTeacher->source_type = CourseUserModel::SOURCE_IMPORT;
+ $courseTeacher->expiry_time = strtotime('+30 years');
$courseTeacher->create();
}
}
diff --git a/app/Http/Admin/Services/Util.php b/app/Http/Admin/Services/Util.php
index b9352de6..552f235b 100644
--- a/app/Http/Admin/Services/Util.php
+++ b/app/Http/Admin/Services/Util.php
@@ -7,8 +7,7 @@
namespace App\Http\Admin\Services;
-use App\Caches\IndexSlideList as IndexSlideListCache;
-use App\Services\Utils\IndexCourseCache as IndexCourseCacheUtil;
+use App\Services\Utils\IndexPageCache as IndexPageCacheUtil;
class Util extends Service
{
@@ -17,29 +16,25 @@ class Util extends Service
{
$items = $this->request->getPost('items');
- if ($items['slide'] == 1) {
- $cache = new IndexSlideListCache();
- $cache->rebuild();
+ $sections = [
+ 'slide',
+ 'featured_course',
+ 'new_course',
+ 'free_course',
+ 'vip_course',
+ ];
+
+ if (empty($items)) {
+ $items = $sections;
}
- $util = new IndexCourseCacheUtil();
+ $util = new IndexPageCacheUtil();
- if ($items['featured_course'] == 1) {
- $util->rebuild('featured_course');
+ foreach ($sections as $section) {
+ if (in_array($section, $items)) {
+ $util->rebuild($section);
+ }
}
-
- if ($items['new_course'] == 1) {
- $util->rebuild('new_course');
- }
-
- if ($items['free_course'] == 1) {
- $util->rebuild('free_course');
- }
-
- if ($items['vip_course'] == 1) {
- $util->rebuild('vip_course');
- }
-
}
}
diff --git a/app/Http/Admin/Views/article/list.volt b/app/Http/Admin/Views/article/list.volt
index 13269e08..50f9c6f6 100644
--- a/app/Http/Admin/Views/article/list.volt
+++ b/app/Http/Admin/Views/article/list.volt
@@ -80,8 +80,10 @@
{{ item.like_count }} |
{{ item.favorite_count }} |
{{ publish_status(item.published) }} |
- |
- |
+ |
+ |
@@ -126,7 +128,13 @@
var featured = checked ? 1 : 0;
var url = $(this).data('url');
var tips = featured === 1 ? '确定要推荐?' : '确定要取消推荐?';
- layer.confirm(tips, function () {
+ layer.confirm(tips, {
+ cancel: function (index) {
+ layer.close(index);
+ data.elem.checked = !checked;
+ form.render();
+ }
+ }, function () {
$.ajax({
type: 'POST',
url: url,
diff --git a/app/Http/Admin/Views/course/list.volt b/app/Http/Admin/Views/course/list.volt
index 0b17998e..0c25d653 100644
--- a/app/Http/Admin/Views/course/list.volt
+++ b/app/Http/Admin/Views/course/list.volt
@@ -96,8 +96,10 @@
市场:{{ '¥%0.2f'|format(item.market_price) }}
会员:{{ '¥%0.2f'|format(item.vip_price) }}
|
- |
- |
+ |
+ |
@@ -144,7 +146,13 @@
var featured = checked ? 1 : 0;
var url = $(this).data('url');
var tips = featured === 1 ? '确定要推荐?' : '确定要取消推荐?';
- layer.confirm(tips, function () {
+ layer.confirm(tips, {
+ cancel: function (index) {
+ layer.close(index);
+ data.elem.checked = !checked;
+ form.render();
+ }
+ }, function () {
$.ajax({
type: 'POST',
url: url,
diff --git a/app/Http/Admin/Views/question/list.volt b/app/Http/Admin/Views/question/list.volt
index 66d8e660..da8d49d9 100644
--- a/app/Http/Admin/Views/question/list.volt
+++ b/app/Http/Admin/Views/question/list.volt
@@ -78,7 +78,8 @@
{{ item.like_count }} |
{{ item.favorite_count }} |
{{ publish_status(item.published) }} |
- |
+ |
@@ -124,7 +125,13 @@
var closed = checked ? 1 : 0;
var url = $(this).data('url');
var tips = closed === 1 ? '确定要关闭讨论?' : '确定要开启讨论?';
- layer.confirm(tips, function () {
+ layer.confirm(tips, {
+ cancel: function (index) {
+ layer.close(index);
+ data.elem.checked = !checked;
+ form.render();
+ }
+ }, function () {
$.ajax({
type: 'POST',
url: url,
diff --git a/app/Http/Admin/Views/review/list.volt b/app/Http/Admin/Views/review/list.volt
index 59276eff..6dc86644 100644
--- a/app/Http/Admin/Views/review/list.volt
+++ b/app/Http/Admin/Views/review/list.volt
@@ -52,7 +52,7 @@
课程:{{ item.course.title }}({{ item.course.id }})
- 评价:{{ item.content }}
+ 评价:{{ substr(item.content,0,30) }}({{ item.id }})
时间:{{ date('Y-m-d H:i:s',item.create_time) }}
|
diff --git a/app/Http/Admin/Views/student/learning.volt b/app/Http/Admin/Views/student/learning.volt
index 314ef2c2..61d5d226 100644
--- a/app/Http/Admin/Views/student/learning.volt
+++ b/app/Http/Admin/Views/student/learning.volt
@@ -2,17 +2,7 @@
{% block content %}
- {%- macro client_type_info(value) %}
- {% if value == 1 %}
- desktop
- {% elseif value == 2 %}
- mobile
- {% elseif value == 3 %}
- app
- {% elseif value == 4 %}
- 小程序
- {% endif %}
- {%- endmacro %}
+ {{ partial('macros/common') }}
@@ -20,7 +10,6 @@
-
@@ -36,11 +25,11 @@
{% set active_time = item.active_time > 0 ? date('Y-m-d H:i:s',item.active_time) : 'N/A' %}
- 课程:{{ item.course.title }}
- 章节:{{ item.chapter.title }}
+ 课程:{{ item.course.title }}({{ item.course.id }})
+ 章节:{{ item.chapter.title }}({{ item.chaper.id }})
|
- 类型:{{ client_type_info(item.client_type) }}
+ 类型:{{ client_type(item.client_type) }}
地址:{{ item.client_ip }}
|
{{ duration }} |
diff --git a/app/Http/Home/Views/error/show401.volt b/app/Http/Home/Views/error/show401.volt
index c483a510..b42bae93 100644
--- a/app/Http/Home/Views/error/show401.volt
+++ b/app/Http/Home/Views/error/show401.volt
@@ -5,6 +5,7 @@
+ 无操作权限,请先登录认证
4
diff --git a/app/Http/Home/Views/error/show403.volt b/app/Http/Home/Views/error/show403.volt
index c4ef6f50..5b807f52 100644
--- a/app/Http/Home/Views/error/show403.volt
+++ b/app/Http/Home/Views/error/show403.volt
@@ -5,6 +5,7 @@
+ 无操作权限,禁止访问
4
diff --git a/app/Http/Home/Views/error/show404.volt b/app/Http/Home/Views/error/show404.volt
index c20a6f27..1e1e276b 100644
--- a/app/Http/Home/Views/error/show404.volt
+++ b/app/Http/Home/Views/error/show404.volt
@@ -5,6 +5,7 @@
+ 迷失自我,相关资源不存在
4
diff --git a/app/Http/Home/Views/error/show500.volt b/app/Http/Home/Views/error/show500.volt
index 5a8cff68..e579901e 100644
--- a/app/Http/Home/Views/error/show500.volt
+++ b/app/Http/Home/Views/error/show500.volt
@@ -5,6 +5,7 @@
+ 尴尬到家,服务器内部错误
5
diff --git a/app/Http/Home/Views/error/show503.volt b/app/Http/Home/Views/error/show503.volt
index 4cf9059a..31f883eb 100644
--- a/app/Http/Home/Views/error/show503.volt
+++ b/app/Http/Home/Views/error/show503.volt
@@ -5,6 +5,7 @@
+ 压力山大,当前服务不可用
5
diff --git a/app/Library/AppInfo.php b/app/Library/AppInfo.php
index db1f3483..a33bb0a3 100644
--- a/app/Library/AppInfo.php
+++ b/app/Library/AppInfo.php
@@ -16,7 +16,7 @@ class AppInfo
protected $link = 'https://www.koogua.com';
- protected $version = '1.6.6';
+ protected $version = '1.6.7';
public function __get($name)
{
diff --git a/app/Library/Helper.php b/app/Library/Helper.php
index 0240e6ec..55f5a8f5 100644
--- a/app/Library/Helper.php
+++ b/app/Library/Helper.php
@@ -424,6 +424,21 @@ function kg_cos_img_style_trim($path)
return preg_replace('/!\w+/', '', $path);
}
+/**
+ * 获取编辑器内容长度
+ *
+ * @param string $content
+ * @return int
+ */
+function kg_editor_content_length($content)
+{
+ $content = trim($content);
+
+ $content = strip_tags($content,' ');
+
+ return kg_strlen($content);
+}
+
/**
* 清理html内容
*
diff --git a/app/Repos/Category.php b/app/Repos/Category.php
index 3de5830e..7a97ffca 100644
--- a/app/Repos/Category.php
+++ b/app/Repos/Category.php
@@ -85,6 +85,7 @@ class Category extends Repository
->where('type = :type:', ['type' => $type])
->andWhere('parent_id = 0')
->andWhere('published = 1')
+ ->andWhere('deleted = 0')
->orderBy('priority ASC')
->execute();
}
@@ -98,6 +99,7 @@ class Category extends Repository
return CategoryModel::query()
->where('parent_id = :parent_id:', ['parent_id' => $categoryId])
->andWhere('published = 1')
+ ->andWhere('deleted = 0')
->orderBy('priority ASC')
->execute();
}
@@ -105,7 +107,7 @@ class Category extends Repository
public function countChildCategories($categoryId)
{
return (int)CategoryModel::count([
- 'conditions' => 'parent_id = :parent_id: AND published = 1',
+ 'conditions' => 'parent_id = :parent_id: AND published = 1 AND deleted = 0',
'bind' => ['parent_id' => $categoryId],
]);
}
diff --git a/app/Repos/Course.php b/app/Repos/Course.php
index 40000ae0..7a504ef3 100644
--- a/app/Repos/Course.php
+++ b/app/Repos/Course.php
@@ -79,7 +79,7 @@ class Course extends Repository
if (!empty($where['level'])) {
if (is_array($where['level'])) {
- $builder->inWhere('level', $where['model']);
+ $builder->inWhere('level', $where['level']);
} else {
$builder->andWhere('level = :level:', ['level' => $where['level']]);
}
diff --git a/app/Services/Logic/Course/ReviewList.php b/app/Services/Logic/Course/ReviewList.php
index 5e97dd97..f3a1c270 100644
--- a/app/Services/Logic/Course/ReviewList.php
+++ b/app/Services/Logic/Course/ReviewList.php
@@ -102,11 +102,11 @@ class ReviewList extends LogicService
$result = [];
- foreach ($reviews as $consult) {
- $result[$consult['id']] = [
+ foreach ($reviews as $review) {
+ $result[$review['id']] = [
'logged' => $user->id > 0 ? 1 : 0,
- 'liked' => in_array($consult['id'], $likedIds) ? 1 : 0,
- 'owned' => $consult['owner_id'] == $user->id ? 1 : 0,
+ 'liked' => in_array($review['id'], $likedIds) ? 1 : 0,
+ 'owned' => $review['owner_id'] == $user->id ? 1 : 0,
];
}
diff --git a/app/Services/Logic/Review/ReviewCreate.php b/app/Services/Logic/Review/ReviewCreate.php
index 07d4520d..52aa2507 100644
--- a/app/Services/Logic/Review/ReviewCreate.php
+++ b/app/Services/Logic/Review/ReviewCreate.php
@@ -16,16 +16,14 @@ use App\Services\Logic\CourseTrait;
use App\Services\Logic\Point\History\CourseReview as CourseReviewPointHistory;
use App\Services\Logic\ReviewTrait;
use App\Services\Logic\Service as LogicService;
-use App\Traits\Client as ClientTrait;
use App\Validators\CourseUser as CourseUserValidator;
-use App\Validators\Review as ReviewValidator;
class ReviewCreate extends LogicService
{
- use ClientTrait;
use CourseTrait;
use ReviewTrait;
+ use ReviewDataTrait;
public function handle()
{
@@ -41,19 +39,10 @@ class ReviewCreate extends LogicService
$validator->checkIfReviewed($course->id, $user->id);
- $validator = new ReviewValidator();
+ $data = $this->handlePostData($post);
- $data = [
- 'client_type' => $this->getClientType(),
- 'client_ip' => $this->getClientIp(),
- 'course_id' => $course->id,
- 'owner_id' => $user->id,
- ];
-
- $data['content'] = $validator->checkContent($post['content']);
- $data['rating1'] = $validator->checkRating($post['rating1']);
- $data['rating2'] = $validator->checkRating($post['rating2']);
- $data['rating3'] = $validator->checkRating($post['rating3']);
+ $data['course_id'] = $course->id;
+ $data['owner_id'] = $user->id;
$data['published'] = 1;
$review = new ReviewModel();
diff --git a/app/Services/Logic/Review/ReviewDataTrait.php b/app/Services/Logic/Review/ReviewDataTrait.php
new file mode 100644
index 00000000..649cda30
--- /dev/null
+++ b/app/Services/Logic/Review/ReviewDataTrait.php
@@ -0,0 +1,39 @@
+getClientType();
+ $data['client_ip'] = $this->getClientIp();
+
+ $validator = new ReviewValidator();
+
+ $data['content'] = $validator->checkContent($post['content']);
+ $data['rating1'] = $validator->checkRating($post['rating1']);
+ $data['rating2'] = $validator->checkRating($post['rating2']);
+ $data['rating3'] = $validator->checkRating($post['rating3']);
+
+ if (isset($post['anonymous'])) {
+ $data['anonymous'] = $validator->checkAnonymous($post['anonymous']);
+ }
+
+ return $data;
+ }
+
+}
diff --git a/app/Services/Utils/IndexCourseCache.php b/app/Services/Utils/IndexPageCache.php
similarity index 88%
rename from app/Services/Utils/IndexCourseCache.php
rename to app/Services/Utils/IndexPageCache.php
index 7b56a4be..76c737b4 100644
--- a/app/Services/Utils/IndexCourseCache.php
+++ b/app/Services/Utils/IndexPageCache.php
@@ -7,6 +7,7 @@
namespace App\Services\Utils;
+use App\Caches\IndexSlideList as IndexSlideListCache;
use App\Caches\IndexFeaturedCourseList as IndexFeaturedCourseListCache;
use App\Caches\IndexFreeCourseList as IndexFreeCourseListCache;
use App\Caches\IndexNewCourseList as IndexNewCourseListCache;
@@ -17,11 +18,16 @@ use App\Caches\IndexSimpleVipCourseList as IndexSimpleVipCourseListCache;
use App\Caches\IndexVipCourseList as IndexVipCourseListCache;
use App\Services\Service as AppService;
-class IndexCourseCache extends AppService
+class IndexPageCache extends AppService
{
public function rebuild($section = null)
{
+ if (!$section || $section == 'slide') {
+ $cache = new IndexSlideListCache();
+ $cache->rebuild();
+ }
+
if (!$section || $section == 'featured_course') {
$cache = new IndexFeaturedCourseListCache();
$cache->rebuild();
diff --git a/app/Validators/Account.php b/app/Validators/Account.php
index a70e8878..7daec3fd 100644
--- a/app/Validators/Account.php
+++ b/app/Validators/Account.php
@@ -159,9 +159,7 @@ class Account extends Validator
$account = $this->checkAccount($name);
- $hash = PasswordUtil::hash($password, $account->salt);
-
- if ($hash != $account->password) {
+ if (!PasswordUtil::checkHash($password, $account->salt, $account->password)) {
throw new BadRequestException('account.login_pwd_incorrect');
}
diff --git a/app/Validators/Answer.php b/app/Validators/Answer.php
index bb1099a4..d8c2eef1 100644
--- a/app/Validators/Answer.php
+++ b/app/Validators/Answer.php
@@ -63,7 +63,7 @@ class Answer extends Validator
$value = $storage->handle($value);
- $length = kg_strlen($value);
+ $length = kg_editor_content_length($value);
if ($length < 10) {
throw new BadRequestException('answer.content_too_short');
diff --git a/app/Validators/Article.php b/app/Validators/Article.php
index 9987d097..7aeaccdc 100644
--- a/app/Validators/Article.php
+++ b/app/Validators/Article.php
@@ -99,7 +99,7 @@ class Article extends Validator
$value = $storage->handle($value);
- $length = kg_strlen($value);
+ $length = kg_editor_content_length($value);
if ($length < 10) {
throw new BadRequestException('article.content_too_short');
diff --git a/app/Validators/ChapterVod.php b/app/Validators/ChapterVod.php
index 81651391..0d19bcec 100644
--- a/app/Validators/ChapterVod.php
+++ b/app/Validators/ChapterVod.php
@@ -26,7 +26,7 @@ class ChapterVod extends Validator
public function checkDuration($duration)
{
- $value = $value = $this->filter->sanitize($duration, ['trim', 'int']);
+ $value = $this->filter->sanitize($duration, ['trim', 'int']);
if ($value < 10 || $value > 10 * 3600) {
throw new BadRequestException('chapter_vod.invalid_duration');
diff --git a/app/Validators/Course.php b/app/Validators/Course.php
index b562d98f..b791adf2 100644
--- a/app/Validators/Course.php
+++ b/app/Validators/Course.php
@@ -124,7 +124,7 @@ class Course extends Validator
$value = $storage->handle($value);
- $length = kg_strlen($value);
+ $length = kg_editor_content_length($value);
if ($length > 30000) {
throw new BadRequestException('course.details_too_long');
@@ -257,11 +257,11 @@ class Course extends Validator
public function checkPublishAbility(CourseModel $course)
{
- if ($course->model == CourseModel::MODEL_OFFLINE) return true;
-
if ($course->teacher_id == 0) {
throw new BadRequestException('course.teacher_not_assigned');
}
+
+ return true;
}
}
diff --git a/app/Validators/Help.php b/app/Validators/Help.php
index c5acab63..a1356f5a 100644
--- a/app/Validators/Help.php
+++ b/app/Validators/Help.php
@@ -95,7 +95,7 @@ class Help extends Validator
$value = $storage->handle($value);
- $length = kg_strlen($value);
+ $length = kg_editor_content_length($value);
if ($length < 10) {
throw new BadRequestException('help.content_too_short');
diff --git a/app/Validators/Page.php b/app/Validators/Page.php
index 2080d7a6..7bf04814 100644
--- a/app/Validators/Page.php
+++ b/app/Validators/Page.php
@@ -129,7 +129,7 @@ class Page extends Validator
$value = $storage->handle($value);
- $length = kg_strlen($value);
+ $length = kg_editor_content_length($value);
if ($length < 10) {
throw new BadRequestException('page.content_too_short');
diff --git a/app/Validators/PointGift.php b/app/Validators/PointGift.php
index 4f7e30b1..352f6504 100644
--- a/app/Validators/PointGift.php
+++ b/app/Validators/PointGift.php
@@ -91,7 +91,7 @@ class PointGift extends Validator
$value = $storage->handle($value);
- $length = kg_strlen($value);
+ $length = kg_editor_content_length($value);
if ($length > 30000) {
throw new BadRequestException('point_gift.details_too_long');
diff --git a/app/Validators/Question.php b/app/Validators/Question.php
index 84d1e98d..b4ff8be4 100644
--- a/app/Validators/Question.php
+++ b/app/Validators/Question.php
@@ -111,7 +111,7 @@ class Question extends Validator
$value = $storage->handle($value);
- $length = kg_strlen($value);
+ $length = kg_editor_content_length($value);
if ($length > 30000) {
throw new BadRequestException('question.content_too_long');
diff --git a/app/Validators/Review.php b/app/Validators/Review.php
index b5faf25f..2ab09073 100644
--- a/app/Validators/Review.php
+++ b/app/Validators/Review.php
@@ -61,6 +61,15 @@ class Review extends Validator
return $rating;
}
+ public function checkAnonymous($status)
+ {
+ if (!in_array($status, [0, 1])) {
+ throw new BadRequestException('review.invalid_anonymous_status');
+ }
+
+ return $status;
+ }
+
public function checkPublishStatus($status)
{
if (!in_array($status, [0, 1])) {
diff --git a/db/migrations/20230910174508.php b/db/migrations/20230910174508.php
new file mode 100644
index 00000000..7cc60ada
--- /dev/null
+++ b/db/migrations/20230910174508.php
@@ -0,0 +1,39 @@
+alterCourseTable();
+ }
+
+ protected function alterCourseTable()
+ {
+ $table = $this->table('kg_course');
+
+ if (!$table->hasIndexByName('category_id')) {
+ $table->addIndex(['category_id'], [
+ 'name' => 'category_id',
+ 'unique' => false,
+ ]);
+ }
+
+ if (!$table->hasIndexByName('teacher_id')) {
+ $table->addIndex(['teacher_id'], [
+ 'name' => 'teacher_id',
+ 'unique' => false,
+ ]);
+ }
+
+ $table->save();
+ }
+
+}
diff --git a/public/static/admin/js/common.js b/public/static/admin/js/common.js
index 2773c11f..97fc1e05 100644
--- a/public/static/admin/js/common.js
+++ b/public/static/admin/js/common.js
@@ -84,7 +84,13 @@ layui.use(['jquery', 'form', 'element', 'layer', 'kgDropdown'], function () {
var published = checked ? 1 : 0;
var url = $(this).data('url');
var tips = published === 1 ? '确定要上线?' : '确定要下线?';
- layer.confirm(tips, function () {
+ layer.confirm(tips, {
+ cancel: function (index) {
+ layer.close(index);
+ data.elem.checked = !checked;
+ form.render();
+ }
+ }, function () {
$.ajax({
type: 'POST',
url: url,
| | |