mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2026-10-26 04:17:56 +00:00
feat: add validation for documents
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user