Merge pull request #251 from Kitzanos/feature/GEPAFINBE-192

GEPAFINBE-192 (Fix the Custom validation on NDG quick response from 400 to 200 status code)
This commit is contained in:
Rinaldo
2025-03-24 15:54:43 +01:00
committed by GitHub
4 changed files with 32 additions and 2 deletions

View File

@@ -0,0 +1,19 @@
package net.gepafin.tendermanagement.config;
import jakarta.annotation.PostConstruct;
import net.gepafin.tendermanagement.constants.GepafinConstant;
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class NdgStatusResetHandler {
@Autowired
private ApplicationRepository applicationRepository;
@PostConstruct
public void resetNdgStatusOnStartup() {
applicationRepository.resetNdgStatusForInProgress(GepafinConstant.NDG_IN_PROGRESS);
}
}

View File

@@ -171,8 +171,9 @@ public class AppointmentDao {
HubEntity hub = hubRepository.findByHubId(application.getHubId());
loginToOdessa(hub, application);
startAsyncNdgProcessing(applicationId);
throw new CustomValidationException(Status.SUCCESS, Translator.toLocale(GepafinConstant.NDG_GENERATION_IS_IN_PROGRESS));
return ndgResponse;
}
private HubEntity loginToOdessa(HubEntity hub, ApplicationEntity application) {
try {
//code to generate token with payload having "iat" epoch timestamp and secret key with no expiry and send in below method call

View File

@@ -1,8 +1,10 @@
package net.gepafin.tendermanagement.repositories;
import jakarta.transaction.Transactional;
import net.gepafin.tendermanagement.entities.ApplicationEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
@@ -170,4 +172,9 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
ApplicationEntity findByIdAndCompanyIdAndIsDeletedFalse(Long id,Long companyId);
@Modifying
@Transactional
@Query("UPDATE ApplicationEntity a SET a.ndgStatus = NULL WHERE a.ndgStatus = :status")
void resetNdgStatusForInProgress(@Param("status") String status);
}

View File

@@ -43,7 +43,10 @@ public class AppointmentController implements AppointmentApi {
NdgResponse appointmentLoginResponse = appointmentService.checkNdgForAppointment(request, applicationId);
return ResponseEntity.status(HttpStatus.OK).body(new Response<>(appointmentLoginResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.NDG_FETCH_SUCCESSFULLY)));
// Determine the appropriate message
String responseMessage = (appointmentLoginResponse.getNdg() == null) ? Translator.toLocale(GepafinConstant.NDG_GENERATION_IS_IN_PROGRESS) : Translator.toLocale(GepafinConstant.NDG_FETCH_SUCCESSFULLY);
// Return response immediately with 200 OK
return ResponseEntity.status(HttpStatus.OK).body(new Response<>(appointmentLoginResponse, Status.SUCCESS, responseMessage));
}
@Override