form.controller.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { Body, Controller, Delete, Get, Param, Post, Put } from '@nestjs/common'
  2. import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'
  3. import { FormService } from './form.service'
  4. import { PageRequest } from 'src/common/dto/page-request'
  5. import { Form } from './entities/form.entity'
  6. import { FormDto } from './dto/form.dto'
  7. import { Field } from './entities/filed.entity'
  8. @ApiTags('form')
  9. @ApiBearerAuth()
  10. @Controller('/form')
  11. export class FormController {
  12. constructor(private readonly formService: FormService) {}
  13. @Post()
  14. public async list(@Body() page: PageRequest<Form>) {
  15. return await this.formService.findAll(page)
  16. }
  17. @Put()
  18. public async create(@Body() form: Partial<Form>) {
  19. return await this.formService.save(form)
  20. }
  21. @Put('/:id')
  22. public async update(@Body() form: Partial<Form>) {
  23. return await this.formService.update(form)
  24. }
  25. @Post('/fileds')
  26. public async findAllFileds(@Body() page: PageRequest<Field>) {
  27. return await this.formService.findAllFileds(page)
  28. }
  29. @Delete('/:id')
  30. public async delete(@Param('id') id: string) {
  31. return await this.formService.delete(Number(id))
  32. }
  33. }