You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
2.7 KiB
Java

package com.vmis.interfaceapp.service;
import com.vmis.interfaceapp.config.properties.VmisProperties;
import com.vmis.interfaceapp.model.basic.BasicRequest;
import com.vmis.interfaceapp.model.common.Envelope;
import com.vmis.interfaceapp.model.ledger.LedgerRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
/**
* Populates incoming request models with values from YAML configuration.
* Unconditionally overwrites the listed fields per requirement:
* - INFO_SYS_ID, INFO_SYS_IP, SIGUNGU_CODE
* - CNTC_INFO_CODE (service specific)
* - CHARGER_ID, CHARGER_IP, CHARGER_NM
*/
@Component
public class RequestEnricher {
private static final Logger log = LoggerFactory.getLogger(RequestEnricher.class);
private final VmisProperties props;
public RequestEnricher(VmisProperties props) {
this.props = props;
}
public void enrichBasic(Envelope<BasicRequest> envelope) {
if (envelope == null || envelope.getData() == null) return;
VmisProperties.SystemProps sys = props.getSystem();
String cntc = props.getGov().getServices().getBasic().getCntcInfoCode();
for (BasicRequest req : envelope.getData()) {
if (req == null) continue;
req.setInfoSysId(sys.getInfoSysId());
req.setInfoSysIp(sys.getInfoSysIp());
req.setSigunguCode(sys.getRegionCode());
req.setCntcInfoCode(cntc);
req.setChargerId(sys.getChargerId());
req.setChargerIp(sys.getChargerIp());
req.setChargerNm(sys.getChargerNm());
}
log.debug("[ENRICH] basic: applied INFO_SYS_ID={}, INFO_SYS_IP={}, SIGUNGU_CODE={}, CNTC_INFO_CODE={}",
sys.getInfoSysId(), sys.getInfoSysIp(), sys.getRegionCode(), cntc);
}
public void enrichLedger(Envelope<LedgerRequest> envelope) {
if (envelope == null || envelope.getData() == null) return;
VmisProperties.SystemProps sys = props.getSystem();
String cntc = props.getGov().getServices().getLedger().getCntcInfoCode();
for (LedgerRequest req : envelope.getData()) {
if (req == null) continue;
req.setInfoSysId(sys.getInfoSysId());
req.setInfoSysIp(sys.getInfoSysIp());
req.setSigunguCode(sys.getRegionCode());
req.setCntcInfoCode(cntc);
req.setChargerId(sys.getChargerId());
req.setChargerIp(sys.getChargerIp());
req.setChargerNm(sys.getChargerNm());
}
log.debug("[ENRICH] ledger: applied INFO_SYS_ID={}, INFO_SYS_IP={}, SIGUNGU_CODE={}, CNTC_INFO_CODE={}",
sys.getInfoSysId(), sys.getInfoSysIp(), sys.getRegionCode(), cntc);
}
}