feat(admin): 更新后台权限管理与同步逻辑,简化权限检查并优化文档
- 新增后台 RBAC 相关文档,提供权限目录与维护命令说明。 - 移除不必要的角色资源同步检查,简化权限审计命令。 - 更新权限描述与同步逻辑,确保一致性与可维护性。 - 统一权限注册表,替换过时的权限别名,增强代码可读性。
This commit is contained in:
@@ -12,7 +12,7 @@ final class SyncAdminAuthorizationCommand extends Command
|
||||
protected $signature = 'lottery:admin-auth-sync
|
||||
{--audit : 同步完成后立即执行后台权限体检}';
|
||||
|
||||
protected $description = '根据后台统一注册表同步 admin_api_resources / bindings / role_api_resources';
|
||||
protected $description = '根据后台统一注册表同步 admin_api_resources 与 resource_bindings';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
@@ -69,25 +69,9 @@ final class SyncAdminAuthorizationCommand extends Command
|
||||
}
|
||||
}
|
||||
|
||||
DB::table('admin_role_api_resources')->delete();
|
||||
|
||||
$roleResourceRows = DB::table('admin_role_menu_actions as rma')
|
||||
->join('admin_api_resource_bindings as arb', 'arb.menu_action_id', '=', 'rma.menu_action_id')
|
||||
->select('rma.role_id', 'arb.api_resource_id')
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
foreach ($roleResourceRows as $row) {
|
||||
DB::table('admin_role_api_resources')->insert([
|
||||
'role_id' => (int) $row->role_id,
|
||||
'api_resource_id' => (int) $row->api_resource_id,
|
||||
]);
|
||||
}
|
||||
|
||||
$this->info(sprintf(
|
||||
'Admin authorization synced: %d resources, %d role-resource rows.',
|
||||
'Admin authorization synced: %d resources.',
|
||||
count(AdminAuthorizationRegistry::resources()),
|
||||
$roleResourceRows->count(),
|
||||
));
|
||||
|
||||
if ((bool) $this->option('audit')) {
|
||||
|
||||
Reference in New Issue
Block a user