【发布时间】:2021-11-13 16:05:14
【问题描述】:
我想使用 3 条路线:“项目”; “项目/1”; “项目/作者”。 但是当我调用“project/authors”时,触发了“project/1”,我得到了一个错误。如何避免?
@Controller('project')
export class ProjectController {
@Get()
async getProjects(@Res() res): Promise<ProjectDto[]> {
return await this.projectService.getProjects(0, 0).then(projects => res.json(projects));
}
@Get(':id')
async getProject(@Param('id', new ParseIntPipe()) id, @Res() res): Promise<ProjectDto> {
return await this.projectService.getProjects(id).then(project => res.json(project[0]));
}
@Get('/authors')
async getAuthors(@Res() res): Promise<AuthorDto[]> {
return await this.projectService.getAuthors().then(authors => res.json(authors));
}
}
【问题讨论】: