正在显示
1 个修改的文件
包含
20 行增加
和
7 行删除
| @@ -23,19 +23,17 @@ class BlogController extends BaseController | @@ -23,19 +23,17 @@ class BlogController extends BaseController | ||
| 23 | * @method | 23 | * @method |
| 24 | */ | 24 | */ |
| 25 | public function lists(BlogModel $blogModel,BlogCategoryLogic $blogCategoryLogic,BlogLabelLogic $blogLabelLogic){ | 25 | public function lists(BlogModel $blogModel,BlogCategoryLogic $blogCategoryLogic,BlogLabelLogic $blogLabelLogic){ |
| 26 | - //搜索条件 | ||
| 27 | - $this->map['project_id'] = $this->user['project_id']; | 26 | + $this->map = $this->searchParam(); |
| 28 | $lists = $blogModel->lists($this->map,$this->page,$this->row,$this->order = 'sort', | 27 | $lists = $blogModel->lists($this->map,$this->page,$this->row,$this->order = 'sort', |
| 29 | ['id','category_id','operator_id','status','created_at','label_id','image','updated_at','name','sort','url']); | 28 | ['id','category_id','operator_id','status','created_at','label_id','image','updated_at','name','sort','url']); |
| 30 | - if(!empty($lists['list'])){ | 29 | + if(!empty($lists) && !empty($lists['list'])){ |
| 30 | + $user = new User(); | ||
| 31 | foreach ($lists['list'] as $k => $v){ | 31 | foreach ($lists['list'] as $k => $v){ |
| 32 | - //获取分类名称 | ||
| 33 | $v = $blogCategoryLogic->get_category_name($v); | 32 | $v = $blogCategoryLogic->get_category_name($v); |
| 34 | - //获取标签名称 | ||
| 35 | $v = $blogLabelLogic->get_label_name($v); | 33 | $v = $blogLabelLogic->get_label_name($v); |
| 36 | - $v['url'] = $this->user['domain'] . RouteMap::getRoute(RouteMap::SOURCE_BLOG, $v['id'], $this->user['project_id']); | 34 | + $v['url'] = $this->user['domain'] .$v['url']; |
| 37 | $v['image_link'] = getImageUrl($v['image']); | 35 | $v['image_link'] = getImageUrl($v['image']); |
| 38 | - $v['operator_name'] = (new User())->getName($v['operator_id']); | 36 | + $v['operator_name'] = $user->getName($v['operator_id']); |
| 39 | $lists['list'][$k] = $v; | 37 | $lists['list'][$k] = $v; |
| 40 | } | 38 | } |
| 41 | } | 39 | } |
| @@ -43,6 +41,21 @@ class BlogController extends BaseController | @@ -43,6 +41,21 @@ class BlogController extends BaseController | ||
| 43 | } | 41 | } |
| 44 | 42 | ||
| 45 | /** | 43 | /** |
| 44 | + * @remark :处理列表返回参数 | ||
| 45 | + * @name :handleReturnParam | ||
| 46 | + * @author :lyh | ||
| 47 | + * @method :post | ||
| 48 | + * @time :2023/9/14 10:01 | ||
| 49 | + */ | ||
| 50 | + public function searchParam(){ | ||
| 51 | + $this->map['project_id'] = $this->user['project_id']; | ||
| 52 | + if(isset($this->map['category_id']) && !empty($this->map['category_id'])){ | ||
| 53 | + $this->map['category_id'] = ['like','%,'.$this->map['category_id'].',%']; | ||
| 54 | + } | ||
| 55 | + return $this->map; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + /** | ||
| 46 | * @remark :根据状态数量 | 59 | * @remark :根据状态数量 |
| 47 | * @name :getStatusNumber | 60 | * @name :getStatusNumber |
| 48 | * @author :lyh | 61 | * @author :lyh |
-
请 注册 或 登录 后发表评论