diff --git a/crmeb/app/adminapi/controller/v1/setting/SystemMenus.php b/crmeb/app/adminapi/controller/v1/setting/SystemMenus.php index ee3956221..f69d1bef8 100644 --- a/crmeb/app/adminapi/controller/v1/setting/SystemMenus.php +++ b/crmeb/app/adminapi/controller/v1/setting/SystemMenus.php @@ -130,14 +130,45 @@ class SystemMenus extends AuthController } $data = []; + $uniqueAuthAll = $this->services->getColumn(['is_del' => 0, 'is_show' => 1], 'unique_auth'); + $uniqueAuthAll = array_filter($uniqueAuthAll, function ($item) { + return !!$item; + }); + $uniqueAuthAll = array_unique($uniqueAuthAll); + + $uniqueFn = function ($path) use ($uniqueAuthAll) { + $attPath = explode('/', $path); + $uniqueAuth = ''; + if ($attPath) { + $pathData = []; + foreach ($attPath as $vv) { + if (strstr($vv, '<') === false || strstr($vv, '?>') === false) { + $pathData[] = $vv; + } + } + $uniqueAuth = implode('-', $pathData); + } + + if (in_array($uniqueAuth, $uniqueAuthAll)) { + $uniqueAuth .= '-' . uniqid(); + } + + array_push($uniqueAuthAll, $uniqueAuth); + + return $uniqueAuth; + }; + foreach ($menus as $menu) { if (empty($menu['menu_name'])) { return app('json')->fail(400198); } + if (isset($menu['unique_auth']) && $menu['unique_auth']) { + $menu['unique_auth'] = explode('/', $menu['api_url']); + } $data[] = [ 'methods' => $menu['method'], 'menu_name' => $menu['menu_name'], - 'unique_auth' => $menu['unique_auth'] ?? '', + 'unique_auth' => !empty($menu['unique_auth']) ? $menu['unique_auth'] : $uniqueFn($menu['api_url']), 'api_url' => $menu['api_url'], 'pid' => $menu['path'], 'auth_type' => 2, diff --git a/crmeb/app/model/system/SystemCrud.php b/crmeb/app/model/system/SystemCrud.php index 585cd79db..0a9f1065a 100644 --- a/crmeb/app/model/system/SystemCrud.php +++ b/crmeb/app/model/system/SystemCrud.php @@ -56,8 +56,7 @@ class SystemCrud extends BaseModel return json_decode($value, true); } - - public function getRoutesIdAttr($value) + public function getRouteIdsAttr($value) { return json_decode($value, true); } diff --git a/crmeb/app/services/system/SystemCrudServices.php b/crmeb/app/services/system/SystemCrudServices.php index 6cb557123..0113a73d8 100644 --- a/crmeb/app/services/system/SystemCrudServices.php +++ b/crmeb/app/services/system/SystemCrudServices.php @@ -29,7 +29,6 @@ use crmeb\services\crud\ViewPages; use crmeb\services\crud\ViewRouter; use crmeb\services\FileService; use Phinx\Db\Adapter\AdapterFactory; -use think\exception\ValidateException; use think\facade\Db; use think\helper\Str; use think\migration\db\Table;