feat: 重构管理员权限管理,移除 AdminPermission 模型,整合权限与角色管理逻辑,优化 API 接口以支持角色与权限的同步,增强数据库填充器以对齐权限配置
This commit is contained in:
@@ -52,13 +52,22 @@ function grantSuperAdminRole(AdminUser $admin): void
|
||||
$now = now();
|
||||
DB::table('admin_roles')->updateOrInsert(
|
||||
['slug' => AdminUser::ROLE_SUPER_ADMIN],
|
||||
['name' => 'Super Admin', 'created_at' => $now, 'updated_at' => $now],
|
||||
[
|
||||
'name' => 'Super Admin',
|
||||
'code' => AdminUser::ROLE_SUPER_ADMIN,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
],
|
||||
);
|
||||
$rid = (int) DB::table('admin_roles')->where('slug', AdminUser::ROLE_SUPER_ADMIN)->value('id');
|
||||
if (! DB::table('admin_user_roles')->where('admin_user_id', $admin->id)->where('role_id', $rid)->exists()) {
|
||||
DB::table('admin_user_roles')->insert([
|
||||
$siteId = (int) DB::table('admin_sites')->where('is_default', true)->value('id');
|
||||
|
||||
DB::table('admin_user_site_roles')->updateOrInsert(
|
||||
[
|
||||
'admin_user_id' => $admin->id,
|
||||
'site_id' => $siteId,
|
||||
'role_id' => $rid,
|
||||
]);
|
||||
}
|
||||
],
|
||||
['granted_at' => $now],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user