From 6bb531789a0d2276e54644f71ca0e56c6e5648c6 Mon Sep 17 00:00:00 2001 From: rajesh Date: Tue, 11 Feb 2025 18:24:18 +0530 Subject: [PATCH] Changes in create Application api for gepafin --- .../tendermanagement/dao/ApplicationDao.java | 16 ++++++++++++++++ .../repositories/ApplicationRepository.java | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java index 35ecc113..fb2a1749 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java @@ -888,6 +888,10 @@ public class ApplicationDao { checkCallEndDate(call); // call = callService.validatePublishedCall(call.getId()); // checkIfApplicationExists(call, userWithCompanyEntity, userEntity); + HubEntity hubEntity = hubService.valdateHub(call.getHub().getId()); + if(hubEntity.getUniqueUuid().equals(defaultHubUuid)){ + checkIfApplicationExists(call, userWithCompanyEntity, userEntity); + } ApplicationEntity applicationEntity = createApplicationEntity(userEntity, call, userWithCompanyEntity); applicationEntity.setComments(applicationRequest.getComments()); applicationEntity = saveApplicationEntity(applicationEntity); @@ -900,6 +904,18 @@ public class ApplicationDao { // } // } + public void checkIfApplicationExists(CallEntity call, UserWithCompanyEntity userWithCompanyEntity, UserEntity userEntity){ + + List applications = applicationRepository.findByUserIdAndUserWithCompany_IdAndCall_IdAndIsDeletedFalseAndStatusNot( + userEntity.getId(), userWithCompanyEntity.getId(), call.getId(), ApplicationStatusTypeEnum.REJECTED.name() + ); + + if (!applications.isEmpty()) { + throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_ALREADY_EXISTS)); + } + } + + public ApplicationResponse updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status) { ApplicationEntity applicationEntity = validateApplication(applicationId); diff --git a/src/main/java/net/gepafin/tendermanagement/repositories/ApplicationRepository.java b/src/main/java/net/gepafin/tendermanagement/repositories/ApplicationRepository.java index 2434fac9..5ed76d55 100644 --- a/src/main/java/net/gepafin/tendermanagement/repositories/ApplicationRepository.java +++ b/src/main/java/net/gepafin/tendermanagement/repositories/ApplicationRepository.java @@ -158,4 +158,8 @@ public interface ApplicationRepository extends JpaRepository findByUserIdAndUserWithCompany_IdAndCall_IdAndIsDeletedFalseAndStatusNot( + Long userId, Long userWithCompanyId, Long callId, String status + ); }