From 51dcb0fa5a50bf72b8e1456b3db696081ee8a2d2 Mon Sep 17 00:00:00 2001 From: vishnu vinay Date: Tue, 26 Nov 2024 14:28:50 +0530 Subject: [PATCH] Aadhaar check before upload or fetching any other documents. --- src/modules/user-docs/user-docs.service.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/modules/user-docs/user-docs.service.ts b/src/modules/user-docs/user-docs.service.ts index 9f252e7..8715d85 100644 --- a/src/modules/user-docs/user-docs.service.ts +++ b/src/modules/user-docs/user-docs.service.ts @@ -48,6 +48,21 @@ export class UserDocsService { errorMessage: `Document with doc_id ${createUserDocDto.doc_id} already exists`, }); } + const checkAadhaarExist = await this.userDocsRepository.findOne({ + where: { sso_id: ssoId , doc_subtype:'aadhaar' }, + }); + if(checkAadhaarExist && createUserDocDto.doc_subtype==="aadhaar" ) { + return new ErrorResponse({ + statusCode: 409, + errorMessage: `Aadhaar already added to wallet`, + }); + } + if (!checkAadhaarExist && createUserDocDto.doc_subtype!=="aadhaar") { + return new ErrorResponse({ + statusCode: 400, + errorMessage: `Please add Aadhaar first before adding any other document to wallet`, + }); + } const userDoc = this.userDocsRepository.create({...createUserDocDto,sso_id:ssoId}); await this.userDocsRepository.save(userDoc);