ProjectMenuLogic.php
3.4 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?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->model->read($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->model->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->model->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($map){
$lists = $this->model->list($map,'sort');
$menu = array();
foreach ($lists as $k => $v){
$v = (array)$v;
if ($v['pid'] == 0) {
$v['sub'] = _get_child($v['id'], $lists);
$menu[] = $v;
}
}
return $this->success($menu);
}
/**
* @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);
}
/**
* @remark :设置排序
* @name :setSort
* @author :lyh
* @method :post
* @time :2023/8/10 16:42
*/
public function setParamStatus(){
$rs = $this->model->edit(['sort'=>$this->param['sort']],['id'=>$this->param['id']]);
if($rs === false){
$this->fail('修改失败');
}
return $this->success();
}
}