79 lines
2.0 KiB
TypeScript
79 lines
2.0 KiB
TypeScript
import { Controller, Get, Post, Patch, Delete, Param, Body, Query } from '@nestjs/common';
|
|
import { RequirementService } from './requirement.service';
|
|
import { CreateRequirementDto } from './dto/create-requirement.dto';
|
|
import { UpdateRequirementDto } from './dto/update-requirement.dto';
|
|
import { UpdateRequirementStatusDto } from './dto/update-requirement-status.dto';
|
|
|
|
@Controller('products/:productId/requirements')
|
|
export class RequirementController {
|
|
constructor(private readonly requirementService: RequirementService) {}
|
|
|
|
@Post()
|
|
create(
|
|
@Param('productId') productId: string,
|
|
@Body() dto: CreateRequirementDto,
|
|
) {
|
|
return this.requirementService.create(productId, dto);
|
|
}
|
|
|
|
@Get()
|
|
findAll(
|
|
@Param('productId') productId: string,
|
|
@Query('status') status?: string,
|
|
@Query('projectId') projectId?: string,
|
|
@Query('versionId') versionId?: string,
|
|
@Query('priority') priority?: string,
|
|
@Query('type') type?: string,
|
|
@Query('q') q?: string,
|
|
@Query('sort') sort?: string,
|
|
@Query('cursor') cursor?: string,
|
|
@Query('limit') limit?: string,
|
|
) {
|
|
return this.requirementService.findAll(productId, {
|
|
projectId,
|
|
versionId,
|
|
status,
|
|
priority,
|
|
type,
|
|
q,
|
|
sort,
|
|
cursor,
|
|
limit,
|
|
});
|
|
}
|
|
|
|
@Get(':id')
|
|
findOne(
|
|
@Param('productId') productId: string,
|
|
@Param('id') id: string,
|
|
) {
|
|
return this.requirementService.findOne(productId, id);
|
|
}
|
|
|
|
@Patch(':id')
|
|
update(
|
|
@Param('productId') productId: string,
|
|
@Param('id') id: string,
|
|
@Body() dto: UpdateRequirementDto,
|
|
) {
|
|
return this.requirementService.update(productId, id, dto);
|
|
}
|
|
|
|
@Patch(':id/status')
|
|
updateStatus(
|
|
@Param('productId') productId: string,
|
|
@Param('id') id: string,
|
|
@Body() dto: UpdateRequirementStatusDto,
|
|
) {
|
|
return this.requirementService.updateStatus(productId, id, dto.status);
|
|
}
|
|
|
|
@Delete(':id')
|
|
remove(
|
|
@Param('productId') productId: string,
|
|
@Param('id') id: string,
|
|
) {
|
|
return this.requirementService.remove(productId, id);
|
|
}
|
|
}
|