feat: add validation for documents

This commit is contained in:
Abdalhamid Alhamad
2025-01-13 11:43:28 +03:00
parent 756e947c8a
commit 62621c1a15
12 changed files with 195 additions and 13 deletions
+7 -2
View File
@@ -9,14 +9,19 @@ import { OciService } from './oci.service';
export class DocumentService {
private readonly logger = new Logger(DocumentService.name);
constructor(private readonly ociService: OciService, private readonly documentRepository: DocumentRepository) {}
async createDocument(file: Express.Multer.File, uploadedDocumentRequest: UploadDocumentRequestDto) {
async createDocument(file: Express.Multer.File, uploadedDocumentRequest: UploadDocumentRequestDto, userId: string) {
this.logger.log(`creating document for with type ${uploadedDocumentRequest.documentType}`);
const uploadedFile = await this.ociService.uploadFile(file, uploadedDocumentRequest);
return this.documentRepository.createDocument(uploadedFile);
return this.documentRepository.createDocument(userId, uploadedFile);
}
findDocuments(where: FindOptionsWhere<Document>) {
this.logger.log(`finding documents with where clause ${JSON.stringify(where)}`);
return this.documentRepository.findDocuments(where);
}
findDocumentById(id: string) {
this.logger.log(`finding document with id ${id}`);
return this.documentRepository.findDocumentById(id);
}
}