我想使用 3 条路线:“项目”;'项目/1'; “项目/作者”。但是当我调用“项目/作者”时,触发了“项目/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));
}
}
Run Code Online (Sandbox Code Playgroud)