| 123456789101112131415161718192021222324252627282930313233343536 |
- import { Controller, Get, Post, Body, Param, Put, Delete, Query } from '@nestjs/common';
- import { PhaseService } from '../services/phase.service';
- import { Phase } from '../schemas/site.schema';
- @Controller('phases')
- export class PhaseController {
- constructor(private readonly phaseService: PhaseService) { }
- @Post()
- async create(@Body() phase: Phase) {
- return this.phaseService.create(phase);
- }
- @Get()
- async findAll(@Query('siteId') siteId?: string) {
- const filter = siteId ? { siteId } : {};
- return this.phaseService.findAll(filter);
- }
- @Get(':id')
- async findById(@Param('id') id: string, @Query('populate') populate: string) {
- return this.phaseService.findById(id, populate === 'true');
- }
- @Put(':id')
- async update(@Param('id') id: string, @Body() update: Partial<Phase>) {
- await this.phaseService.update(id, update);
- return { message: 'Phase updated successfully' };
- }
- @Delete(':id')
- async delete(@Param('id') id: string) {
- await this.phaseService.delete(id);
- return { message: 'Phase and all related blocks/FFB data deleted successfully' };
- }
- }
|