import { Body, Controller, Delete, Get, Param, Patch, Post } from '@nestjs/common';
import { ProtectedMutation } from '../../common/audit/protected-mutation.decorator';
import { CreateTaskCategoryDto } from './dto/create-task-category.dto';
import { UpdateTaskCategoryDto } from './dto/update-task-category.dto';
import { TaskCategoryService } from './task-category.service';

@Controller('task-categories')
export class TaskCategoryController {
  constructor(private readonly taskCategoryService: TaskCategoryService) {}

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

  @Post()
  @ProtectedMutation('task-category:manage', {}, { action: 'task_category.create', entityType: 'task_category' })
  create(@Body() dto: CreateTaskCategoryDto) {
    return this.taskCategoryService.create(dto);
  }

  @Patch(':id')
  @ProtectedMutation('task-category:manage', {}, {
    action: 'task_category.update',
    entityType: 'task_category',
    entityIdParam: 'id',
  })
  update(@Param('id') id: string, @Body() dto: UpdateTaskCategoryDto) {
    return this.taskCategoryService.update(id, dto);
  }

  @Delete(':id')
  @ProtectedMutation('task-category:manage', {}, {
    action: 'task_category.delete',
    entityType: 'task_category',
    entityIdParam: 'id',
  })
  remove(@Param('id') id: string) {
    return this.taskCategoryService.remove(id);
  }
}
