nest-project/src/users/users.controller.ts

21 lines
715 B
TypeScript
Raw Normal View History

2023-02-17 16:13:04 +08:00
import { Controller, Get, UseInterceptors } from '@nestjs/common'
2023-02-15 20:32:14 +08:00
import { UsersService } from './users.service'
2023-02-16 01:18:55 +08:00
import { ApiTags } from '@nestjs/swagger'
2023-02-17 14:21:08 +08:00
import { User } from 'src/common/decorators/user.decorator'
import { NeedAuth } from 'src/common/decorators/need-auth.decorator'
2023-02-17 16:13:04 +08:00
import { PasswordInterceptor } from 'src/common/interceptors/password.interceptor'
2023-02-15 20:32:14 +08:00
2023-02-17 14:21:08 +08:00
@ApiTags('User')
@Controller('api/user')
2023-02-15 20:32:14 +08:00
export class UsersController {
constructor(private readonly userService: UsersService) {}
2023-02-17 14:21:08 +08:00
2023-02-17 16:13:04 +08:00
@UseInterceptors(PasswordInterceptor)
2023-02-17 14:21:08 +08:00
@NeedAuth()
@Get('profile')
async getUserInfo(@User('userId') userId: string) {
const user = await this.userService.findUser({ id: userId })
return user
}
2023-02-15 20:32:14 +08:00
}