refactor: removed unnecessary functions from taskphase
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Controller, Get, Post, Patch, Delete, Param, Body, Query } from "@nestjs/common";
|
||||
import { ApiTags, ApiOperation, ApiResponse, ApiParam, ApiQuery } from "@nestjs/swagger";
|
||||
import { Controller, Post, Patch, Delete, Param, Body } from "@nestjs/common";
|
||||
import { ApiTags, ApiOperation, ApiResponse, ApiParam } from "@nestjs/swagger";
|
||||
import { TaskPhaseService } from "../providers/task-phase.service";
|
||||
import { CreateTaskPhaseDto } from "../dto/task-phase/create-task-phase.dto";
|
||||
import { UpdateTaskPhaseDto } from "../dto/task-phase/update-task-phase.dto";
|
||||
@@ -17,24 +17,6 @@ import { PermissionEnum } from "../../users/enums/permission.enum";
|
||||
export class TaskPhaseController {
|
||||
constructor(private readonly taskPhaseService: TaskPhaseService) {}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: "Get all task phases, optionally filtered by project" })
|
||||
@ApiQuery({ name: "projectId", required: false, description: "Filter task phases by project ID" })
|
||||
@ApiResponse({ status: 200, description: "List of task phases", type: [TMTaskPhase] })
|
||||
findAll(@Query("projectId") projectId?: string): Promise<TMTaskPhase[]> {
|
||||
if (projectId) return this.taskPhaseService.findByProject(projectId);
|
||||
return this.taskPhaseService.findAll();
|
||||
}
|
||||
|
||||
@Get(":id")
|
||||
@ApiOperation({ summary: "Get a task phase by ID" })
|
||||
@ApiParam({ name: "id", description: "TaskPhase ID" })
|
||||
@ApiResponse({ status: 200, description: "TaskPhase found", type: TMTaskPhase })
|
||||
@ApiResponse({ status: 404, description: "TaskPhase not found" })
|
||||
findOne(@Param("id") id: string): Promise<TMTaskPhase> {
|
||||
return this.taskPhaseService.findOneOrFail(id);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@ApiOperation({ summary: "Create a new task phase" })
|
||||
@ApiResponse({ status: 201, description: "TaskPhase created", type: TMTaskPhase })
|
||||
|
||||
@@ -13,16 +13,6 @@ export class TaskPhaseService {
|
||||
private readonly projectService: ProjectService
|
||||
) {}
|
||||
|
||||
findAll(): Promise<TMTaskPhase[]> {
|
||||
return this.taskPhaseRepository.find();
|
||||
}
|
||||
|
||||
findByProject(projectId: string): Promise<TMTaskPhase[]> {
|
||||
return this.taskPhaseRepository.find({
|
||||
where: {projectId}
|
||||
});
|
||||
}
|
||||
|
||||
async findOneOrFail(id: string): Promise<TMTaskPhase> {
|
||||
const taskPhase = await this.taskPhaseRepository.findOne({where: {id}});
|
||||
if (!taskPhase) throw new NotFoundException(TaskPhaseMessage.TASK_PHASE_NOT_FOUND);
|
||||
|
||||
Reference in New Issue
Block a user