Merge pull request #257 from Kitzanos/ndg-response-fix-prod
Cherry-pick (Fix the Custom validation on NDG quick response from 400 to 200 .)
This commit is contained in:
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -171,8 +171,9 @@ public class AppointmentDao {
|
|||||||
HubEntity hub = hubRepository.findByHubId(application.getHubId());
|
HubEntity hub = hubRepository.findByHubId(application.getHubId());
|
||||||
loginToOdessa(hub, application);
|
loginToOdessa(hub, application);
|
||||||
startAsyncNdgProcessing(applicationId);
|
startAsyncNdgProcessing(applicationId);
|
||||||
throw new CustomValidationException(Status.SUCCESS, Translator.toLocale(GepafinConstant.NDG_GENERATION_IS_IN_PROGRESS));
|
return ndgResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
private HubEntity loginToOdessa(HubEntity hub, ApplicationEntity application) {
|
private HubEntity loginToOdessa(HubEntity hub, ApplicationEntity application) {
|
||||||
try {
|
try {
|
||||||
//code to generate token with payload having "iat" epoch timestamp and secret key with no expiry and send in below method call
|
//code to generate token with payload having "iat" epoch timestamp and secret key with no expiry and send in below method call
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package net.gepafin.tendermanagement.repositories;
|
package net.gepafin.tendermanagement.repositories;
|
||||||
|
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
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.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
@@ -170,4 +172,9 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
|
|||||||
|
|
||||||
ApplicationEntity findByIdAndCompanyIdAndIsDeletedFalse(Long id,Long companyId);
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,10 @@ public class AppointmentController implements AppointmentApi {
|
|||||||
|
|
||||||
NdgResponse appointmentLoginResponse = appointmentService.checkNdgForAppointment(request, applicationId);
|
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
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user