개발서버에 push위해
This commit is contained in:
@@ -33,6 +33,15 @@ import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.common.util.MessageUtil;
|
||||
import com.eactive.eai.common.util.UUIDGenerator;
|
||||
import com.eactive.eai.inbound.error.InboundErrorInfoVO;
|
||||
import com.kjbank.encrypt.exchange.crypto.AES256Cipher;
|
||||
import com.kjbank.encrypt.exchange.crypto.AES256GCMCipher;
|
||||
import com.kjbank.encrypt.exchange.crypto.AESCipher;
|
||||
|
||||
// jwhong
|
||||
import org.json.simple.JSONObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@RestController
|
||||
public class ApiAdapterController implements HttpAdapterServiceKey {
|
||||
@@ -45,7 +54,7 @@ public class ApiAdapterController implements HttpAdapterServiceKey {
|
||||
* KBANK 요구사항으로 /api/v1/oauth/token 과 같은 형태로 토큰 발급거래를 수행해야해서 예외처리함
|
||||
* @See com.eactive.eai.authserver.config.AuthorizationServerConfig.configure(AuthorizationServerEndpointsConfigurer endpoints)
|
||||
*/
|
||||
@RequestMapping(value = {"/api/*", "/api/*/{path:^(?!.*oauth).*$}/**"})
|
||||
@RequestMapping(value = {"/api/*", "/mapi/*", "/api/*/{path:^(?!.*oauth).*$}/**", "/mapi/*/{path:^(?!.*oauth).*$}/**"})
|
||||
// @RequestMapping(value = {"/api/**"})
|
||||
public ResponseEntity<String> callApi(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws Exception {
|
||||
// /ONLWeb/api/v1/public/getUserInfo.svc
|
||||
@@ -54,7 +63,16 @@ public class ApiAdapterController implements HttpAdapterServiceKey {
|
||||
apiUri = StringUtils.removeStart(apiUri, servletRequest.getContextPath());
|
||||
apiUri = StringUtils.removeEnd(apiUri, "/");
|
||||
HttpDynamicInAdapterUri adptUri = findAdptUri(apiUri, HttpDynamicInAdapterManager.getInstance());
|
||||
|
||||
//Received time , jwhong
|
||||
long receivedTimeMillis = System.currentTimeMillis();
|
||||
String receivedTimeStr = String.valueOf(receivedTimeMillis);
|
||||
|
||||
System.out.println("현재 시간 밀리초(long): " + receivedTimeMillis);
|
||||
System.out.println("현재 시간 밀리초(String): " + receivedTimeStr);
|
||||
//Timestamp timestamp = new Timestamp(System.currentTimeMillis());
|
||||
//System.out.println("현재 Timestamp: " + timestamp);
|
||||
|
||||
if (logger.isDebug()) {
|
||||
logger.debug("ApiAdapterController] service request uri : " + servletRequest.getRequestURI());
|
||||
}
|
||||
@@ -85,10 +103,26 @@ public class ApiAdapterController implements HttpAdapterServiceKey {
|
||||
String responseType = httpProp.getProperty(RESPONSE_TYPE, "SYNC");
|
||||
ResponseEntity responseEntity = null;
|
||||
Properties transactionProp = new Properties();
|
||||
//transactionProp.put(INBOUND_REQUESTED_TIME, receivedTimeMillis); // jwhong, put api received time
|
||||
transactionProp.put(INBOUND_REQUESTED_TIME, receivedTimeStr);
|
||||
|
||||
try {
|
||||
String responseData = service.callApi(servletRequest, servletResponse, httpProp, adapterGroupVO, adapterVO, transactionProp);
|
||||
if (RESPONSE_TYPE_ASYNC.equals(responseType)) {
|
||||
responseEntity = ResponseEntity.ok("dummy");
|
||||
// if (RESPONSE_TYPE_ASYNC.equals(responseType)) { // table의 값이 ASYNC 로 들어가 있는데 response_type_async는 ASYN 로 되어 있어 아래처럼 비교함 jwhong 2025
|
||||
if ("ASYNC".equals(responseType)) {
|
||||
//responseEntity = ResponseEntity.ok("dummy"); // comment by jwhong
|
||||
servletResponse.addHeader("traceId", responseData); // uuid를 response header에
|
||||
int httpStatus = servletResponse.getStatus();
|
||||
if (httpStatus == 200) {
|
||||
// 업체별 aync response message 가 다르다.
|
||||
String asyncMsgStyle = httpProp.getProperty("ASYNC_RTNMSG_TYPE", "").toUpperCase();
|
||||
//String responseBody = makeResponseBodyMsg(asyncMsgStyle);
|
||||
String responseBody = asyncMsgStyle;
|
||||
responseEntity = ResponseEntity.status(httpStatus).contentType(mediaType).body(responseBody);
|
||||
// jwhong
|
||||
} else {
|
||||
responseEntity = ResponseEntity.status(httpStatus).contentType(mediaType).body(responseData);
|
||||
}
|
||||
} else {
|
||||
// responseEntity = ResponseEntity.ok().contentType(mediaType).body(responseData);
|
||||
// 버즈빌 포인트 적립 처리하기 위하여 정상응답이더라도 응답코드(apiRsltCd) 값이 200이 아닌 경우 처리를 위하여 수정
|
||||
@@ -186,5 +220,35 @@ public class ApiAdapterController implements HttpAdapterServiceKey {
|
||||
|
||||
InboundErrorLogger.error(errorInfoVO);
|
||||
}
|
||||
|
||||
private String makeResponseBodyMsg(String asyncMsgStyle) {
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
dataMap.put("result", 1);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
||||
switch (asyncMsgStyle) {
|
||||
case "TB_SUC":
|
||||
map.put("rspCode", "TB_SUC_000");
|
||||
map.put("rspMsg", "정상");
|
||||
map.put("data", dataMap);
|
||||
break;
|
||||
case "ONLYDATA":
|
||||
map.put("data", dataMap);
|
||||
map.put("success", "true");
|
||||
break;
|
||||
default:
|
||||
map.put("code", "200");
|
||||
map.put("data", dataMap);
|
||||
map.put("message", "정상 처리 되었습니다.");
|
||||
break;
|
||||
}
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
json.putAll(map);
|
||||
|
||||
return json.toJSONString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user