更新menu
This commit is contained in:
parent
138e50c86c
commit
681fc5159b
@ -232,7 +232,8 @@ class AdminLogic extends BaseLogic
|
|||||||
|
|
||||||
$result['user'] = $admin;
|
$result['user'] = $admin;
|
||||||
// 当前管理员角色拥有的菜单
|
// 当前管理员角色拥有的菜单
|
||||||
$result['menu'] = MenuLogic::getMenuByAdminId($params['id']);
|
$result['menu'] = MenuLogic::getMenuByAdminId($params['id'],false);
|
||||||
|
$result['top_menu'] = MenuLogic::getMenuByAdminId($params['id'],true);
|
||||||
// 当前管理员橘色拥有的按钮权限
|
// 当前管理员橘色拥有的按钮权限
|
||||||
$result['permissions'] = AuthLogic::getBtnAuthByRoleId($admin);
|
$result['permissions'] = AuthLogic::getBtnAuthByRoleId($admin);
|
||||||
return $result;
|
return $result;
|
||||||
|
@ -41,20 +41,23 @@ class MenuLogic extends BaseLogic
|
|||||||
* @author 段誉
|
* @author 段誉
|
||||||
* @date 2022/7/1 10:50
|
* @date 2022/7/1 10:50
|
||||||
*/
|
*/
|
||||||
public static function getMenuByAdminId($adminId)
|
public static function getMenuByAdminId($adminId,$is_top=false)
|
||||||
{
|
{
|
||||||
$admin = Admin::findOrEmpty($adminId);
|
$admin = Admin::findOrEmpty($adminId);
|
||||||
|
|
||||||
$where = [];
|
$where = [];
|
||||||
|
$menu_where=[];
|
||||||
|
|
||||||
$where[] = ['type', 'in', ['M', 'C']];
|
$where[] = ['type', 'in', ['M', 'C']];
|
||||||
$where[] = ['is_disable', '=', 0];
|
$where[] = ['is_disable', '=', 0];
|
||||||
|
if($is_top==true){
|
||||||
if ($admin['root'] != 1) {
|
$menu_where[]=['is_top','=',1];
|
||||||
$roleMenu = SystemRoleMenu::whereIn('role_id', $admin['role_id'])->where('is_top', 1)->column('menu_id');
|
|
||||||
$where[] = ['id', 'in', $roleMenu];
|
|
||||||
} else {
|
|
||||||
$where[] = ['pid', '=', 0];
|
$where[] = ['pid', '=', 0];
|
||||||
}
|
}
|
||||||
|
if ($admin['root'] != 1) {
|
||||||
|
$roleMenu = SystemRoleMenu::whereIn('role_id', $admin['role_id'])->where($menu_where)->column('menu_id');
|
||||||
|
$where[] = ['id', 'in', $roleMenu];
|
||||||
|
}
|
||||||
|
|
||||||
$menu = SystemMenu::where($where)
|
$menu = SystemMenu::where($where)
|
||||||
->order(['sort' => 'desc', 'id' => 'asc'])
|
->order(['sort' => 'desc', 'id' => 'asc'])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user