update application

Nabeel-DG-BS
rnabeel 1 year ago
parent 2f1d762419
commit e25d74128c

@ -2,6 +2,8 @@ package com.mfsys.uco.service;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.mfsys.comm.constant.EurekaRegisteredMicroServicesURI;
import com.mfsys.comm.constant.SecurityURI;
import com.mfsys.uco.constants.UCOConstants; import com.mfsys.uco.constants.UCOConstants;
import com.mfsys.uco.constants.UCOURI; import com.mfsys.uco.constants.UCOURI;
import com.mfsys.uco.dto.AccountInquiryResponse; import com.mfsys.uco.dto.AccountInquiryResponse;
@ -16,7 +18,10 @@ import com.mfsys.uco.model.CustomerProfile;
import com.mfsys.uco.model.UcoAccount; import com.mfsys.uco.model.UcoAccount;
import com.mfsys.uco.repository.CustomerProfileRepository; import com.mfsys.uco.repository.CustomerProfileRepository;
import com.mfsys.uco.repository.UCOAccountRepository; import com.mfsys.uco.repository.UCOAccountRepository;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.*; import java.util.*;
@ -27,12 +32,14 @@ public class UcoAccountService {
private final CustomerProfileRepository customerProfileRepository; private final CustomerProfileRepository customerProfileRepository;
private final UCOAccountRepository ucoAccountRepository; private final UCOAccountRepository ucoAccountRepository;
private final CustomerProfileService customerProfileService; private final CustomerProfileService customerProfileService;
@LoadBalanced
private final WebClient webClient;
private final WebClientDepositService webClientDeposit; private final WebClientDepositService webClientDeposit;
private final WebClientCrmService webClientCrmService; private final WebClientCrmService webClientCrmService;
public UcoAccountService(CustomerProfileRepository customerProfileRepository, UCOAccountRepository ucoAccountRepository, CustomerProfileService customerProfileService, WebClientDepositService webClientDeposit, WebClientCrmService webClientCrmService public UcoAccountService(WebClient.Builder webClientBuilder,CustomerProfileRepository customerProfileRepository, UCOAccountRepository ucoAccountRepository, CustomerProfileService customerProfileService, WebClientDepositService webClientDeposit, WebClientCrmService webClientCrmService
,ObjectMapper objectMapper) { ,ObjectMapper objectMapper) {
this.webClient = webClientBuilder.baseUrl(EurekaRegisteredMicroServicesURI.SECURITY_SERVICE_LB).build();
this.customerProfileRepository = customerProfileRepository; this.customerProfileRepository = customerProfileRepository;
this.ucoAccountRepository = ucoAccountRepository; this.ucoAccountRepository = ucoAccountRepository;
this.customerProfileService = customerProfileService; this.customerProfileService = customerProfileService;
@ -111,6 +118,14 @@ public class UcoAccountService {
.sgtLasttrandate(LocalDate.now()) .sgtLasttrandate(LocalDate.now())
.build(); .build();
ucoAccountRepository.save(ucoAccount); ucoAccountRepository.save(ucoAccount);
updateCustomerApplication(Map.of("email",customerProfile.getCmpEmail(),"porOrgacode",porOrgacode));
}
private void updateCustomerApplication(Map<String, String> payload) {
webClient.post().uri(SecurityURI.UPDATE_CUSTOMER_APPLICATION).bodyValue(payload).retrieve()
.onStatus(status -> status.is4xxClientError() || status.is5xxServerError(), clientResponse
-> Mono.error(new RuntimeException("Response has error status."))).bodyToMono(String.class);
} }

Loading…
Cancel
Save