正在显示
3 个修改的文件
包含
36 行增加
和
9 行删除
| @@ -29,6 +29,7 @@ class CustomModuleCategoryController extends BaseController | @@ -29,6 +29,7 @@ class CustomModuleCategoryController extends BaseController | ||
| 29 | 'module_id.required' => 'module_id不能为空', | 29 | 'module_id.required' => 'module_id不能为空', |
| 30 | ]); | 30 | ]); |
| 31 | $this->map['project_id'] = $this->user['project_id']; | 31 | $this->map['project_id'] = $this->user['project_id']; |
| 32 | + $this->map['status'] = 0; | ||
| 32 | $lists = $customModuleCategory->lists($this->map,$this->page,$this->row,$this->order); | 33 | $lists = $customModuleCategory->lists($this->map,$this->page,$this->row,$this->order); |
| 33 | $this->response('success',Code::SUCCESS,$lists); | 34 | $this->response('success',Code::SUCCESS,$lists); |
| 34 | } | 35 | } |
| @@ -73,11 +74,13 @@ class CustomModuleCategoryController extends BaseController | @@ -73,11 +74,13 @@ class CustomModuleCategoryController extends BaseController | ||
| 73 | $this->request->validate([ | 74 | $this->request->validate([ |
| 74 | 'name'=>['required'], | 75 | 'name'=>['required'], |
| 75 | 'route'=>['required'], | 76 | 'route'=>['required'], |
| 76 | - 'module_id'=>['required'] | 77 | + 'module_id'=>['required'], |
| 78 | + 'pid'=>['required'] | ||
| 77 | ],[ | 79 | ],[ |
| 78 | 'name.required' => '分类名称不能为空', | 80 | 'name.required' => '分类名称不能为空', |
| 79 | 'route.required' => '分类路由不能为空', | 81 | 'route.required' => '分类路由不能为空', |
| 80 | - 'module_id.required' => '所选模块id不能为空' | 82 | + 'module_id.required' => '所选模块id不能为空', |
| 83 | + 'pid.required' => '上级不能为空' | ||
| 81 | ]); | 84 | ]); |
| 82 | $logic->categorySave(); | 85 | $logic->categorySave(); |
| 83 | $this->response('success'); | 86 | $this->response('success'); |
| @@ -32,6 +32,7 @@ class CustomModuleController extends BaseController | @@ -32,6 +32,7 @@ class CustomModuleController extends BaseController | ||
| 32 | */ | 32 | */ |
| 33 | public function lists(CustomModule $customModule){ | 33 | public function lists(CustomModule $customModule){ |
| 34 | $this->map['project_id'] = $this->user['project_id']; | 34 | $this->map['project_id'] = $this->user['project_id']; |
| 35 | + $this->map['status'] = 0; | ||
| 35 | $lists = $customModule->lists($this->map,$this->page,$this->row,$this->order); | 36 | $lists = $customModule->lists($this->map,$this->page,$this->row,$this->order); |
| 36 | $this->response('success',Code::SUCCESS,$lists); | 37 | $this->response('success',Code::SUCCESS,$lists); |
| 37 | } | 38 | } |
| @@ -268,14 +268,37 @@ class CustomModuleCategoryLogic extends BaseLogic | @@ -268,14 +268,37 @@ class CustomModuleCategoryLogic extends BaseLogic | ||
| 268 | * @time :2023/12/4 15:47 | 268 | * @time :2023/12/4 15:47 |
| 269 | */ | 269 | */ |
| 270 | public function categoryDel(){ | 270 | public function categoryDel(){ |
| 271 | - $info = $this->model->read(['pid' => $this->param['id']], ['id', 'route']); | ||
| 272 | - if($info === false){ | ||
| 273 | - $this->fail('当前分类拥有下级'); | ||
| 274 | - } | ||
| 275 | - $rs = $this->model->del($this->param); | ||
| 276 | - if($rs === false){ | ||
| 277 | - $this->fail('系统错误,请连续管理员'); | 271 | + $ids = $this->param['id']; |
| 272 | + foreach ($ids as $id){ | ||
| 273 | + $info = $this->model->read(['pid'=>$id],['id']); | ||
| 274 | + if($info !== false){ | ||
| 275 | + $this->fail('分类id:'.$id.'拥有子集不允许删除'); | ||
| 276 | + } | ||
| 277 | + $contentModel = new CustomModuleContent(); | ||
| 278 | + $contentInfo = $contentModel->read(['category_id'=>['like','%,'.$id.',%']]); | ||
| 279 | + if($contentInfo !== false){ | ||
| 280 | + $this->fail('当前分类拥有产品不允许删除'); | ||
| 281 | + } | ||
| 282 | + //删除路由 | ||
| 283 | + $this->delRoute($id); | ||
| 284 | + $this->model->del(['id'=>$id]); | ||
| 278 | } | 285 | } |
| 279 | return $this->success(); | 286 | return $this->success(); |
| 280 | } | 287 | } |
| 288 | + | ||
| 289 | + /** | ||
| 290 | + * @remark :删除路由 | ||
| 291 | + * @name :delRoute | ||
| 292 | + * @author :lyh | ||
| 293 | + * @method :post | ||
| 294 | + * @time :2023/9/7 10:50 | ||
| 295 | + */ | ||
| 296 | + public function delRoute($id) | ||
| 297 | + { | ||
| 298 | + RouteMap::delRoute(RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'], $id, $this->user['project_id']); | ||
| 299 | + //通知 | ||
| 300 | + $info = $this->model->read(['id' => $id], ['id', 'route']); | ||
| 301 | + $this->curlDelRoute(['route'=>$info['route']]); | ||
| 302 | + return $this->success(); | ||
| 303 | + } | ||
| 281 | } | 304 | } |
-
请 注册 或 登录 后发表评论