bug fix: update method

This commit is contained in:
myh 2024-01-04 18:45:27 +08:00
parent ddac5608a6
commit 8a46905abe
2 changed files with 8 additions and 4 deletions

View File

@ -32,8 +32,8 @@ export class UserController {
} }
// 根据id修改用户 // 根据id修改用户
@Put("/update") @Put("/update/:id")
async update(@Param('id') id: number, @Body() user: Users): Promise<void> { async update(@Param('id') id: number, @Body() user: Partial<Users>): Promise<void> {
this.userService.update(id, user); this.userService.update(id, user);
} }
} }

View File

@ -32,7 +32,11 @@ export class UserService {
} }
// 根据id修改用户 // 根据id修改用户
async update(id: number, user: Users): Promise<void> { async update(id: number, user: Partial<Users>): Promise<void> {
try {
await this.userRepository.update(id,user); await this.userRepository.update(id,user);
} catch (error) {
console.log(error);
}
} }
} }