Skip to content
Snippets Groups Projects
Commit 1f0e0b1d authored by Manjunath Kumar's avatar Manjunath Kumar
Browse files

fetchdocumentById- review-changes

parent 9224bc2f
No related branches found
No related tags found
1 merge request!3fetchdocumentById in dms
......@@ -122,7 +122,6 @@ export class DocumentController {
'Fetches a document by its unique identifier and returns its metadata ' +
'or download link.',
})
@ApiConsumes('application/json')
@ApiBody({
description: 'Fetch document by id request',
type: FetchDocumentRequestDto,
......
......@@ -23,8 +23,8 @@ import {FetchDocumentResponseDto} from './dto/fetch-document-response.dto';
import {v4 as uuidv4 } from 'uuid';
import {Action, Status } from '@prisma/client';
import {
LogInsertionDocumentsAuditLogsArgs,
} from './interfaces/log-insertion-documents-audit-logs-args.interface';
LogAuditLogsArgs,
} from './interfaces/log-audit-logs.interface';
/**
......@@ -137,26 +137,27 @@ export class DocumentService {
* @returns Object with either base64 file data or a presigned URL
*/
async fetchDocument(
dto: FetchDocumentRequestDto
fetchDocumentRequestDto: FetchDocumentRequestDto
): Promise<FetchDocumentResponseDto> {
try {
const document = await this.prisma.documents.findUnique(
{
where: {
document_id: dto.id,
document_id: fetchDocumentRequestDto.id,
},
},
);
if (!document) throw new AppException('981', 'Document not found');
try {
// const file = await this.fileNetClient.get(document.document_id);//mock
if (document.source === 'FILENET') {
const auditLogArgsBase64 = {
logDetails: {
document_id: document?.document_id,
action: Action.FETCH,
performed_by: 'system',
performed_by: 'user',
performed_at: new Date(),
status: Status.SUCCESS,
error_message: null,
......@@ -183,7 +184,7 @@ export class DocumentService {
logDetails: {
document_id: document?.document_id,
action: Action.FETCH,
performed_by: 'system',
performed_by: 'user',
performed_at: new Date(),
status: Status.SUCCESS,
error_message: null,
......@@ -207,9 +208,9 @@ export class DocumentService {
this.logger.error('Failed to fetch document:', error);
const auditLogArgsError = {
logDetails: {
document_id: document?.document_id,
document_id: fetchDocumentRequestDto.id,
action: Action.FETCH,
performed_by: 'system',
performed_by: 'user',
performed_at: new Date(),
status: Status.FAILURE,
error_message: error.message,
......@@ -225,8 +226,8 @@ export class DocumentService {
}
async logInsertToDocumentsAuditLogs(
args: LogInsertionDocumentsAuditLogsArgs,
): Promise<any> {
args: LogAuditLogsArgs,
): Promise<boolean> {
const { logDetails } = args;
await this.prisma.document_audit_logs.create({
data: {
......
import { ApiProperty } from '@nestjs/swagger';
import { IsUUID } from 'class-validator';
import { IsUUID, IsNotEmpty } from 'class-validator';
export class FetchDocumentRequestDto {
@ApiProperty({ example: 'a1b2c3d4-e5f6-7890-1234-567890abcdef' })
@IsUUID()
@IsNotEmpty()
id: string;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment