ProjectMenuLogic.php
2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
namespace App\Http\Logic\Aside\User;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\User\ProjectMenu;
class ProjectMenuLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new ProjectMenu();
$this->param = $this->requestAll;
}
/**
* @name :获取详情
* @return void
* @author :liyuhang
* @method
*/
public function menu_info(){
$info = $this->info($this->param);
return $this->success($info);
}
/**
* @name :添加菜单
* @return void
* @author :liyuhang
* @method
*/
public function menu_add(){
//查询当前名称是否存在
$info = $this->model->read(['name'=>$this->param['name']]);
if($info !== false){
$this->fail('当前菜单名称已存在');
}
$rs = $this->model->add($this->param);
if($rs === false){
$this->fail('添加失败');
}
return $this->success();
}
/**
* @name :编辑菜单
* @return void
* @author :liyuhang
* @method
*/
public function menu_edit(){
//查询当前名称是否存在
$info = $this->model->read(['name'=>$this->param['name'],'id'=>['!=',$this->param['id']]]);
if($info !== false){
$this->fail('当前菜单名称已存在');
}
$this->edit($this->param,['id'=>$this->param['id']]);
return $this->success();
}
/**
* @name :删除菜单
* @return void
* @author :liyuhang
* @method
*/
public function menu_del(){
$ids = $this->param['id'];
//查看当前菜单是否有子菜单
foreach ($ids as $v){
$info = $this->model->read(['pid'=>$v],['id','name']);
if($info !== false){
$this->fail('当前分类存在子分类:'.$info['name'].',不允许删除');
}
}
$this->param['id'] = ['in',$this->param['id']];
$rs = $this->del($this->param);
if($rs === false){
$this->fail('编辑失败');
}
return $this->success();
}
/**
* @remark :添加时获取菜单列表
* @name :MenuList
* @author :lyh
* @method :post
* @time :2023/6/21 17:26
*/
public function MenuList(){
$lists = $this->model->list(['status'=>$this->model::ZERO,'is_role'=>$this->model::ZERO,'pid'=>$this->model::ZERO],'created_at');
return $this->success($lists);
}
/**
* @remark :当前菜单下的所有权限子菜单
* @name :roleMenuInfo
* @author :lyh
* @method :post
* @time :2023/8/2 16:24
*/
public function roleMenuInfo(){
$list = $this->model->list(['pid'=>$this->param['id'], 'is_role'=>1]);
return $this->success($list);
}
}