作者 lyh

gx

@@ -9,7 +9,6 @@ use App\Http\Requests\Bside\Blog\BlogRequest; @@ -9,7 +9,6 @@ use App\Http\Requests\Bside\Blog\BlogRequest;
9 use App\Models\Blog\Blog as BlogModel; 9 use App\Models\Blog\Blog as BlogModel;
10 use App\Models\Blog\BlogCategory; 10 use App\Models\Blog\BlogCategory;
11 use App\Models\Blog\BlogCategory as BlogCategoryModel; 11 use App\Models\Blog\BlogCategory as BlogCategoryModel;
12 -use App\Models\Product\Category;  
13 use App\Models\RouteMap\RouteMap; 12 use App\Models\RouteMap\RouteMap;
14 use App\Models\User\User; 13 use App\Models\User\User;
15 14
@@ -56,12 +55,8 @@ class BlogController extends BaseController @@ -56,12 +55,8 @@ class BlogController extends BaseController
56 $query = $query->where('project_id',$this->user['project_id']); 55 $query = $query->where('project_id',$this->user['project_id']);
57 if (isset($this->map['category_id']) && !empty($this->map['category_id'])) { 56 if (isset($this->map['category_id']) && !empty($this->map['category_id'])) {
58 $str = []; 57 $str = [];
59 - $this->getLastLevelIds($this->map['category_id'],$str);  
60 - $query->where(function ($subQuery) use ($str) {  
61 - foreach ($str as $v) {  
62 - $subQuery->orWhereRaw("FIND_IN_SET(?, category_id) > 0", [$v]);  
63 - }  
64 - }); 58 + $this->getAllSub($this->map['category_id'],$str);
  59 + $query = $query->whereIn('category_id',$str);
65 } 60 }
66 if(isset($this->map['status'])){ 61 if(isset($this->map['status'])){
67 $query = $query->where('status',$this->map['status']); 62 $query = $query->where('status',$this->map['status']);
@@ -76,24 +71,22 @@ class BlogController extends BaseController @@ -76,24 +71,22 @@ class BlogController extends BaseController
76 } 71 }
77 72
78 /** 73 /**
79 - * @remark :获取当前分类的最后一级id  
80 - * @name :getLastLevelIds 74 + * @remark :获取当前id下所有子集
  75 + * @name :getAllSub
81 * @author :lyh 76 * @author :lyh
82 * @method :post 77 * @method :post
83 - * @time :2023/10/20 15:02 78 + * @time :2023/10/18 15:10
84 */ 79 */
85 - public function getLastLevelIds($id, &$str = []) {  
86 - $cateModel = new BlogCategoryModel();  
87 - $subList = $cateModel->where('pid', $id)->get();  
88 - if ($subList->isEmpty()) {  
89 - // 如果没有子集,将当前 ID 添加到最后一级 ID 数组  
90 - $str[] = $id;  
91 - } else {  
92 - // 如果有子集,继续向下遍历  
93 - foreach ($subList as $v) {  
94 - $this->getLastLevelIds($v->id, $str); 80 + public function getAllSub($id,&$str = []){
  81 + $cateModel = new BlogCategory();
  82 + $list = $cateModel->list(['pid'=>$id,'status'=>1],['id','pid']);
  83 + if(!empty($list)){
  84 + foreach ($list as $v){
  85 + $str[] = $v['id'];
  86 + $this->getAllSub($v['id'],$str);
95 } 87 }
96 } 88 }
  89 + return $str;
97 } 90 }
98 91
99 /** 92 /**
@@ -158,7 +151,7 @@ class BlogController extends BaseController @@ -158,7 +151,7 @@ class BlogController extends BaseController
158 public function get_category_list(){ 151 public function get_category_list(){
159 $this->map['status'] = 0; 152 $this->map['status'] = 0;
160 $this->map['project_id'] = $this->user['project_id']; 153 $this->map['project_id'] = $this->user['project_id'];
161 - $blogCategoryModel = new BlogCategoryModel(); 154 + $blogCategoryModel = new BlogCategory();
162 $cate_list = $blogCategoryModel->list($this->map,'sort'); 155 $cate_list = $blogCategoryModel->list($this->map,'sort');
163 if($cate_list === false){ 156 if($cate_list === false){
164 $this->fail('error',Code::USER_ERROR); 157 $this->fail('error',Code::USER_ERROR);
@@ -58,12 +58,8 @@ class NewsController extends BaseController @@ -58,12 +58,8 @@ class NewsController extends BaseController
58 $query = $query->where('project_id',$this->user['project_id']); 58 $query = $query->where('project_id',$this->user['project_id']);
59 if (isset($this->map['category_id']) && !empty($this->map['category_id'])) { 59 if (isset($this->map['category_id']) && !empty($this->map['category_id'])) {
60 $str = []; 60 $str = [];
61 - $this->getLastLevelIds($this->map['category_id'],$str);  
62 - $query->where(function ($subQuery) use ($str) {  
63 - foreach ($str as $v) {  
64 - $subQuery->orWhereRaw("FIND_IN_SET(?, category_id) > 0", [$v]);  
65 - }  
66 - }); 61 + $this->getAllSub($this->map['category_id'],$str);
  62 + $query = $query->whereIn('category_id',$str);
67 } 63 }
68 if(isset($this->map['status'])){ 64 if(isset($this->map['status'])){
69 $query = $query->where('status',$this->map['status']); 65 $query = $query->where('status',$this->map['status']);
@@ -78,24 +74,22 @@ class NewsController extends BaseController @@ -78,24 +74,22 @@ class NewsController extends BaseController
78 } 74 }
79 75
80 /** 76 /**
81 - * @remark :获取当前分类的最后一级id  
82 - * @name :getLastLevelIds 77 + * @remark :获取当前id下所有子集
  78 + * @name :getAllSub
83 * @author :lyh 79 * @author :lyh
84 * @method :post 80 * @method :post
85 - * @time :2023/10/20 15:02 81 + * @time :2023/10/18 15:10
86 */ 82 */
87 - public function getLastLevelIds($id, &$str = []) { 83 + public function getAllSub($id,&$str = []){
88 $cateModel = new NewsCategory(); 84 $cateModel = new NewsCategory();
89 - $subList = $cateModel->where('pid', $id)->get();  
90 - if ($subList->isEmpty()) {  
91 - // 如果没有子集,将当前 ID 添加到最后一级 ID 数组  
92 - $str[] = $id;  
93 - } else {  
94 - // 如果有子集,继续向下遍历  
95 - foreach ($subList as $v) {  
96 - $this->getLastLevelIds($v->id, $str); 85 + $list = $cateModel->list(['pid'=>$id,'status'=>1],['id','pid']);
  86 + if(!empty($list)){
  87 + foreach ($list as $v){
  88 + $str[] = $v['id'];
  89 + $this->getAllSub($v['id'],$str);
97 } 90 }
98 } 91 }
  92 + return $str;
99 } 93 }
100 94
101 /** 95 /**
@@ -79,12 +79,8 @@ class ProductController extends BaseController @@ -79,12 +79,8 @@ class ProductController extends BaseController
79 $query = $query->where('project_id',$this->user['project_id']); 79 $query = $query->where('project_id',$this->user['project_id']);
80 if (isset($this->map['category_id']) && !empty($this->map['category_id'])) { 80 if (isset($this->map['category_id']) && !empty($this->map['category_id'])) {
81 $str = []; 81 $str = [];
82 - $this->getLastLevelIds($this->map['category_id'],$str);  
83 - $query->where(function ($subQuery) use ($str) {  
84 - foreach ($str as $v) {  
85 - $subQuery->orWhereRaw("FIND_IN_SET(?, category_id) > 0", [$v]);  
86 - }  
87 - }); 82 + $this->getAllSub($this->map['category_id'],$str);
  83 + $query = $query->whereIn('category_id',$str);
88 } 84 }
89 if(isset($this->map['title']) && !empty($this->map['title'])){ 85 if(isset($this->map['title']) && !empty($this->map['title'])){
90 $query = $query->where('title','like','%'.$this->map['title'].'%'); 86 $query = $query->where('title','like','%'.$this->map['title'].'%');
@@ -99,24 +95,22 @@ class ProductController extends BaseController @@ -99,24 +95,22 @@ class ProductController extends BaseController
99 } 95 }
100 96
101 /** 97 /**
102 - * @remark :获取当前分类的最后一级id  
103 - * @name :getLastLevelIds 98 + * @remark :获取当前id下所有子集
  99 + * @name :getAllSub
104 * @author :lyh 100 * @author :lyh
105 * @method :post 101 * @method :post
106 - * @time :2023/10/20 15:02 102 + * @time :2023/10/18 15:10
107 */ 103 */
108 - public function getLastLevelIds($id, &$str = []) { 104 + public function getAllSub($id,&$str = []){
109 $cateModel = new Category(); 105 $cateModel = new Category();
110 - $subList = $cateModel->where('pid', $id)->get();  
111 - if ($subList->isEmpty()) {  
112 - // 如果没有子集,将当前 ID 添加到最后一级 ID 数组  
113 - $str[] = $id;  
114 - } else {  
115 - // 如果有子集,继续向下遍历  
116 - foreach ($subList as $v) {  
117 - $this->getLastLevelIds($v->id, $str); 106 + $list = $cateModel->list(['pid'=>$id,'status'=>1],['id','pid']);
  107 + if(!empty($list)){
  108 + foreach ($list as $v){
  109 + $str[] = $v['id'];
  110 + $this->getAllSub($v['id'],$str);
118 } 111 }
119 } 112 }
  113 + return $str;
120 } 114 }
121 115
122 /** 116 /**
@@ -34,7 +34,6 @@ class BlogCategoryLogic extends BaseLogic @@ -34,7 +34,6 @@ class BlogCategoryLogic extends BaseLogic
34 if(isset($this->param['id']) && !empty($this->param['id'])){ 34 if(isset($this->param['id']) && !empty($this->param['id'])){
35 $this->param['alias'] = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_BLOG_CATE, $this->param['id'], $this->user['project_id']); 35 $this->param['alias'] = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_BLOG_CATE, $this->param['id'], $this->user['project_id']);
36 $route = $this->param['alias']; 36 $route = $this->param['alias'];
37 - $this->editHandleCategory($this->param['id'],$this->param['pid']);  
38 $this->param['operator_id'] = $this->user['id']; 37 $this->param['operator_id'] = $this->user['id'];
39 $this->edit($this->param,['id'=>$this->param['id']]); 38 $this->edit($this->param,['id'=>$this->param['id']]);
40 }else{ 39 }else{
@@ -47,8 +46,6 @@ class BlogCategoryLogic extends BaseLogic @@ -47,8 +46,6 @@ class BlogCategoryLogic extends BaseLogic
47 $id = $this->model->addReturnId($this->param); 46 $id = $this->model->addReturnId($this->param);
48 $route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']); 47 $route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']);
49 $this->edit(['alias'=>$route],['id'=>$id]); 48 $this->edit(['alias'=>$route],['id'=>$id]);
50 - //处理子集  
51 - $this->addProcessingSon($id);  
52 } 49 }
53 DB::commit(); 50 DB::commit();
54 }catch (\Exception $e){ 51 }catch (\Exception $e){
@@ -61,48 +58,6 @@ class BlogCategoryLogic extends BaseLogic @@ -61,48 +58,6 @@ class BlogCategoryLogic extends BaseLogic
61 } 58 }
62 59
63 /** 60 /**
64 - * @remark :编辑分类,处理博客数据  
65 - * @name :editCategory  
66 - * @author :lyh  
67 - * @method :post  
68 - * @time :2023/10/20 9:32  
69 - */  
70 - public function editHandleCategory($id,$pid){  
71 - $info = $this->model->read(['id'=>$id],['id','pid']);  
72 - if($info['pid'] != $pid){  
73 - //修改勒上级,先查看上级是否拥有博客  
74 - $blogModel = new BlogModel();  
75 - $blogCount = $blogModel->formatQuery(['category_id'=>['like','%,'.$pid.',%']])->count();  
76 - if($blogCount > 0){  
77 - //随机获取最后一级id  
78 - $replacement = $this->getLastId($id);  
79 - //存在博客时,移动所有博客到当前分类最后一级  
80 - $blogModel->where('category_id', 'like', '%,' . $pid . ',%')->where('category_id', 'like', '%,' . $replacement . ',%')  
81 - ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',')")]);  
82 - $blogModel->where('category_id', 'like', '%,' . $pid . ',%')  
83 - ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',$replacement,')")]);  
84 - }  
85 - }  
86 - return $this->success();  
87 - }  
88 -  
89 - /**  
90 - * @remark :随机获取当前id下最后一级的id  
91 - * @name :getLastId  
92 - * @author :lyh  
93 - * @method :post  
94 - * @time :2023/10/20 9:45  
95 - */  
96 - public function getLastId($id){  
97 - $info = $this->model->read(['pid'=>$id],['id']);  
98 - if($info !== false){  
99 - return $this->getLastId($info['id']);  
100 - }else{  
101 - return $id;  
102 - }  
103 - }  
104 -  
105 - /**  
106 * @name :详情 61 * @name :详情
107 * @return array 62 * @return array
108 * @author :liyuhang 63 * @author :liyuhang
@@ -248,37 +203,6 @@ class BlogCategoryLogic extends BaseLogic @@ -248,37 +203,6 @@ class BlogCategoryLogic extends BaseLogic
248 } 203 }
249 204
250 /** 205 /**
251 - * @param $cate_id  
252 - * @name :(处理子集)addProcessingSon  
253 - * @author :lyh  
254 - * @method :post  
255 - * @time :2023/6/13 11:59  
256 - */  
257 - public function addProcessingSon($cate_id){  
258 - if(!isset($this->param['pid'])){  
259 - $this->param['pid'] = 0;  
260 - }  
261 - //判断为子分类时  
262 - if($this->param['pid'] != 0){  
263 - //查看当前上级分类下是否有其他子分类  
264 - $cate_info = $this->model->read(['pid' => $this->param['pid'], 'id' => ['!=', $cate_id]]);  
265 - if ($cate_info === false) {  
266 - //查看当前上一级分类下是否有新闻  
267 - $blogModel = new BlogModel();  
268 - $blog_count = $blogModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count();  
269 - if ($blog_count > 0) {  
270 - $replacement = ',' . $cate_id . ',';  
271 - $old = ',' . $this->param['pid'] . ',';  
272 - //更新所有商品到当前分类  
273 - $blogModel->where('category_id', 'like', '%' . $old . '%')  
274 - ->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]);  
275 - }  
276 - }  
277 - }  
278 - return $this->success();  
279 - }  
280 -  
281 - /**  
282 * @remark :删除路由 206 * @remark :删除路由
283 * @name :delRoute 207 * @name :delRoute
284 * @author :lyh 208 * @author :lyh
@@ -322,7 +246,7 @@ class BlogCategoryLogic extends BaseLogic @@ -322,7 +246,7 @@ class BlogCategoryLogic extends BaseLogic
322 $pid = $id; 246 $pid = $id;
323 } 247 }
324 } 248 }
325 - return $this->getLastCategory($return); 249 + return $this->getCategory($return);
326 } 250 }
327 251
328 /** 252 /**
@@ -332,15 +256,12 @@ class BlogCategoryLogic extends BaseLogic @@ -332,15 +256,12 @@ class BlogCategoryLogic extends BaseLogic
332 * @method :post 256 * @method :post
333 * @time :2023/10/20 9:02 257 * @time :2023/10/20 9:02
334 */ 258 */
335 - public function getLastCategory($category){ 259 + public function getCategory($category){
336 $str = ''; 260 $str = '';
337 foreach ($category as $v){ 261 foreach ($category as $v){
338 - $info = $this->model->read(['pid'=>$v]);  
339 - if($info === false){  
340 $str .= $v.','; 262 $str .= $v.',';
341 } 263 }
342 - }  
343 - return ','.$str; 264 + return !empty($str) ? ','.$str : '';
344 } 265 }
345 266
346 /** 267 /**
@@ -46,7 +46,6 @@ class NewsCategoryLogic extends BaseLogic @@ -46,7 +46,6 @@ class NewsCategoryLogic extends BaseLogic
46 if(isset($this->param['id']) && !empty($this->param['id'])){ 46 if(isset($this->param['id']) && !empty($this->param['id'])){
47 $this->param['alias'] = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $this->param['id'], $this->user['project_id']); 47 $this->param['alias'] = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $this->param['id'], $this->user['project_id']);
48 $route = $this->param['alias']; 48 $route = $this->param['alias'];
49 - $this->editHandleCategory($this->param['id'],$this->param['pid']);  
50 $this->param['operator_id'] = $this->user['id']; 49 $this->param['operator_id'] = $this->user['id'];
51 $this->edit($this->param,['id'=>$this->param['id']]); 50 $this->edit($this->param,['id'=>$this->param['id']]);
52 }else{ 51 }else{
@@ -57,8 +56,6 @@ class NewsCategoryLogic extends BaseLogic @@ -57,8 +56,6 @@ class NewsCategoryLogic extends BaseLogic
57 $id = $this->model->addReturnId($this->param); 56 $id = $this->model->addReturnId($this->param);
58 $route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']); 57 $route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
59 $this->model->edit(['alias'=>$route],['id'=>$id]); 58 $this->model->edit(['alias'=>$route],['id'=>$id]);
60 - //当父级分类拥有产品时,处理子集  
61 - $this->addProcessingSon($id);  
62 } 59 }
63 DB::commit(); 60 DB::commit();
64 }catch (\Exception $e){ 61 }catch (\Exception $e){
@@ -71,49 +68,6 @@ class NewsCategoryLogic extends BaseLogic @@ -71,49 +68,6 @@ class NewsCategoryLogic extends BaseLogic
71 } 68 }
72 69
73 /** 70 /**
74 - * @remark :编辑分类,处理博客数据  
75 - * @name :editCategory  
76 - * @author :lyh  
77 - * @method :post  
78 - * @time :2023/10/20 9:32  
79 - */  
80 - public function editHandleCategory($id,$pid){  
81 - $info = $this->model->read(['id'=>$id],['id','pid']);  
82 - if($info['pid'] != $pid){  
83 - //修改勒上级,先查看上级是否拥有博客  
84 - $newsModel = new NewsModel();  
85 - $newsCount = $newsModel->formatQuery(['category_id'=>['like','%,'.$pid.',%']])->count();  
86 - //随机获取最后一级id  
87 - $replacement = $this->getLastId($id);  
88 - if($newsCount > 0){  
89 - //存在博客时,移动所有博客到当前分类最后一级  
90 - $newsModel->where('category_id', 'like', '%,' . $pid . ',%')->where('category_id', 'like', '%,' . $replacement . ',%')  
91 - ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',')")]);  
92 - $newsModel->where('category_id', 'like', '%,' . $pid . ',%')  
93 - ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',$replacement,')")]);  
94 - }  
95 - }  
96 - return $this->success();  
97 - }  
98 -  
99 - /**  
100 - * @remark :随机获取当前id下最后一级的id  
101 - * @name :getLastId  
102 - * @author :lyh  
103 - * @method :post  
104 - * @time :2023/10/20 9:45  
105 - */  
106 - public function getLastId($id){  
107 - $info = $this->model->read(['pid'=>$id],['id']);  
108 - if($info !== false){  
109 - return $this->getLastId($info['id']);  
110 - }else{  
111 - return $id;  
112 - }  
113 - }  
114 -  
115 -  
116 - /**  
117 * @remark :修改状态 71 * @remark :修改状态
118 * @name :status_news_category 72 * @name :status_news_category
119 * @author :lyh 73 * @author :lyh
@@ -231,36 +185,6 @@ class NewsCategoryLogic extends BaseLogic @@ -231,36 +185,6 @@ class NewsCategoryLogic extends BaseLogic
231 } 185 }
232 186
233 /** 187 /**
234 - * @name :(添加分类时处理子集分类)addProcessingSon  
235 - * @author :lyh  
236 - * @method :post  
237 - * @time :2023/6/13 11:34  
238 - */  
239 - public function addProcessingSon($cate_id){  
240 - if(isset($this->param['pid']) && !empty($this->param['pid'])) {  
241 - $this->param['pid'] = 0;  
242 - }  
243 - //判断为子分类时  
244 - if($this->param['pid'] != 0) {  
245 - //查看当前上级分类下是否有其他分类  
246 - $cate_info = $this->model->read(['pid' => $this->param['pid'], 'id' => ['!=', $cate_id]]);  
247 - if ($cate_info === false) {  
248 - //查看当前上一级分类下是否有新闻  
249 - $newsModel = new NewsModel();  
250 - $news_count = $newsModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count();  
251 - if ($news_count > 0) {  
252 - $replacement = ',' . $cate_id . ',';  
253 - $old = ',' . $this->param['pid'] . ',';  
254 - //更新所有商品到当前分类  
255 - $newsModel->where('category_id', 'like', '%' . $old . '%')  
256 - ->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]);  
257 - }  
258 - }  
259 - }  
260 - return $this->success();  
261 - }  
262 -  
263 - /**  
264 * @remark :删除路由 188 * @remark :删除路由
265 * @name :delRoute 189 * @name :delRoute
266 * @author :lyh 190 * @author :lyh
@@ -303,7 +227,7 @@ class NewsCategoryLogic extends BaseLogic @@ -303,7 +227,7 @@ class NewsCategoryLogic extends BaseLogic
303 $pid = $id; 227 $pid = $id;
304 } 228 }
305 } 229 }
306 - return $this->getLastCategory($return); 230 + return $this->getCategory($return);
307 } 231 }
308 232
309 /** 233 /**
@@ -313,15 +237,12 @@ class NewsCategoryLogic extends BaseLogic @@ -313,15 +237,12 @@ class NewsCategoryLogic extends BaseLogic
313 * @method :post 237 * @method :post
314 * @time :2023/10/20 9:02 238 * @time :2023/10/20 9:02
315 */ 239 */
316 - public function getLastCategory($category){ 240 + public function getCategory($category){
317 $str = ''; 241 $str = '';
318 foreach ($category as $v){ 242 foreach ($category as $v){
319 - $info = $this->model->read(['pid'=>$v]);  
320 - if($info === false){  
321 $str .= $v.','; 243 $str .= $v.',';
322 } 244 }
323 - }  
324 - return ','.$str; 245 + return !empty($str) ? ','.$str : '';
325 } 246 }
326 247
327 /** 248 /**
@@ -167,36 +167,32 @@ class NewsLogic extends BaseLogic @@ -167,36 +167,32 @@ class NewsLogic extends BaseLogic
167 if(isset($this->param['id'])){ 167 if(isset($this->param['id'])){
168 $param['operator_id'] = $this->user['id']; 168 $param['operator_id'] = $this->user['id'];
169 if(isset($param['category_id']) && !empty($param['category_id'])){ 169 if(isset($param['category_id']) && !empty($param['category_id'])){
170 - $param['category_id'] = $this->getLastCategory($param['category_id']); 170 + $param['category_id'] = $this->getCategory($param['category_id']);
171 } 171 }
172 }else{ 172 }else{
173 $param['create_id'] = $this->user['id']; 173 $param['create_id'] = $this->user['id'];
174 $param['operator_id'] = $this->user['id']; 174 $param['operator_id'] = $this->user['id'];
175 $param['project_id'] = $this->user['project_id']; 175 $param['project_id'] = $this->user['project_id'];
176 if(isset($param['category_id']) && !empty($param['category_id'])){ 176 if(isset($param['category_id']) && !empty($param['category_id'])){
177 - $param['category_id'] = $this->getLastCategory($param['category_id']); 177 + $param['category_id'] = $this->getCategory($param['category_id']);
178 } 178 }
179 } 179 }
180 return $this->success($param); 180 return $this->success($param);
181 } 181 }
182 182
183 /** 183 /**
184 - * @remark :获取最后一级分类id 184 + * @remark :获取分类(字符串)
185 * @name :getLastCategory 185 * @name :getLastCategory
186 * @author :lyh 186 * @author :lyh
187 * @method :post 187 * @method :post
188 * @time :2023/10/20 9:02 188 * @time :2023/10/20 9:02
189 */ 189 */
190 - public function getLastCategory($category){ 190 + public function getCategory($category){
191 $str = ''; 191 $str = '';
192 - $cateModel = new NewsCategoryModel();  
193 foreach ($category as $v){ 192 foreach ($category as $v){
194 - $info = $cateModel->read(['pid'=>$v]);  
195 - if($info === false){  
196 $str .= $v.','; 193 $str .= $v.',';
197 } 194 }
198 - }  
199 - return ','.$str; 195 + return !empty($str) ? ','.$str : '';
200 } 196 }
201 197
202 /** 198 /**