File

src/application-profile/application-profile.controller.ts

Prefix

application/:applicationId/profile

Index

Methods

Methods

Async addApplicationProfile
addApplicationProfile(response, applicationId: number, body: ApplicationProfileBodyDto)
Decorators :
@Post()
@ApiResponse({status: undefined, type: Application})
Parameters :
Name Type Optional
response No
applicationId number No
body ApplicationProfileBodyDto No
Returns : any
Async deleteApplicationProfile
deleteApplicationProfile(response, applicationId: number, id: number)
Decorators :
@Delete('/:id')
@ApiResponse({status: undefined, type: Application})
Parameters :
Name Type Optional
response No
applicationId number No
id number No
Returns : unknown
disableApplication
disableApplication(applicationId: number, id: number)
Decorators :
@Patch(':id/disable')
@ApiResponse({type: Application})
Parameters :
Name Type Optional
applicationId number No
id number No
Returns : any
enableApplication
enableApplication(applicationId: number, id: number)
Decorators :
@Patch(':id/enable')
@ApiResponse({type: Application})
Parameters :
Name Type Optional
applicationId number No
id number No
Returns : any
getApplication
getApplication(applicationId: number)
Decorators :
@Get()
@ApiResponse({type: undefined})
Parameters :
Name Type Optional
applicationId number No
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()
  }
}

results matching ""

    No results matching ""