|
|
@@ -15,12 +15,13 @@ import { UsersService } from './users.service'
|
|
|
import { UserProfileDto } from './dto/user-profile.dto'
|
|
|
import { UserUpdateDto } from './dto/user-update.dto'
|
|
|
import { IUsers } from './interfaces/users.interface'
|
|
|
-import { ApiTags } from '@nestjs/swagger'
|
|
|
+import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'
|
|
|
import { HasRoles } from '../auth/roles.decorator'
|
|
|
import { Role } from '../model/role.enum'
|
|
|
|
|
|
@ApiTags('users')
|
|
|
@Controller('users')
|
|
|
+@ApiBearerAuth()
|
|
|
export class UsersController {
|
|
|
constructor(private readonly usersService: UsersService) {}
|
|
|
|
|
|
@@ -29,7 +30,6 @@ export class UsersController {
|
|
|
return this.usersService.findById(req.user.userId)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Post('/update')
|
|
|
public async update(@Body() userProfileDto: UserProfileDto, @Req() req): Promise<any> {
|
|
|
try {
|
|
|
@@ -44,11 +44,6 @@ export class UsersController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Get()
|
|
|
- public async findAllUser(): Promise<IUsers[]> {
|
|
|
- return this.usersService.findAll()
|
|
|
- }
|
|
|
-
|
|
|
@Get('/:userId')
|
|
|
public async findOneUser(@Param('userId') userId: string): Promise<IUsers> {
|
|
|
return this.usersService.findById(userId)
|
|
|
@@ -67,23 +62,4 @@ export class UsersController {
|
|
|
status: HttpStatus.OK
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- @Put('/:userId')
|
|
|
- public async updateUser(@Param('userId') userId: string, @Body() userUpdateDto: UserUpdateDto) {
|
|
|
- try {
|
|
|
- await this.usersService.updateUser(userId, userUpdateDto)
|
|
|
-
|
|
|
- return {
|
|
|
- message: 'User Updated successfully!',
|
|
|
- status: HttpStatus.OK
|
|
|
- }
|
|
|
- } catch (err) {
|
|
|
- throw new BadRequestException(err, 'Error: User not updated!')
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Delete('/:userId')
|
|
|
- public async deleteUser(@Param('userId') userId: string): Promise<void> {
|
|
|
- await this.usersService.deleteUser(userId)
|
|
|
- }
|
|
|
}
|