From 3eee4dda149ba591b7167e87a60b5ffe22d36078 Mon Sep 17 00:00:00 2001 From: rajesh Date: Tue, 22 Oct 2024 17:18:49 +0530 Subject: [PATCH] Fixed prod Document issue --- .../net/gepafin/tendermanagement/dao/CallDao.java | 12 ++++++------ .../repositories/DocumentRepository.java | 7 +++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/gepafin/tendermanagement/dao/CallDao.java b/src/main/java/net/gepafin/tendermanagement/dao/CallDao.java index 0827b62a..0277b678 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/CallDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/CallDao.java @@ -239,7 +239,7 @@ public class CallDao { } List existingDocuments = documentRepository - .findBySourceIdAndTypeAndIsDeletedFalse(sourceId, documentType.getValue()); + .findBySourceIdAndSourceAndTypeAndIsDeletedFalse(sourceId, DocumentSourceTypeEnum.CALL.getValue(), documentType.getValue()); List incomingIds = documentReqList.stream().map(DocumentReq::getId).filter(id -> id != null && id > 0) .collect(Collectors.toList()); @@ -259,7 +259,7 @@ public class CallDao { private DocumentEntity convertToDocumentEntity(DocumentReq documentReq,Long sourceId) { validateDocumentEntity(documentReq.getId()); - DocumentEntity documentEntity = documentRepository.findByIdAndSourceIdAndIsDeletedFalse(documentReq.getId(),sourceId) + DocumentEntity documentEntity = documentRepository.findByIdAndSourceIdAndAndSourceAndIsDeletedFalse(documentReq.getId(),sourceId, DocumentSourceTypeEnum.CALL.getValue()) .orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.DOCUMENT_NOT_FOUND))); return documentEntity; @@ -618,10 +618,10 @@ public class CallDao { } private CallResponse getCallResponseBean(CallEntity callEntity) { - List documentEntities = documentRepository.findBySourceIdAndTypeAndIsDeletedFalse(callEntity.getId(), - DocumentTypeEnum.DOCUMENT.getValue()); - List imageEntities = documentRepository.findBySourceIdAndTypeAndIsDeletedFalse(callEntity.getId(), - DocumentTypeEnum.IMAGES.getValue()); + List documentEntities = documentRepository.findBySourceIdAndSourceAndTypeAndIsDeletedFalse(callEntity.getId(),DocumentSourceTypeEnum.CALL.getValue() + , DocumentTypeEnum.DOCUMENT.getValue()); + List imageEntities = documentRepository.findBySourceIdAndSourceAndTypeAndIsDeletedFalse(callEntity.getId(), DocumentSourceTypeEnum.CALL.getValue() + , DocumentTypeEnum.IMAGES.getValue()); List amiedTo = callTargetAudienceChecklistRepository .findByCallIdAndLookupDataTypeAndIsDeletedFalse(callEntity.getId(), LookUpDataTypeEnum.AIMED_TO.getValue()).stream() .map(this::convertToLookUpDataResponseBean).toList(); diff --git a/src/main/java/net/gepafin/tendermanagement/repositories/DocumentRepository.java b/src/main/java/net/gepafin/tendermanagement/repositories/DocumentRepository.java index 1543def3..a86ef8fd 100644 --- a/src/main/java/net/gepafin/tendermanagement/repositories/DocumentRepository.java +++ b/src/main/java/net/gepafin/tendermanagement/repositories/DocumentRepository.java @@ -15,12 +15,15 @@ public interface DocumentRepository extends JpaRepository @Query("SELECT d FROM DocumentEntity d WHERE d.id = :id AND d.isDeleted = false") Optional findById(@Param("id") Long id); - List findBySourceIdAndTypeAndIsDeletedFalse(Long sourceId, String type); +// List findBySourceIdAndTypeAndIsDeletedFalse(Long sourceId, String type); - Optional findByIdAndSourceIdAndIsDeletedFalse(Long id, Long sourceId); +// Optional findByIdAndSourceIdAndIsDeletedFalse(Long id, Long sourceId); List findBySource(String source); + List findBySourceIdAndSourceAndTypeAndIsDeletedFalse(Long sourceId, String source, String type); + Optional findByIdAndSourceIdAndAndSourceAndIsDeletedFalse(Long id, Long sourceId, String source); + }