正在显示
6 个修改的文件
包含
137 行增加
和
1 行删除
@@ -4,6 +4,9 @@ namespace app\api\controller; | @@ -4,6 +4,9 @@ namespace app\api\controller; | ||
4 | 4 | ||
5 | use app\admin\controller\Base; | 5 | use app\admin\controller\Base; |
6 | use app\admin\model\Manager as ManagerModel; | 6 | use app\admin\model\Manager as ManagerModel; |
7 | +use app\admin\model\Menu as MenuModel; | ||
8 | +use app\admin\model\Role as RoleModel; | ||
9 | +use think\Cache; | ||
7 | use think\Validate; | 10 | use think\Validate; |
8 | 11 | ||
9 | /** | 12 | /** |
@@ -159,4 +162,23 @@ class Manager extends Base | @@ -159,4 +162,23 @@ class Manager extends Base | ||
159 | $this->response('成功',200,[]);; | 162 | $this->response('成功',200,[]);; |
160 | } | 163 | } |
161 | } | 164 | } |
165 | + | ||
166 | + /** | ||
167 | + * @name :获取当前用户菜单列表 | ||
168 | + * @return void | ||
169 | + * @author :liyuhang | ||
170 | + * @method : get | ||
171 | + */ | ||
172 | + public function get_menu(){ | ||
173 | + //获取当前用户角色 | ||
174 | + $roleModel = new RoleModel(); | ||
175 | + $role_info = $roleModel->read(['id'=>$this->user['role_id']]); | ||
176 | + //根据当前角色获取当前菜单栏 | ||
177 | + $menuModel = new MenuModel(); | ||
178 | + $menu_lists = $menuModel->where(['pid'=>0,'status'=>1,'deleted'=>1])->where('id','in',$role_info['menu'])->select()->toArray(); | ||
179 | + foreach ($menu_lists as $k => $v){ | ||
180 | + $menu_lists[$k]['son'] = $menuModel->where(['pid'=>$v['id'],'status'=>1,'deleted'=>1])->where('id','in',$role_info['menu'])->select()->toArray(); | ||
181 | + } | ||
182 | + $this->response('当前用户菜单列表',200,$menu_lists); | ||
183 | + } | ||
162 | } | 184 | } |
application/admin/controller/Menu.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace app\api\controller; | ||
4 | + | ||
5 | +use app\admin\controller\Base; | ||
6 | + | ||
7 | +class Menu extends Base | ||
8 | +{ | ||
9 | + /** | ||
10 | + * @name 菜单列表 | ||
11 | + * @return void | ||
12 | + * @author :liyuhang | ||
13 | + * @method | ||
14 | + */ | ||
15 | + public function lists(){} | ||
16 | + | ||
17 | + /** | ||
18 | + * @name :新增菜单 | ||
19 | + * @return void | ||
20 | + * @author :liyuhang | ||
21 | + * @method | ||
22 | + */ | ||
23 | + public function add(){} | ||
24 | + | ||
25 | + /** | ||
26 | + * @name:编辑菜单 | ||
27 | + * @return void | ||
28 | + * @author :liyuhang | ||
29 | + * @method | ||
30 | + */ | ||
31 | + public function edit(){} | ||
32 | + | ||
33 | + /** | ||
34 | + * @name:禁用菜单 | ||
35 | + * @return void | ||
36 | + * @author :liyuhang | ||
37 | + * @method | ||
38 | + */ | ||
39 | + public function status(){} | ||
40 | + | ||
41 | + /** | ||
42 | + * @name:删除菜单 | ||
43 | + * @return void | ||
44 | + * @author :liyuhang | ||
45 | + * @method | ||
46 | + */ | ||
47 | + public function deleted(){ | ||
48 | + | ||
49 | + } | ||
50 | +} |
application/admin/controller/Role.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace app\api\controller; | ||
4 | + | ||
5 | +use app\admin\controller\Base; | ||
6 | + | ||
7 | +class Role extends Base | ||
8 | +{ | ||
9 | + /** | ||
10 | + * @name :角色列表 | ||
11 | + * @return void | ||
12 | + * @author :liyuhang | ||
13 | + * @method | ||
14 | + */ | ||
15 | + public function lists(){} | ||
16 | + | ||
17 | + /** | ||
18 | + * @name :添加角色 | ||
19 | + * @return void | ||
20 | + * @author :liyuhang | ||
21 | + * @method | ||
22 | + */ | ||
23 | + public function add(){} | ||
24 | + | ||
25 | + /** | ||
26 | + * @name:编辑角色 | ||
27 | + * @return void | ||
28 | + * @author :liyuhang | ||
29 | + * @method | ||
30 | + */ | ||
31 | + public function edit(){} | ||
32 | + | ||
33 | + /** | ||
34 | + * @name:修改当前角色状态 | ||
35 | + * @return void | ||
36 | + * @author :liyuhang | ||
37 | + * @method | ||
38 | + */ | ||
39 | + public function status(){} | ||
40 | + | ||
41 | + /** | ||
42 | + * @name :逻辑删除角色 | ||
43 | + * @return void | ||
44 | + * @author :liyuhang | ||
45 | + * @method | ||
46 | + */ | ||
47 | + public function deleted(){} | ||
48 | +} |
@@ -36,7 +36,7 @@ abstract class Base extends Model | @@ -36,7 +36,7 @@ abstract class Base extends Model | ||
36 | * @param $data | 36 | * @param $data |
37 | * @return $info | 37 | * @return $info |
38 | */ | 38 | */ |
39 | - protected function read($data) | 39 | + public function read($data) |
40 | { | 40 | { |
41 | $info = $this->where($data)->find(); | 41 | $info = $this->where($data)->find(); |
42 | if (!empty($info)) { | 42 | if (!empty($info)) { |
application/admin/model/Menu.php
0 → 100644
-
请 注册 或 登录 后发表评论