import { Body, Controller, Delete, Get, Param, Post } from '@nestjs/common';
import { ProtectedMutation } from '../../common/audit/protected-mutation.decorator';
import { WorkActivityRecordInput, WorkActivityService } from './work-activity.service';

@Controller('work-activities')
export class WorkActivityController {
  constructor(private readonly workActivityService: WorkActivityService) {}

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

  @Post()
  @ProtectedMutation('work-activity:manage', { productIdBody: 'productId', projectIdBody: 'projectId', versionIdBody: 'versionId' }, {
    action: 'work_activity.create',
    entityType: 'work_activity',
    productIdBody: 'productId',
    projectIdBody: 'projectId',
    versionIdBody: 'versionId',
  })
  create(@Body() dto: WorkActivityRecordInput) {
    return this.workActivityService.record(dto);
  }

  @Delete(':id')
  @ProtectedMutation('work-activity:manage', {}, {
    action: 'work_activity.delete',
    entityType: 'work_activity',
    entityIdParam: 'id',
  })
  remove(@Param('id') id: string) {
    return this.workActivityService.remove(id);
  }
}
