|
@@ -178,6 +178,21 @@ export class UsersService implements OnModuleInit {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public async update(userProfileDto: UserProfileDto): Promise<Users> {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const user = await this.userRepository.findOneBy({ id: +userProfileDto.id })
|
|
|
|
|
+ if (userProfileDto.name) user.name = userProfileDto.name
|
|
|
|
|
+ if (userProfileDto.avatar) user.avatar = userProfileDto.avatar
|
|
|
|
|
+ if (userProfileDto.username) user.username = userProfileDto.username
|
|
|
|
|
+ if (userProfileDto.invitor) user.invitor = userProfileDto.invitor
|
|
|
|
|
+ if (userProfileDto.roles) user.roles = userProfileDto.roles
|
|
|
|
|
+
|
|
|
|
|
+ return await this.userRepository.save(user)
|
|
|
|
|
+ } catch (err) {
|
|
|
|
|
+ throw new HttpException(err, HttpStatus.BAD_REQUEST)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public async updateUser(id: number, userUpdateDto: UserUpdateDto): Promise<UpdateResult> {
|
|
public async updateUser(id: number, userUpdateDto: UserUpdateDto): Promise<UpdateResult> {
|
|
|
try {
|
|
try {
|
|
|
const user = await this.userRepository.update(
|
|
const user = await this.userRepository.update(
|