fetchdocumentById in dms
5 open threads
5 open threads
Merge request reports
Activity
189 await logInsertToDocumentsAuditLogs( 190 this.prisma, 191 'document_audit_logs', 192 { 193 logDetails: { 194 document_id: document?.document_id, 195 action: Action.FETCH, 196 performed_by: 'system', 197 performed_at: new Date(), 198 status: Status.FAILURE, 199 error_message: error.message, 200 created_at: new Date(), 201 }, 202 }, 203 ); 204 throw new InternalServerErrorException('Failed to fetch document'); changed this line in version 2 of the diff
216 * 217 * @param prisma 218 * @param model 219 * @param args 220 */ 221 export async function logInsertToDocumentsAuditLogs( 222 prisma: PrismaClient, 223 model: string, 224 args: LogInsertionDocumentsAuditLogsArgs, 225 ): Promise<any> { 226 const { 227 logDetails, 228 229 230 } = args; 231 await prisma[model].create({ changed this line in version 2 of the diff
124 * 125 * @param documentId 126 */ 127 async fetchDocument(documentId: string) { 128 const document = await this.prisma.documents.findUnique({ 129 where: {document_id: documentId}, 130 }); 131 132 if (!document) throw new NotFoundException('Document not found'); 133 134 try { 135 // const file = await this.fileNetClient.get(document.document_id);//mock 136 if (document.source === 'FILENET') { 137 // Mock behavior: randomly return either base64 or presigned URL 138 const usePresignedUrl = 139 document.document_link !== null && Math.random() > 0.5; changed this line in version 2 of the diff
126 @ApiConsumes('application/json') 127 @ApiBody({ 128 description: 'Fetch document by id request', 129 type: FetchDocumentRequestDto, 130 }) 131 @ApiResponse({ 132 status: 200, 133 description: 'Document fetched successfully', 134 type: FetchDocumentResponseDto, 135 }) 136 async download( 137 @Body() body: FetchDocumentRequestDto, 138 ): Promise<FetchDocumentResponseDto> { 139 const result = await this.documentService.fetchDocument(body.id); 140 if (!result) { 141 throw new NotFoundException('Document not found'); changed this line in version 4 of the diff
125 126 /** 127 * 128 * @param documentId 129 */ 130 async fetchDocument(documentId: string) { 131 const document = await this.prisma.documents.findUnique( 132 { 133 where: { 134 document_id: documentId, 135 }, 136 }, 137 ); 138 139 if (!document) throw new NotFoundException('Document not found'); changed this line in version 3 of the diff
added 1 commit
- e24012d5 - fetchdocumentbyid-review-changes-implemented
added 1 commit
- 6a4ac238 - fetchdocumentbyid-review-changes-implemented-1
added 1 commit
- 9224bc2f - fetchdocumentbyid-review-changes-implemented-2
Please register or sign in to reply