diff --git a/src/modules/task-manager/controllers/remark.controller.ts b/src/modules/task-manager/controllers/remark.controller.ts new file mode 100644 index 0000000..7c4168a --- /dev/null +++ b/src/modules/task-manager/controllers/remark.controller.ts @@ -0,0 +1,56 @@ +import { Controller, Get, Post, Patch, Delete, Param, Body, Query } from "@nestjs/common"; +import { ApiTags, ApiOperation, ApiResponse, ApiParam, ApiQuery } from "@nestjs/swagger"; +import { RemarkService } from "../providers/remark.service"; +import { CreateRemarkDto } from "../dto/remark/create-remark.dto"; +import { UpdateRemarkDto } from "../dto/remark/update-remark.dto"; +import { TMRemark } from "../entities/remark.entity"; + +@ApiTags("Task Manager - Remarks") +@Controller("task-manager/remarks") +export class RemarkController { + constructor(private readonly remarkService: RemarkService) {} + + @Get() + @ApiOperation({ summary: "Get all remarks, optionally filtered by task" }) + @ApiQuery({ name: "taskId", required: false, description: "Filter remarks by task ID" }) + @ApiResponse({ status: 200, description: "List of remarks", type: [TMRemark] }) + findAll(@Query("taskId") taskId?: string): Promise { + if (taskId) return this.remarkService.findByTask(taskId); + return this.remarkService.findAll(); + } + + @Get(":id") + @ApiOperation({ summary: "Get a remark by ID" }) + @ApiParam({ name: "id", description: "Remark ID" }) + @ApiResponse({ status: 200, description: "Remark found", type: TMRemark }) + @ApiResponse({ status: 404, description: "Remark not found" }) + findOne(@Param("id") id: string): Promise { + return this.remarkService.findOne(id); + } + + @Post() + @ApiOperation({ summary: "Create a new remark" }) + @ApiResponse({ status: 201, description: "Remark created", type: TMRemark }) + @ApiResponse({ status: 404, description: "Task not found" }) + create(@Body() body: CreateRemarkDto): Promise { + return this.remarkService.create(body); + } + + @Patch(":id") + @ApiOperation({ summary: "Update a remark" }) + @ApiParam({ name: "id", description: "Remark ID" }) + @ApiResponse({ status: 200, description: "Remark updated", type: TMRemark }) + @ApiResponse({ status: 404, description: "Remark or Task not found" }) + update(@Param("id") id: string, @Body() body: UpdateRemarkDto): Promise { + return this.remarkService.update(id, body); + } + + @Delete(":id") + @ApiOperation({ summary: "Delete a remark" }) + @ApiParam({ name: "id", description: "Remark ID" }) + @ApiResponse({ status: 200, description: "Remark deleted" }) + @ApiResponse({ status: 404, description: "Remark not found" }) + remove(@Param("id") id: string): Promise { + return this.remarkService.remove(id); + } +}