feat : basic
This commit is contained in:
@@ -12,7 +12,7 @@ namespace App\Service\Admin\User;
|
||||
|
||||
use App\Cache\Redis\Admin\MenuCache;
|
||||
use App\Constants\Admin\AuthCode;
|
||||
use App\Exception\AdminException;
|
||||
use App\Exception\ErrException;
|
||||
use App\Model\AdminMenu;
|
||||
use App\Service\Admin\BaseService;
|
||||
use Exception;
|
||||
@@ -60,14 +60,14 @@ class RoleMenuService extends BaseService
|
||||
public function add(): array
|
||||
{
|
||||
$url = $this->request->input('menu_url');
|
||||
if (!empty($this->adminMenuModel->getMenuByUrl($url))) throw new AdminException('已存在相同路由的权限菜单');
|
||||
if (!empty($this->adminMenuModel->getMenuByUrl($url))) throw new ErrException('已存在相同路由的权限菜单');
|
||||
|
||||
$insertButtonArr = [];
|
||||
if (!empty($permissionList = $this->request->input('permission_list'))) {
|
||||
$permissionList = json_decode($permissionList, true);
|
||||
foreach ($permissionList as $one) {
|
||||
if (empty($one['value'])) throw new AdminException('按钮权限值错误');
|
||||
if (empty($one['menu_url'])) throw new AdminException('按钮路由值错误');
|
||||
if (empty($one['value'])) throw new ErrException('按钮权限值错误');
|
||||
if (empty($one['menu_url'])) throw new ErrException('按钮路由值错误');
|
||||
$insertButtonArr[] = [
|
||||
'url' => $one['menu_url'],
|
||||
'value' => $one['value'],
|
||||
@@ -104,7 +104,7 @@ class RoleMenuService extends BaseService
|
||||
$this->reconfigurationCache();
|
||||
} catch (Exception $exception) {
|
||||
Db::rollBack();
|
||||
throw new AdminException($exception->getMessage());
|
||||
throw new ErrException($exception->getMessage());
|
||||
}
|
||||
|
||||
return $this->return->success();
|
||||
@@ -122,8 +122,8 @@ class RoleMenuService extends BaseService
|
||||
$url = $this->request->input('menu_url');
|
||||
$oldUrlInfo = $this->adminMenuModel->getMenuByUrl($url);
|
||||
$menuInfo = $this->adminMenuModel->where('id',$menuId)->first();
|
||||
if (!empty($oldUrlInfo) && $oldUrlInfo->id != $menuId) throw new AdminException('已存在相同路由的权限菜单');
|
||||
if (empty($menuInfo)) throw new AdminException('路由不存在');
|
||||
if (!empty($oldUrlInfo) && $oldUrlInfo->id != $menuId) throw new ErrException('已存在相同路由的权限菜单');
|
||||
if (empty($menuInfo)) throw new ErrException('路由不存在');
|
||||
|
||||
$childrenType = $this->adminMenuModel->getChildMenuType($menuId);
|
||||
$permissionList = $this->request->input('permission_list');
|
||||
@@ -131,8 +131,8 @@ class RoleMenuService extends BaseService
|
||||
if (!empty($permissionList) && $childrenType != AuthCode::MENU_TYPE_LIST) {
|
||||
$permissionList = json_decode($permissionList, true);
|
||||
foreach ($permissionList as $one) {
|
||||
if (empty($one['value'])) throw new AdminException('按钮权限值错误');
|
||||
if (empty($one['menu_url'])) throw new AdminException('按钮路由值错误');
|
||||
if (empty($one['value'])) throw new ErrException('按钮权限值错误');
|
||||
if (empty($one['menu_url'])) throw new ErrException('按钮路由值错误');
|
||||
$insertButtonArr[] = [
|
||||
'parent_id' => $menuId,
|
||||
'url' => $one['menu_url'],
|
||||
@@ -168,7 +168,7 @@ class RoleMenuService extends BaseService
|
||||
$this->reconfigurationCache();
|
||||
} catch (Exception $exception) {
|
||||
Db::rollBack();
|
||||
throw new AdminException($exception->getMessage());
|
||||
throw new ErrException($exception->getMessage());
|
||||
}
|
||||
|
||||
return $this->return->success();
|
||||
@@ -185,7 +185,7 @@ class RoleMenuService extends BaseService
|
||||
{
|
||||
$menuId = $this->request->input('menu_id');
|
||||
$res = $this->adminMenuModel->where('id',$menuId)->first();
|
||||
if (!$res) throw new AdminException('路由不存在');
|
||||
if (!$res) throw new ErrException('路由不存在');
|
||||
|
||||
$ids = [$res->id];
|
||||
$topIds = [$res->id];
|
||||
@@ -210,7 +210,7 @@ class RoleMenuService extends BaseService
|
||||
{
|
||||
$menuId = $this->request->input('menu_id');
|
||||
$res = $this->adminMenuModel->where('id',$menuId)->first();
|
||||
if (!$res) throw new AdminException('路由不存在');
|
||||
if (!$res) throw new ErrException('路由不存在');
|
||||
$res = $res->toArray();
|
||||
|
||||
//获取子集
|
||||
|
||||
Reference in New Issue
Block a user