|
|
@@ -8,7 +8,8 @@ import {
|
|
|
NotFoundException,
|
|
|
Delete,
|
|
|
BadRequestException,
|
|
|
- Req
|
|
|
+ Req,
|
|
|
+ Post
|
|
|
} from '@nestjs/common'
|
|
|
import { UsersService } from './users.service'
|
|
|
import { UserProfileDto } from './dto/user-profile.dto'
|
|
|
@@ -26,6 +27,20 @@ export class UsersController {
|
|
|
return this.usersService.findById(req.user.userId)
|
|
|
}
|
|
|
|
|
|
+ @Post('/update')
|
|
|
+ public async update(@Body() userProfileDto: UserProfileDto, @Req() req): Promise<any> {
|
|
|
+ try {
|
|
|
+ await this.usersService.updateProfileUser(req.user.userId, userProfileDto)
|
|
|
+
|
|
|
+ return {
|
|
|
+ message: 'User Updated successfully!',
|
|
|
+ status: HttpStatus.OK
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ throw new BadRequestException(err, 'Error: User not updated!')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Get()
|
|
|
public async findAllUser(): Promise<IUsers[]> {
|
|
|
return this.usersService.findAll()
|
|
|
@@ -50,23 +65,6 @@ export class UsersController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Put('/:userId/profile')
|
|
|
- public async updateProfileUser(
|
|
|
- @Param('userId') userId: string,
|
|
|
- @Body() userProfileDto: UserProfileDto
|
|
|
- ): Promise<any> {
|
|
|
- try {
|
|
|
- await this.usersService.updateProfileUser(userId, userProfileDto)
|
|
|
-
|
|
|
- return {
|
|
|
- message: 'User Updated successfully!',
|
|
|
- status: HttpStatus.OK
|
|
|
- }
|
|
|
- } catch (err) {
|
|
|
- throw new BadRequestException(err, 'Error: User not updated!')
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
@Put('/:userId')
|
|
|
public async updateUser(@Param('userId') userId: string, @Body() userUpdateDto: UserUpdateDto) {
|
|
|
try {
|