mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-08-26 06:09:41 +00:00
25 lines
912 B
TypeScript
25 lines
912 B
TypeScript
import { Injectable, NotFoundException } from '@nestjs/common';
|
|
import { UploadDocumentRequestDto } from '../dtos/request';
|
|
import { DocumentRepository } from '../repositories';
|
|
import { OciService } from './oci.service';
|
|
|
|
@Injectable()
|
|
export class DocumentService {
|
|
constructor(private readonly ociService: OciService, private readonly documentRepository: DocumentRepository) {}
|
|
async createDocument(file: Express.Multer.File, uploadedDocumentRequest: UploadDocumentRequestDto) {
|
|
const uploadedFile = await this.ociService.uploadFile(file, uploadedDocumentRequest);
|
|
console.log('test');
|
|
return this.documentRepository.createDocument(uploadedFile);
|
|
}
|
|
|
|
async findDocumentById(documentId: string) {
|
|
const document = await this.documentRepository.findDocumentById(documentId);
|
|
|
|
if (!document) {
|
|
throw new NotFoundException('DOCUMENT.NOT_FOUND');
|
|
}
|
|
|
|
return document;
|
|
}
|
|
}
|