作者 lyh

gx

@@ -11,6 +11,7 @@ namespace App\Http\Logic\Bside\CustomModule; @@ -11,6 +11,7 @@ namespace App\Http\Logic\Bside\CustomModule;
11 11
12 use App\Http\Logic\Bside\BaseLogic; 12 use App\Http\Logic\Bside\BaseLogic;
13 use App\Models\CustomModule\CustomModuleCategory; 13 use App\Models\CustomModule\CustomModuleCategory;
  14 +use App\Models\CustomModule\CustomModuleContent;
14 use App\Models\RouteMap\RouteMap; 15 use App\Models\RouteMap\RouteMap;
15 16
16 class CustomModuleCategoryLogic extends BaseLogic 17 class CustomModuleCategoryLogic extends BaseLogic
@@ -41,7 +42,7 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -41,7 +42,7 @@ class CustomModuleCategoryLogic extends BaseLogic
41 $menu = array(); 42 $menu = array();
42 $list = $this->model->list($this->param); 43 $list = $this->model->list($this->param);
43 if(!empty($list)){ 44 if(!empty($list)){
44 - foreach ($list as $k => $v){ 45 + foreach ($list as $v){
45 if($v['pid'] == 0){ 46 if($v['pid'] == 0){
46 $v['sub'] = _get_child($v['id'],$list); 47 $v['sub'] = _get_child($v['id'],$list);
47 $menu[] = $v; 48 $menu[] = $v;
@@ -110,7 +111,9 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -110,7 +111,9 @@ class CustomModuleCategoryLogic extends BaseLogic
110 public function categoryAdd(){ 111 public function categoryAdd(){
111 try { 112 try {
112 $id = $this->model->addReturnId($this->param); 113 $id = $this->model->addReturnId($this->param);
113 - $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'], $id, $this->user['project_id']); 114 + $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],
  115 + $id, $this->user['project_id']);
  116 + $this->handleAddSon($id);
114 $this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],$route); 117 $this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],$route);
115 $this->edit(['url' => $route], ['id' => $id]); 118 $this->edit(['url' => $route], ['id' => $id]);
116 }catch (\Exception $e){ 119 }catch (\Exception $e){
@@ -127,7 +130,8 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -127,7 +130,8 @@ class CustomModuleCategoryLogic extends BaseLogic
127 * @time :2023/12/5 10:55 130 * @time :2023/12/5 10:55
128 */ 131 */
129 public function categoryEdit(){ 132 public function categoryEdit(){
130 - $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'], $this->param['id'], $this->user['project_id']); 133 + $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],
  134 + $this->param['id'], $this->user['project_id']);
131 $this->editNewsRoute($this->param['id'],$route); 135 $this->editNewsRoute($this->param['id'],$route);
132 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); 136 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
133 if($rs === false){ 137 if($rs === false){
@@ -160,24 +164,23 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -160,24 +164,23 @@ class CustomModuleCategoryLogic extends BaseLogic
160 * @method :post 164 * @method :post
161 * @time :2023/6/13 11:34 165 * @time :2023/6/13 11:34
162 */ 166 */
163 - public function addProcessingSon($cate_id){ 167 + public function handleAddSon($cate_id){
164 if(isset($this->param['pid']) && !empty($this->param['pid'])) { 168 if(isset($this->param['pid']) && !empty($this->param['pid'])) {
165 $this->param['pid'] = 0; 169 $this->param['pid'] = 0;
166 } 170 }
167 //判断为子分类时 171 //判断为子分类时
168 if($this->param['pid'] != 0) { 172 if($this->param['pid'] != 0) {
169 //查看当前上级分类下是否有其他分类 173 //查看当前上级分类下是否有其他分类
170 - $cate_info = $this->model->read(['pid' => $this->param['pid'], 'id' => ['!=', $cate_id]]); 174 + $cate_info = $this->model->read(['pid' => $this->param['pid'], 'id' => ['!=', $cate_id]],['id']);
171 if ($cate_info === false) { 175 if ($cate_info === false) {
172 //查看当前上一级分类下是否有关联模块内容 176 //查看当前上一级分类下是否有关联模块内容
173 - $newsModel = new NewsModel();  
174 - $news_count = $newsModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count(); 177 + $contentModel = new CustomModuleContent();
  178 + $news_count = $contentModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count();
175 if ($news_count > 0) { 179 if ($news_count > 0) {
176 - $replacement = ',' . $cate_id . ',';  
177 - $old = ',' . $this->param['pid'] . ','; 180 + $replacement = $this->handleStr($cate_id);
  181 + $old = $this->handleStr($this->param['pid']);
178 //更新所有商品到当前分类 182 //更新所有商品到当前分类
179 - $newsModel->where('category_id', 'like', '%' . $old . '%')  
180 - ->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]); 183 + $contentModel->where('category_id', 'like', '%' . $old . '%')->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]);
181 } 184 }
182 } 185 }
183 } 186 }
@@ -185,6 +188,17 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -185,6 +188,17 @@ class CustomModuleCategoryLogic extends BaseLogic
185 } 188 }
186 189
187 /** 190 /**
  191 + * @remark :处理字符串
  192 + * @name :handleStr
  193 + * @author :lyh
  194 + * @method :post
  195 + * @time :2023/12/5 18:03
  196 + */
  197 + public function handleStr($str){
  198 + return ',' . $str . ',';
  199 + }
  200 +
  201 + /**
188 * @remark :删除数据 202 * @remark :删除数据
189 * @name :ModuleDel 203 * @name :ModuleDel
190 * @author :lyh 204 * @author :lyh