完成用户权限管理

This commit is contained in:
2025-05-08 23:13:24 +08:00
parent 448a7b48ba
commit 2f86362f4b
5 changed files with 74 additions and 0 deletions

View File

@@ -10,6 +10,16 @@ export class UserRoleService {
private readonly userRoleRepository: Repository<UserRole>,
) { }
async findRoleIdsByUserId(userId: string): Promise<string[]> {
const userRoles = await this.userRoleRepository.find({
where: {
userId,
}
});
return userRoles.map(ur => ur.roleId);
}
async findValidRoleIdsByUserId(userId: string): Promise<string[]> {
return (await this.findValidRolesByUserId(userId)).map(ur => ur.roleId);
}