src/application-profile/application-profile.controller.ts
application/:applicationId/profile
Methods |
| Async addApplicationProfile | ||||||||||||
addApplicationProfile(response, applicationId: number, body: ApplicationProfileBodyDto)
|
||||||||||||
Decorators :
@Post()
|
||||||||||||
|
Parameters :
Returns :
any
|
| Async deleteApplicationProfile |
deleteApplicationProfile(response, applicationId: number, id: number)
|
Decorators :
@Delete('/:id')
|
|
Returns :
unknown
|
| disableApplication |
disableApplication(applicationId: number, id: number)
|
Decorators :
@Patch(':id/disable')
|
|
Returns :
any
|
| enableApplication |
enableApplication(applicationId: number, id: number)
|
Decorators :
@Patch(':id/enable')
|
|
Returns :
any
|
| getApplication | ||||||
getApplication(applicationId: number)
|
||||||
Decorators :
@Get()
|
||||||
|
Parameters :
Returns :
Promise<ApplicationProfile[]>
|
import {
Body,
Controller,
Delete,
Get,
HttpStatus,
Param,
Patch,
Post,
Res,
} from '@nestjs/common';
import { ApiBearerAuth, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApplicationProfileService } from './application-profile.service';
import { ApplicationProfileBodyDto } from './dto/application-profile.dto';
import { ApplicationProfile } from 'src/entities/application-profile';
import { Application } from 'src/entities/application';
@ApiTags('application/profile')
@ApiBearerAuth('token')
@Controller('application/:applicationId/profile')
export class ApplicationProfileController {
constructor(
private readonly profileService: ApplicationProfileService
) {}
@Post()
@ApiResponse({ status: HttpStatus.OK, type: Application })
async addApplicationProfile(
@Res() response,
@Param('applicationId') applicationId: number,
@Body() body: ApplicationProfileBodyDto
) {
const id = await this.profileService.addProfile(+applicationId, body)
response.status(HttpStatus.CREATED).json({ id })
}
@Get()
@ApiResponse({ type: [Application] })
getApplication(@Param('applicationId') applicationId: number): Promise<ApplicationProfile[]> {
return this.profileService.getProfilesByApplicationId(+applicationId);
}
@Patch(':id/enable')
@ApiResponse({ type: Application })
enableApplication(
@Param('applicationId') applicationId: number,
@Param('id') id: number
) {
return this.profileService.enable(+applicationId, +id);
}
@Patch(':id/disable')
@ApiResponse({ type: Application })
disableApplication(
@Param('applicationId') applicationId: number,
@Param('id') id: number
) {
return this.profileService.disable(+applicationId, +id);
}
@Delete('/:id')
@ApiResponse({ status: HttpStatus.OK, type: Application })
async deleteApplicationProfile(
@Res() response,
@Param('applicationId') applicationId: number,
@Param('id') id: number
) {
await this.profileService.delete(+applicationId, +id);
return response.json()
}
}