Skip to content

Commit ff32071

Browse files
committed
feat: rota de buscar um documento especifico por usuario
1 parent d799d34 commit ff32071

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/controllers/client.controller.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,24 @@ export class ClientController {
3636
})
3737
}
3838

39-
@Get('/documents')
39+
@Get('/document')
4040
@UseGuards(AuthGuard)
4141
async findAllDocumentsByClient(@Req() request: UserRequest) {
4242
return await this.documentService.findAll({ clientId: request.user.sub })
4343
}
4444

45+
@Get('/document/:id')
46+
@UseGuards(AuthGuard)
47+
async findOneDocumentByClient(
48+
@Param('id') id: string,
49+
@Req() request: UserRequest,
50+
) {
51+
return await this.documentService.findAll({
52+
id: id,
53+
clientId: request.user.sub,
54+
})
55+
}
56+
4557
@Get()
4658
findAll() {
4759
return this.clientService.findAll()

src/services/document.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ export class DocumentService {
3737
return await this.create(createDocumentDto)
3838
}
3939

40-
async findAll(data: any) {
41-
return await this.documentRepository.documents({ where: data })
40+
async findAll(params: any) {
41+
return await this.documentRepository.documents({ where: params })
4242
}
4343

4444
async findOne(id: string) {

0 commit comments

Comments
 (0)