作者 lyh

gx

@@ -58,15 +58,20 @@ class NavController extends BaseController @@ -58,15 +58,20 @@ class NavController extends BaseController
58 58
59 59
60 /** 60 /**
61 - * 删除数据  
62 - * @return \Illuminate\Http\JsonResponse  
63 - * @author:dc  
64 - * @time 2023/5/9 9:20 61 + * @remark :删除菜单
  62 + * @name :delete
  63 + * @author :lyh
  64 + * @method :post
  65 + * @time :2023/8/23 11:09
65 */ 66 */
66 - public function delete(NavRequest $request){  
67 - $id = $request->validated()['id'];  
68 - NavLogic::instance()->delete($id);  
69 - return $this->response('删除成功'); 67 + public function delete(NavLogic $logic){
  68 + $this->request->validate([
  69 + 'id'=>'required',
  70 + ],[
  71 + 'id.required' => '产品ID不能为空',
  72 + ]);
  73 + $logic->navDelete();
  74 + $this->response('success');
70 75
71 } 76 }
72 77
@@ -46,21 +46,24 @@ class NavLogic extends BaseLogic @@ -46,21 +46,24 @@ class NavLogic extends BaseLogic
46 } 46 }
47 47
48 /** 48 /**
49 - * @param $ids  
50 - * @return array  
51 - * @throws \App\Exceptions\AsideGlobalException  
52 - * @throws \App\Exceptions\BsideGlobalException  
53 - * @author:dc  
54 - * @time 2023/5/11 16:59 49 + * @remark :删除菜单
  50 + * @name :navDelete
  51 + * @author :lyh
  52 + * @method :post
  53 + * @time :2023/8/23 11:12
55 */ 54 */
56 - public function delete($ids,$map = []) 55 + public function navDelete()
57 { 56 {
58 - if(BNav::isChild($ids,$this->user['project_id'])){  
59 - $this->fail('存在下级无法删除'); 57 + //判断当前菜单是否拥有下级
  58 + $info = $this->model->read(['id'=>$this->param['id']]);
  59 + if($info !== false){
  60 + $this->fail('当前菜单存在下级,不允许删除');
60 } 61 }
61 -  
62 - return parent::delete($ids,$map); // TODO: Change the autogenerated stub  
63 - 62 + $rs = $this->model->del($this->param);
  63 + if($rs === false){
  64 + $this->fail('error');
  65 + }
  66 + return $this->success();
64 } 67 }
65 68
66 69