This commit is contained in:
weiz 2024-05-30 10:16:56 +08:00
parent 141b7d2a24
commit 6c86550745
2 changed files with 7 additions and 11 deletions

View File

@ -19,8 +19,6 @@ use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\auth\MenuLists;
use app\adminapi\logic\auth\MenuLogic;
use app\adminapi\validate\auth\MenuValidate;
use app\common\model\auth\Admin;
use app\common\model\auth\SystemRoleMenu;
/**
@ -64,14 +62,7 @@ class MenuController extends BaseAdminController
if($id==0){
return $this->fail('缺少参数');
}
$admin = Admin::findOrEmpty($this->adminId);
if ($admin['root'] != 1) {
$roleMenu = SystemRoleMenu::whereIn('role_id', $admin['role_id'])->where('menu_id',$id)->findOrEmpty();
if($roleMenu->isEmpty()){
return $this->fail('没有该菜单权限');
}
}
$list=MenuLogic::getModelList($id);
$list=MenuLogic::getModelList($id,$this->adminId);
return $this->success('操作成功', $list);
}

View File

@ -66,7 +66,7 @@ class MenuLogic extends BaseLogic
return linear_to_tree($menu, 'children');
}
public static function getModelList($id){
public static function getModelList($id,$adminId){
$where = [];
$where[] = ['is_disable', '=', 0];
$where[] = ['id', '=', $id];
@ -75,6 +75,11 @@ class MenuLogic extends BaseLogic
unset($where[1]);
$where[] = ['type', 'in', ['M', 'C']];
$where[] = ['model_name', '=', $model_name];
$admin = Admin::findOrEmpty($adminId);
if ($admin['root'] != 1) {
$roleMenu = SystemRoleMenu::whereIn('role_id', $admin['role_id'])->column('menu_id');
$where[] = ['id', 'in', $roleMenu];
}
$menu = SystemMenu::where($where)
->order(['sort' => 'desc', 'id' => 'asc'])
->select();