import { Body, Controller, Delete, Get, Param, Patch, Post } from '@nestjs/common';
import { ProtectedMutation } from '../../common/audit/protected-mutation.decorator';
import { CreateOvertimeDto } from './dto/create-overtime.dto';
import { UpdateOvertimeDto } from './dto/update-overtime.dto';
import { OvertimeService } from './overtime.service';

@Controller('overtime')
export class OvertimeController {
  constructor(private readonly overtimeService: OvertimeService) {}

  @Get()
  findAll() {
    return this.overtimeService.findAll();
  }

  @Post()
  @ProtectedMutation('overtime:create', { productIdBody: 'productId', projectIdBody: 'projectId', versionIdBody: 'versionId' }, {
    action: 'overtime.create',
    entityType: 'overtime',
    productIdBody: 'productId',
    projectIdBody: 'projectId',
    versionIdBody: 'versionId',
  })
  create(@Body() dto: CreateOvertimeDto) {
    return this.overtimeService.create(dto);
  }

  @Patch(':id')
  @ProtectedMutation('overtime:create', { productIdBody: 'productId', projectIdBody: 'projectId', versionIdBody: 'versionId' }, {
    action: 'overtime.update',
    entityType: 'overtime',
    entityIdParam: 'id',
    productIdBody: 'productId',
    projectIdBody: 'projectId',
    versionIdBody: 'versionId',
  })
  update(@Param('id') id: string, @Body() dto: UpdateOvertimeDto) {
    return this.overtimeService.update(id, dto);
  }

  @Delete(':id')
  @ProtectedMutation('overtime:delete', {}, {
    action: 'overtime.delete',
    entityType: 'overtime',
    entityIdParam: 'id',
  })
  remove(@Param('id') id: string) {
    return this.overtimeService.remove(id);
  }
}
