123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- namespace app\controller\store\system;
- use app\controller\store\AuthController;
- use app\services\system\SystemMenusServices;
- use app\services\system\SystemRoleServices;
- use crmeb\services\CacheService;
- use think\facade\App;
- class SystemMenus extends AuthController
- {
-
- public function __construct(App $app, SystemMenusServices $services)
- {
- parent::__construct($app);
- $this->services = $services;
- $this->request->filter(['addslashes', 'trim']);
- }
-
- public function index()
- {
- $where = $this->request->getMore([
- ['is_show', ''],
- ['keyword', ''],
- ]);
- $where['type'] = 2;
- return app('json')->success($this->services->getList($where));
- }
-
- public function cashierMenusList()
- {
- $where = $this->request->getMore([
- ['is_show', ''],
- ['keyword', ''],
- ]);
- $where['type'] = 3;
- return app('json')->success($this->services->getList($where));
- }
-
- public function sonMenusList($role_id = 0, $id = 0)
- {
- if (!$id) {
- app('json')->fail('请选择上级菜单');
- }
- $rules = [];
- if ($role_id) {
-
- $systemRoleServices = app()->make(SystemRoleServices::class);
- $role = $systemRoleServices->get((int)$role_id);
- $rules = $role && $role['rules'] ? explode(',', $role['rules']) : [];
- }
- $where['type'] = 2;
- $where['auth_type'] = 2;
- $where['pid'] = $id;
- $menus = $this->services->getList($where);
- $checked_rules = [];
- foreach ($menus as $item) {
- if ($rules && in_array($item['id'] ?? 0, $rules)) {
- $checked_rules [] = $item['id'];
- }
- }
- return app('json')->success(compact('menus', 'checked_rules'));
- }
- }
|