64 lines
1.6 KiB
TypeScript
64 lines
1.6 KiB
TypeScript
import { Controller, Get, Post, Patch, Body, Param, Query, UseGuards } from '@nestjs/common';
|
|
import { TaskService } from './task.service';
|
|
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
|
import { TenantId } from '../tenant/tenant.decorator';
|
|
|
|
@Controller('tasks')
|
|
@UseGuards(JwtAuthGuard)
|
|
export class TaskController {
|
|
constructor(private taskService: TaskService) {}
|
|
|
|
@Get()
|
|
async listTasks(
|
|
@TenantId() tenantId: string,
|
|
@Query('status') status?: string,
|
|
@Query('assignedToId') assignedToId?: string,
|
|
@Query('relatedObjectType') relatedObjectType?: string,
|
|
@Query('relatedObjectId') relatedObjectId?: string,
|
|
) {
|
|
return this.taskService.listTasks(tenantId, {
|
|
status,
|
|
assignedToId,
|
|
relatedObjectType,
|
|
relatedObjectId,
|
|
});
|
|
}
|
|
|
|
@Post()
|
|
async createTask(
|
|
@TenantId() tenantId: string,
|
|
@Body()
|
|
body: {
|
|
title: string;
|
|
description?: string;
|
|
status?: string;
|
|
priority?: string;
|
|
dueAt?: string;
|
|
assignedToId?: string;
|
|
relatedObjectType?: string;
|
|
relatedObjectId?: string;
|
|
},
|
|
) {
|
|
return this.taskService.createTask(tenantId, body);
|
|
}
|
|
|
|
@Patch(':taskId')
|
|
async updateTask(
|
|
@TenantId() tenantId: string,
|
|
@Param('taskId') taskId: string,
|
|
@Body()
|
|
body: {
|
|
title?: string;
|
|
description?: string;
|
|
status?: string;
|
|
priority?: string;
|
|
dueAt?: string;
|
|
assignedToId?: string;
|
|
relatedObjectType?: string;
|
|
relatedObjectId?: string;
|
|
},
|
|
) {
|
|
return this.taskService.updateTask(tenantId, taskId, body);
|
|
}
|
|
}
|