import { JsonController , Get , CurrentUser , Body , Delete , Put , UseInterceptor , HttpCode , } from 'routing-controllers' ; import { BaseController } from './BaseController' ; import { User } from '../model' ; import { UserService } from '../service/UserService' ; import { ResponseJosnInterceptor } from '../interceptor/ResponseJsonInterceptor' ; import { OpenAPI , ResponseSchema } from 'routing-controllers-openapi' ; import { IuserDTOClass } from '../dto/UserDTO' ; @ JsonController ( '/user' ) @ UseInterceptor ( ResponseJosnInterceptor ) export class UserController extends BaseController { constructor ( private userService ) { super ( ) ; } @ Get ( ) @ HttpCode ( 200 ) @ OpenAPI ( { summary : 'get user' , description : 'get an user with jwt token' , security : [ { bearerAuth : [ ] } ] , } ) @ ResponseSchema ( User ) async getUser ( @ CurrentUser ( { required : true } ) user ) { return user ; } @ Put ( ) @ HttpCode ( 201 ) @ OpenAPI ( { summary : 'edit user' , description : 'update user' , security : [ { bearerAuth : [ ] } ] , } ) @ ResponseSchema ( User ) async editUser ( @ CurrentUser ( { required : true } ) user , @ Body ( ) body ) { const editUser = await this . userService . createOrUpdate ( body , user . userAccount . clientId ) ; return editUser ; } @ Delete ( ) @ HttpCode ( 204 ) @ OpenAPI ( { summary : 'delete user' , description : 'sofrt delete user' , security : [ { bearerAuth : [ ] } ] , } ) @ ResponseSchema ( User ) async deleteUser ( @ CurrentUser ( { required : true } ) user ) { const editUser = await this . userService . createOrUpdate ( { deletedAt : new Date ( ) } , user . userAccount . clientId ) ; return editUser ; } }