form builder module
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards } from '@nestjs/common';
|
||||
import { ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
|
||||
import { AdminAuthGuard } from '../../auth/guards/adminAuth.guard';
|
||||
import { FieldService } from '../provider/field.service';
|
||||
import { CreateFieldDto } from '../dto/create-field.dto';
|
||||
import { CreateFieldOptionDto } from '../dto/create-field-option.dto';
|
||||
import { FieldOptionService } from '../provider/field-option.service';
|
||||
import { UpdateFieldDto } from '../dto/update-field.dto';
|
||||
import { UpdateFieldOptionDto } from '../dto/update-field-option.dto';
|
||||
|
||||
@Controller('admin')
|
||||
@ApiBearerAuth()
|
||||
export class FormBuilderController {
|
||||
constructor(
|
||||
private readonly fieldService: FieldService,
|
||||
private readonly fieldOptionService: FieldOptionService,
|
||||
) { }
|
||||
|
||||
|
||||
/*================================ Field ========================== */
|
||||
|
||||
@Post('section/:id/field')
|
||||
@ApiOperation({ summary: 'Create field for section' })
|
||||
@UseGuards(AdminAuthGuard)
|
||||
createField(@Body() dto: CreateFieldDto, @Param('id') sectionId: string) {
|
||||
return this.fieldService.create(sectionId,dto);
|
||||
}
|
||||
|
||||
@Get('section/:id/field')
|
||||
@ApiOperation({ summary: 'find all secion fields' })
|
||||
@UseGuards(AdminAuthGuard)
|
||||
findAllSectionFields(@Param('id') sectionId: string) {
|
||||
return this.fieldService.findAll(+sectionId);
|
||||
}
|
||||
|
||||
@Get('section/field/:id')
|
||||
@ApiOperation({ summary: 'Find one field' })
|
||||
@UseGuards(AdminAuthGuard)
|
||||
findOneFiled(@Param('id') id: string) {
|
||||
return this.fieldService.findById(+id);
|
||||
}
|
||||
|
||||
@Patch('section/field/:id')
|
||||
@ApiOperation({ summary: 'Update field' })
|
||||
@UseGuards(AdminAuthGuard)
|
||||
updateField(@Param('id') id: string, @Body() dto: UpdateFieldDto) {
|
||||
return this.fieldService.update(+id, dto);
|
||||
}
|
||||
|
||||
@Delete('section/field/:id')
|
||||
@ApiOperation({ summary: 'Renopve field' })
|
||||
@UseGuards(AdminAuthGuard)
|
||||
removeField(@Param('id') id: string) {
|
||||
return this.fieldService.remove(+id);
|
||||
}
|
||||
|
||||
/*================================ Field Option ========================== */
|
||||
|
||||
@Post('field/:id/option')
|
||||
@ApiOperation({ summary: 'Create field Options ' })
|
||||
@UseGuards(AdminAuthGuard)
|
||||
createFieldOption(@Body() dto: CreateFieldOptionDto, @Param('id') id: string) {
|
||||
return this.fieldOptionService.create(+id, dto);
|
||||
}
|
||||
|
||||
@Get('field/:id/option')
|
||||
@ApiOperation({ summary: 'find all field Option' })
|
||||
@UseGuards(AdminAuthGuard)
|
||||
findAllFiledOptions(@Param('id') fieldId: string) {
|
||||
return this.fieldOptionService.findAll(+fieldId);
|
||||
}
|
||||
|
||||
@Get('field/option/:id')
|
||||
@ApiOperation({ summary: 'Find one field Option' })
|
||||
@UseGuards(AdminAuthGuard)
|
||||
findOneFiledOption(@Param('id') id: string) {
|
||||
return this.fieldOptionService.findById(+id);
|
||||
}
|
||||
|
||||
@Patch('field/option/:id')
|
||||
@ApiOperation({ summary: 'Update field Option' })
|
||||
@UseGuards(AdminAuthGuard)
|
||||
updateFieldOption(@Param('id') id: string, @Body() dto: UpdateFieldOptionDto) {
|
||||
return this.fieldOptionService.update(+id, dto);
|
||||
}
|
||||
|
||||
@Delete('field/option/:id')
|
||||
@ApiOperation({ summary: 'Renopve field Option' })
|
||||
@UseGuards(AdminAuthGuard)
|
||||
removeFieldOption(@Param('id') id: string) {
|
||||
return this.fieldOptionService.remove(+id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user