|
|
@@ -32,9 +32,9 @@ export class UserService {
|
|
|
|
|
|
async getUserById(id: number): Promise<User | null> {
|
|
|
try {
|
|
|
- return await this.userRepository.findOne({
|
|
|
+ return await this.userRepository.findOne({
|
|
|
where: { id },
|
|
|
- relations: ['roles']
|
|
|
+ relations: ['roles', 'roles.rolePermissions', 'roles.rolePermissions.permission']
|
|
|
});
|
|
|
} catch (error) {
|
|
|
console.error('Error getting user:', error);
|
|
|
@@ -46,7 +46,7 @@ export class UserService {
|
|
|
try {
|
|
|
return await this.userRepository.findOne({
|
|
|
where: { username },
|
|
|
- relations: ['roles']
|
|
|
+ relations: ['roles', 'roles.rolePermissions', 'roles.rolePermissions.permission']
|
|
|
});
|
|
|
} catch (error) {
|
|
|
console.error('Error getting user:', error);
|
|
|
@@ -58,7 +58,7 @@ export class UserService {
|
|
|
try {
|
|
|
return await this.userRepository.findOne({
|
|
|
where: { phone: phone },
|
|
|
- relations: ['roles']
|
|
|
+ relations: ['roles', 'roles.rolePermissions', 'roles.rolePermissions.permission']
|
|
|
});
|
|
|
} catch (error) {
|
|
|
console.error('Error getting user by phone:', error);
|
|
|
@@ -66,6 +66,18 @@ export class UserService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ async getUserWithPermissions(id: number): Promise<User | null> {
|
|
|
+ try {
|
|
|
+ return await this.userRepository.findOne({
|
|
|
+ where: { id },
|
|
|
+ relations: ['roles', 'roles.rolePermissions', 'roles.rolePermissions.permission']
|
|
|
+ });
|
|
|
+ } catch (error) {
|
|
|
+ console.error('Error getting user with permissions:', error);
|
|
|
+ throw new Error('Failed to get user with permissions');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
async updateUser(id: number, updateData: Partial<User>): Promise<User | null> {
|
|
|
try {
|
|
|
if (updateData.password) {
|