refactor: 迁移角色定义到src目录
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
import type { RoleDefinition } from './base.role';
|
||||
|
||||
export const AdminRole: RoleDefinition = {
|
||||
name: 'admin',
|
||||
displayName: '超级管理员',
|
||||
credentials: {
|
||||
username: 'admin',
|
||||
password: 'Test@123'
|
||||
},
|
||||
permissions: [
|
||||
'user:*',
|
||||
'role:*',
|
||||
'menu:*',
|
||||
'config:*',
|
||||
'log:read',
|
||||
'dict:*'
|
||||
],
|
||||
cannotAccess: [],
|
||||
expectedBehaviors: {
|
||||
canCreate: ['user', 'role', 'menu', 'config', 'dict'],
|
||||
canRead: ['user', 'role', 'menu', 'config', 'dict', 'log'],
|
||||
canUpdate: ['user', 'role', 'menu', 'config', 'dict'],
|
||||
canDelete: ['user', 'role', 'menu', 'config', 'dict']
|
||||
}
|
||||
};
|
||||
@@ -1,16 +0,0 @@
|
||||
export interface RoleDefinition {
|
||||
name: string;
|
||||
displayName: string;
|
||||
credentials: {
|
||||
username: string;
|
||||
password: string;
|
||||
};
|
||||
permissions: string[];
|
||||
cannotAccess: string[];
|
||||
expectedBehaviors: {
|
||||
canCreate: string[];
|
||||
canRead: string[];
|
||||
canUpdate: string[];
|
||||
canDelete: string[];
|
||||
};
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import type { RoleDefinition } from './base.role';
|
||||
import { AdminRole } from './admin.role';
|
||||
import { UserRole } from './user.role';
|
||||
import { TestRole } from './test.role';
|
||||
|
||||
export class RoleFactory {
|
||||
private static roles: Map<string, RoleDefinition> = new Map([
|
||||
['admin', AdminRole],
|
||||
['user', UserRole],
|
||||
['test', TestRole]
|
||||
]);
|
||||
|
||||
static getRole(roleName: string): RoleDefinition {
|
||||
const role = this.roles.get(roleName);
|
||||
if (!role) {
|
||||
throw new Error(`Role '${roleName}' not found`);
|
||||
}
|
||||
return role;
|
||||
}
|
||||
|
||||
static getAllRoles(): RoleDefinition[] {
|
||||
return Array.from(this.roles.values());
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import type { RoleDefinition } from './base.role';
|
||||
|
||||
export const TestRole: RoleDefinition = {
|
||||
name: 'test',
|
||||
displayName: '测试用户',
|
||||
credentials: {
|
||||
username: 'e2e_test_user',
|
||||
password: 'Test@123'
|
||||
},
|
||||
permissions: [
|
||||
'test:read',
|
||||
'test:write'
|
||||
],
|
||||
cannotAccess: [
|
||||
'/user-management',
|
||||
'/role-management'
|
||||
],
|
||||
expectedBehaviors: {
|
||||
canCreate: ['test'],
|
||||
canRead: ['test'],
|
||||
canUpdate: ['test'],
|
||||
canDelete: []
|
||||
}
|
||||
};
|
||||
@@ -1,26 +0,0 @@
|
||||
import type { RoleDefinition } from './base.role';
|
||||
|
||||
export const UserRole: RoleDefinition = {
|
||||
name: 'user',
|
||||
displayName: '普通用户',
|
||||
credentials: {
|
||||
username: 'normaluser',
|
||||
password: 'Test@123'
|
||||
},
|
||||
permissions: [
|
||||
'user:read:self',
|
||||
'user:update:self'
|
||||
],
|
||||
cannotAccess: [
|
||||
'/user-management',
|
||||
'/role-management',
|
||||
'/menu-management',
|
||||
'/system-config'
|
||||
],
|
||||
expectedBehaviors: {
|
||||
canCreate: [],
|
||||
canRead: ['self'],
|
||||
canUpdate: ['self'],
|
||||
canDelete: []
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user