feat : role
This commit is contained in:
@@ -118,7 +118,7 @@ class RoleMenuService extends BaseService
|
||||
*/
|
||||
public function edit(): array
|
||||
{
|
||||
$menuId = $this->request->input('menu_id');
|
||||
$menuId = (int)$this->request->input('menu_id');
|
||||
$url = $this->request->input('menu_url');
|
||||
$oldUrlInfo = $this->adminMenuModel->getMenuByUrl($url);
|
||||
$menuInfo = $this->adminMenuModel->where('id',$menuId)->first();
|
||||
@@ -213,32 +213,40 @@ class RoleMenuService extends BaseService
|
||||
if (!$res) throw new AdminException('路由不存在');
|
||||
$res = $res->toArray();
|
||||
|
||||
//闭包函数获取子集
|
||||
$res = function() use($res,$menuId) {
|
||||
$children = $this->adminMenuModel->where('parent_id',$menuId)->select(['type','value','title','id'])->get();
|
||||
$res['permissionList'] = [];
|
||||
if (!empty($children)) {
|
||||
$children = $children->toArray();
|
||||
if ($children[0]['type'] == AuthCode::MENU_TYPE_LIST) {
|
||||
return $res;
|
||||
}
|
||||
|
||||
foreach ($children as $one)
|
||||
{
|
||||
$res['permissionList'][] = [
|
||||
'id' => $one['id'],
|
||||
'label' => $one['title'],
|
||||
'value' => $one['value'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
};
|
||||
//获取子集
|
||||
$res = $this->getChildren($res,$menuId);
|
||||
|
||||
return $this->return->success('success',['info' => $res]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $res
|
||||
* @param $menuId
|
||||
* @return array
|
||||
*/
|
||||
private function getChildren(&$res,$menuId): array
|
||||
{
|
||||
$children = $this->adminMenuModel->where('parent_id',$menuId)->get(['type','value','title','id']);
|
||||
$res['permission_list'] = [];
|
||||
if (!empty($children)) {
|
||||
$children = $children->toArray();
|
||||
if ($children[0]['type'] == AuthCode::MENU_TYPE_LIST) {
|
||||
return $res;
|
||||
}
|
||||
|
||||
foreach ($children as $one)
|
||||
{
|
||||
$res['permission_list'][] = [
|
||||
'id' => $one['id'],
|
||||
'label' => $one['title'],
|
||||
'value' => $one['value'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建缓存
|
||||
* @return array
|
||||
|
||||
Reference in New Issue
Block a user