作者 lyh

gx

@@ -41,12 +41,9 @@ class ProductController extends BaseController @@ -41,12 +41,9 @@ class ProductController extends BaseController
41 public function index(Product $product) 41 public function index(Product $product)
42 { 42 {
43 $this->map = $this->searchParam(); 43 $this->map = $this->searchParam();
44 -  
45 $filed = ['id', 'project_id', 'title', 'sort' ,'thumb', 'gallery' ,'product_type' , 'route' , 44 $filed = ['id', 'project_id', 'title', 'sort' ,'thumb', 'gallery' ,'product_type' , 'route' ,
46 'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at']; 45 'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at'];
47 -  
48 $lists = $product->product_lists($this->map,$this->page,$this->row,$this->order = ['sort','id'],$filed); 46 $lists = $product->product_lists($this->map,$this->page,$this->row,$this->order = ['sort','id'],$filed);
49 -  
50 if(!empty($lists) && !empty($lists['list'])){ 47 if(!empty($lists) && !empty($lists['list'])){
51 $cate_data = $this->getCategoryList();//分类 48 $cate_data = $this->getCategoryList();//分类
52 $key_data = $this->getKeywordsList();//关键字 49 $key_data = $this->getKeywordsList();//关键字
@@ -96,7 +96,7 @@ class BlogCategoryLogic extends BaseLogic @@ -96,7 +96,7 @@ class BlogCategoryLogic extends BaseLogic
96 } 96 }
97 //查询当前分类下是否有商品 97 //查询当前分类下是否有商品
98 $blogModel = new BlogModel(); 98 $blogModel = new BlogModel();
99 - $info = $blogModel->read(['id'=>['like','%,'.$id.',%']]); 99 + $info = $blogModel->read(['id'=>['like','%,'.$id.',%']],['id']);
100 if($info !== false){ 100 if($info !== false){
101 $this->fail('当前分类下已存在博客,请先把博客移除当前分类,在修改'); 101 $this->fail('当前分类下已存在博客,请先把博客移除当前分类,在修改');
102 } 102 }
@@ -160,7 +160,7 @@ class BlogCategoryLogic extends BaseLogic @@ -160,7 +160,7 @@ class BlogCategoryLogic extends BaseLogic
160 } 160 }
161 //查看当前分内下是否有博客 161 //查看当前分内下是否有博客
162 $blogModel = new BlogModel(); 162 $blogModel = new BlogModel();
163 - $rs = $blogModel->read(['category_id'=>$id],['id']); 163 + $rs = $blogModel->read(['category_id'=>['like','%,'.$id.',%']],['id']);
164 if($rs !== false){ 164 if($rs !== false){
165 $this->response('当前分类拥有博客,不允许删除'); 165 $this->response('当前分类拥有博客,不允许删除');
166 } 166 }
@@ -39,11 +39,11 @@ class NewsCategoryLogic extends BaseLogic @@ -39,11 +39,11 @@ class NewsCategoryLogic extends BaseLogic
39 } 39 }
40 40
41 /** 41 /**
42 - * @name :详情  
43 - * @return array  
44 - * @throws \App\Exceptions\BsideGlobalException  
45 - * @author :liyuhang  
46 - * @method 42 + * @remark :获取详情
  43 + * @name :info_news_category
  44 + * @author :lyh
  45 + * @method :post
  46 + * @time :2023/10/19 16:04
47 */ 47 */
48 public function info_news_category(){ 48 public function info_news_category(){
49 $info = $this->model->read($this->param); 49 $info = $this->model->read($this->param);
@@ -118,9 +118,6 @@ class NewsCategoryLogic extends BaseLogic @@ -118,9 +118,6 @@ class NewsCategoryLogic extends BaseLogic
118 */ 118 */
119 public function verifyEditParam($id,$pid){ 119 public function verifyEditParam($id,$pid){
120 $info = $this->model->read(['id'=>$id]); 120 $info = $this->model->read(['id'=>$id]);
121 - if($info['id'] == $pid){  
122 - $this->fail('不能成为自己的上级');  
123 - }  
124 if($info['pid'] != $pid){ 121 if($info['pid'] != $pid){
125 $info = $this->model->read(['pid'=>$id]); 122 $info = $this->model->read(['pid'=>$id]);
126 if($info !== false){ 123 if($info !== false){
@@ -166,7 +163,7 @@ class NewsCategoryLogic extends BaseLogic @@ -166,7 +163,7 @@ class NewsCategoryLogic extends BaseLogic
166 $newsModel = new NewsModel(); 163 $newsModel = new NewsModel();
167 $rs = $newsModel->read(['category_id'=>$id],['id']); 164 $rs = $newsModel->read(['category_id'=>$id],['id']);
168 if($rs !== false){ 165 if($rs !== false){
169 - $this->fail('当前分类拥有商品'); 166 + $this->fail('当前分类拥有商品,不允许删除');
170 } 167 }
171 $this->delRoute($id); 168 $this->delRoute($id);
172 $this->model->del(['id'=>$id]); 169 $this->model->del(['id'=>$id]);
@@ -181,13 +178,44 @@ class NewsCategoryLogic extends BaseLogic @@ -181,13 +178,44 @@ class NewsCategoryLogic extends BaseLogic
181 * @time :2023/6/13 9:09 178 * @time :2023/6/13 9:09
182 */ 179 */
183 public function categoryTopList(){ 180 public function categoryTopList(){
184 - $map = [  
185 - 'project_id'=>$this->user['project_id'],  
186 - 'pid'=>0,  
187 - 'status'=>0,  
188 - ];  
189 - $list = $this->model->list($map);  
190 - return $this->success($list); 181 + $this->param['project_id'] = $this->user['project_id'];
  182 + $this->param['status'] = 0;
  183 + if(isset($this->param['id']) && !empty($this->param['id'])){
  184 + $str = [];
  185 + //排序掉当前id下所有子集
  186 + $str = $this->getAllSub($this->param['id'],$str);
  187 + $str[] = (int)$this->param['id'];
  188 + $this->param['id'] = ['not in',$str];
  189 + }
  190 + $menu = array();
  191 + $list = $this->model->list($this->param);
  192 + if(!empty($list)){
  193 + foreach ($list as $k => $v){
  194 + if($v['pid'] == 0){
  195 + $v['sub'] = _get_child($v['id'],$list);
  196 + $menu[] = $v;
  197 + }
  198 + }
  199 + }
  200 + return $this->success($menu);
  201 + }
  202 +
  203 + /**
  204 + * @remark :获取当前id下所有子集
  205 + * @name :getAllSub
  206 + * @author :lyh
  207 + * @method :post
  208 + * @time :2023/10/18 15:10
  209 + */
  210 + public function getAllSub($id,&$str = []){
  211 + $list = $this->model->list(['pid'=>$id,'status'=>0],['id','pid']);
  212 + if(!empty($list)){
  213 + foreach ($list as $v){
  214 + $str[] = $v['id'];
  215 + $this->getAllSub($v['id'],$str);
  216 + }
  217 + }
  218 + return $str;
191 } 219 }
192 220
193 /** 221 /**
@@ -66,10 +66,10 @@ class CategoryLogic extends BaseLogic @@ -66,10 +66,10 @@ class CategoryLogic extends BaseLogic
66 * @time :2023/8/21 17:14 66 * @time :2023/8/21 17:14
67 */ 67 */
68 public function categorySave(){ 68 public function categorySave(){
69 - $this->handleEditParam($this->param);  
70 DB::beginTransaction(); 69 DB::beginTransaction();
71 try { 70 try {
72 if(isset($this->param['id']) && !empty($this->param['id'])){ 71 if(isset($this->param['id']) && !empty($this->param['id'])){
  72 + $this->handleEditParam($this->param);
73 //是否编辑路由 73 //是否编辑路由
74 $id = $this->editCategoryRoute($this->param['id'],$this->param['route']); 74 $id = $this->editCategoryRoute($this->param['id'],$this->param['route']);
75 $this->model->edit($this->param,['id'=>$this->param['id']]); 75 $this->model->edit($this->param,['id'=>$this->param['id']]);
@@ -125,6 +125,11 @@ class CategoryLogic extends BaseLogic @@ -125,6 +125,11 @@ class CategoryLogic extends BaseLogic
125 if(in_array($param['pid'], $category_ids)){ 125 if(in_array($param['pid'], $category_ids)){
126 $this->fail('上级分类不能是本分类或子分类'); 126 $this->fail('上级分类不能是本分类或子分类');
127 } 127 }
  128 + $productModel = new Product();
  129 + $rs = $productModel->read(['category_id'=>['like','%,'.$param['id'].',%']],['id']);
  130 + if($rs !== false){
  131 + $this->response('当前分类拥有产品,不允许修改级别');
  132 + }
128 return $this->success(); 133 return $this->success();
129 } 134 }
130 135