Browse Source

feat(article): 添加文章分类ID筛选功能

- 在控制器中增加 article_category_id 参数支持
- 在服务层实现根据 article_category_id 筛选逻辑
- 优化查询条件构建,确保参数安全过滤
master
zhangf@suq.cn 6 days ago
parent
commit
0745837beb
  1. 1
      app/controller/CreationArticleController.php
  2. 3
      app/service/CreationArticleService.php

1
app/controller/CreationArticleController.php

@ -38,6 +38,7 @@ class CreationArticleController
public function index(CreationArticleService $service): Response
{
$params = requestOnly([
'article_category_id' => '',
'article_category' => '',
'task' => '',
'title' => '',

3
app/service/CreationArticleService.php

@ -70,6 +70,9 @@ class CreationArticleService extends BaseService
$query = [
'delete_time' => 0
];
if (isNotBlank($params['article_category_id'])) {
$query[] = ['article_category_id', '=', $params['article_category_id']];
}
if (isNotBlank($params['article_category'])) {
$cids = $this->articleCategoryDao->getColumn([['name', 'like', '%' . $params['article_category'] . '%']], 'id');
$query[] = ['article_category_id', 'in', $cids];

Loading…
Cancel
Save