mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-29 14:01:07 +00:00
调整添加权限是权限规则自动生成
This commit is contained in:
parent
b227e881f3
commit
0840443190
@ -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,
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user