mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-07-15 21:02:20 +08:00
1.强化文章|提问|课程列表参数检查
2.优化课程学习时长同步
This commit is contained in:
parent
59b3edc1c0
commit
df9d77cad2
@ -1,4 +1,8 @@
|
||||
### [v1.6.2](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.1)(2023-01-12)
|
||||
### [v1.6.2](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.3)(2023-03-12)
|
||||
- 强化文章|提问|课程列表参数检查
|
||||
- 优化课程学习时长同步
|
||||
|
||||
### [v1.6.2](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.2)(2023-02-12)
|
||||
|
||||
- 增加ServerMonitor监控指标配置
|
||||
- 同步更新腾讯云短信内容规则
|
||||
|
@ -7,7 +7,9 @@
|
||||
|
||||
namespace App\Http\Home\Services;
|
||||
|
||||
use App\Models\Category as CategoryModel;
|
||||
use App\Models\Question as QuestionModel;
|
||||
use App\Services\Category as CategoryService;
|
||||
use App\Validators\QuestionQuery as QuestionQueryValidator;
|
||||
|
||||
class QuestionQuery extends Service
|
||||
@ -20,6 +22,40 @@ class QuestionQuery extends Service
|
||||
$this->baseUrl = $this->url->get(['for' => 'home.question.list']);
|
||||
}
|
||||
|
||||
public function handleCategories()
|
||||
{
|
||||
$params = $this->getParams();
|
||||
|
||||
if (isset($params['category_id'])) {
|
||||
unset($params['category_id']);
|
||||
}
|
||||
|
||||
$defaultItem = [
|
||||
'id' => 'all',
|
||||
'name' => '全部',
|
||||
'url' => $this->baseUrl . $this->buildParams($params),
|
||||
];
|
||||
|
||||
$result = [];
|
||||
|
||||
$result[] = $defaultItem;
|
||||
|
||||
$categoryService = new CategoryService();
|
||||
|
||||
$topCategories = $categoryService->getChildCategories(CategoryModel::TYPE_QUESTION, 0);
|
||||
|
||||
foreach ($topCategories as $key => $category) {
|
||||
$params['category_id'] = $category['id'];
|
||||
$result[] = [
|
||||
'id' => $category['id'],
|
||||
'name' => $category['name'],
|
||||
'url' => $this->baseUrl . $this->buildParams($params),
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function handleSorts()
|
||||
{
|
||||
$params = $this->getParams();
|
||||
@ -48,6 +84,11 @@ class QuestionQuery extends Service
|
||||
|
||||
$validator = new QuestionQueryValidator();
|
||||
|
||||
if (isset($query['category_id']) && $query['category_id'] != 'all') {
|
||||
$validator->checkCategory($query['category_id']);
|
||||
$params['category_id'] = $query['category_id'];
|
||||
}
|
||||
|
||||
if (isset($query['tag_id'])) {
|
||||
$validator->checkTag($query['tag_id']);
|
||||
$params['tag_id'] = $query['tag_id'];
|
||||
|
@ -16,7 +16,7 @@ class AppInfo
|
||||
|
||||
protected $link = 'https://www.koogua.com';
|
||||
|
||||
protected $version = '1.6.2';
|
||||
protected $version = '1.6.3';
|
||||
|
||||
public function __get($name)
|
||||
{
|
||||
|
@ -59,10 +59,6 @@ class Learning extends AppService
|
||||
$key = $this->getSyncKey();
|
||||
|
||||
$redis->sAdd($key, $learning->request_id);
|
||||
|
||||
if ($redis->sCard($key) == 1) {
|
||||
$redis->expire($key, $this->lifetime);
|
||||
}
|
||||
}
|
||||
|
||||
public function getItemKey($id)
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
namespace App\Validators;
|
||||
|
||||
use App\Caches\Category as CategoryCache;
|
||||
use App\Caches\Tag as TagCache;
|
||||
use App\Exceptions\BadRequest as BadRequestException;
|
||||
use App\Models\Article as ArticleModel;
|
||||
@ -17,9 +16,9 @@ class ArticleQuery extends Validator
|
||||
|
||||
public function checkCategory($id)
|
||||
{
|
||||
$categoryCache = new CategoryCache();
|
||||
$validator = new Category();
|
||||
|
||||
$category = $categoryCache->get($id);
|
||||
$category = $validator->checkCategoryCache($id);
|
||||
|
||||
if (!$category) {
|
||||
throw new BadRequestException('article_query.invalid_category');
|
||||
|
@ -16,9 +16,9 @@ class CourseQuery extends Validator
|
||||
|
||||
public function checkTopCategory($id)
|
||||
{
|
||||
$categoryCache = new CategoryCache();
|
||||
$validator = new Category();
|
||||
|
||||
$category = $categoryCache->get($id);
|
||||
$category = $validator->checkCategoryCache($id);
|
||||
|
||||
if (!$category) {
|
||||
throw new BadRequestException('course_query.invalid_top_category');
|
||||
|
@ -14,6 +14,19 @@ use App\Models\Question as QuestionModel;
|
||||
class QuestionQuery extends Validator
|
||||
{
|
||||
|
||||
public function checkCategory($id)
|
||||
{
|
||||
$validator = new Category();
|
||||
|
||||
$category = $validator->checkCategoryCache($id);
|
||||
|
||||
if (!$category) {
|
||||
throw new BadRequestException('question_query.invalid_category');
|
||||
}
|
||||
|
||||
return $category->id;
|
||||
}
|
||||
|
||||
public function checkTag($id)
|
||||
{
|
||||
$tagCache = new TagCache();
|
||||
|
Loading…
x
Reference in New Issue
Block a user