|
@@ -1,25 +1,21 @@
|
|
|
package com.tsi.api.server.controller;
|
|
|
|
|
|
import com.tsi.api.server.controller.result.*;
|
|
|
-import com.tsi.api.server.dto.KafkaTokenAuthDto;
|
|
|
-import com.tsi.api.server.dto.KafkaTokenDto;
|
|
|
-import com.tsi.api.server.dto.SystemStatus2Dto;
|
|
|
-import com.tsi.api.server.dto.SystemStatusDto;
|
|
|
+import com.tsi.api.server.dto.*;
|
|
|
import com.tsi.api.server.error.TscSsipApiErrorCode;
|
|
|
import com.tsi.api.server.repository.TsiSystemStatusManager;
|
|
|
import com.tsi.api.server.service.TscSsipApiService;
|
|
|
import com.tsi.api.server.service.TscSsipKafkaTokenService;
|
|
|
import com.tsi.api.server.util.ApiUtils;
|
|
|
-import com.tsi.api.server.vo.ApiInvokeVo;
|
|
|
-import com.tsi.api.server.vo.BrokerVo;
|
|
|
-import com.tsi.api.server.vo.KafkaAuthorizedVo;
|
|
|
-import com.tsi.api.server.vo.SystemStatusVo;
|
|
|
+import com.tsi.api.server.vo.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
@Slf4j
|
|
@@ -42,13 +38,14 @@ public class TscSsipApiController {
|
|
|
this.tscSsipKafkaTokenService = tscSsipKafkaTokenService;
|
|
|
}
|
|
|
|
|
|
- @GetMapping(value = {SSIP_API_NODE_INFO}, produces = {"application/json; charset=utf8"})
|
|
|
- public ResponseEntity<AbstractTscSsipApiResult> getNodeInfo(@PathVariable("apiToken") String apiToken, HttpServletRequest request) {
|
|
|
+ @PostMapping(value = {SSIP_API_NODE_INFO}, produces = {"application/json; charset=utf8"})
|
|
|
+ public ResponseEntity<TscSsipApiResultNodeInfo> getNodeInfo(@PathVariable("apiToken") String apiToken, HttpServletRequest request) {
|
|
|
|
|
|
String apiId = SSIP_API_NODE_INFO;
|
|
|
String remoteIP = ApiUtils.getRemoteIP(request);
|
|
|
log.info("{}, {}, {}", apiId, remoteIP, apiToken);
|
|
|
|
|
|
+ List<NodeDto> resultData = new ArrayList<>();
|
|
|
ApiInvokeVo apiInvokeVo = ApiInvokeVo.builder()
|
|
|
.apiId(apiId)
|
|
|
.apiToken(apiToken)
|
|
@@ -57,15 +54,25 @@ public class TscSsipApiController {
|
|
|
.build();
|
|
|
|
|
|
try {
|
|
|
- TscSsipApiErrorCode authorizedInfo = this.tscSsipApiService.getAuthorizedInfo(apiId, apiToken, remoteIP);
|
|
|
- if (authorizedInfo != TscSsipApiErrorCode.SUCCESS) {
|
|
|
+ TscApiResultCode errorCode = this.tscSsipApiService.getTscAuthorizedInfo(apiId, apiToken, remoteIP);
|
|
|
+ if (errorCode != TscApiResultCode.SUCCESS) {
|
|
|
// api token 인증 오류
|
|
|
- log.error("인증오류: [{}] ==> [{}]: [{}].[{}]" + apiId, remoteIP, apiToken, authorizedInfo.getCode(), authorizedInfo.getMessage());
|
|
|
- apiInvokeVo.setError(authorizedInfo.getCode());
|
|
|
+ log.error("인증오류: [{}] ==> [{}]: [{}].[{}]" + apiId, remoteIP, apiToken, errorCode.getValue(), errorCode.toString());
|
|
|
+ apiInvokeVo.setError(errorCode.getValue());
|
|
|
this.tscSsipApiService.insertInvokeHs(apiInvokeVo, true);
|
|
|
- TscSsipApiResultError error = new TscSsipApiResultError(authorizedInfo.getCode(), authorizedInfo.getMessage());
|
|
|
- return new ResponseEntity<>(error, HttpStatus.UNAUTHORIZED);
|
|
|
+ //TscSsipApiResultError error = new TscSsipApiResultError(authorizedInfo.getCode(), authorizedInfo.getMessage());
|
|
|
+ //return new ResponseEntity<>(new TscSsipApiResultNodeInfo(errorCode, resultData), HttpStatus.UNAUTHORIZED);
|
|
|
+ return new ResponseEntity<>(new TscSsipApiResultNodeInfo(errorCode, resultData), HttpStatus.OK);
|
|
|
}
|
|
|
+
|
|
|
+ List<NodeVo> nodeInfoList = tscSsipApiService.getNodeInfoList();
|
|
|
+ nodeInfoList.forEach(obj -> {
|
|
|
+ resultData.add(obj.toDto());
|
|
|
+ });
|
|
|
+
|
|
|
+ // 이력저장
|
|
|
+ this.tscSsipApiService.insertInvokeHs(apiInvokeVo, true);
|
|
|
+ return new ResponseEntity<>(new TscSsipApiResultNodeInfo(errorCode, resultData), HttpStatus.OK);
|
|
|
}
|
|
|
catch (Exception e) {
|
|
|
log.error("getNodeInfo: {}", e.getMessage());
|
|
@@ -73,19 +80,19 @@ public class TscSsipApiController {
|
|
|
TscSsipApiResultError error = new TscSsipApiResultError(TscSsipApiErrorCode.ERROR_INTERNAL_DATA.getCode(), TscSsipApiErrorCode.ERROR_INTERNAL_DATA.getMessage());
|
|
|
apiInvokeVo.setError(TscSsipApiErrorCode.ERROR_INTERNAL_DATA.getCode());
|
|
|
this.tscSsipApiService.insertInvokeHs(apiInvokeVo, true);
|
|
|
- return new ResponseEntity<>(error, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ //return new ResponseEntity<>(error, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ TscApiResultCode errorCode = TscApiResultCode.FAIL_INTERNAL_ERROR;
|
|
|
+ return new ResponseEntity<>(new TscSsipApiResultNodeInfo(errorCode, resultData), HttpStatus.OK);
|
|
|
}
|
|
|
- TscSsipApiResultNodeInfo result = new TscSsipApiResultNodeInfo(TscSsipApiErrorCode.SUCCESS.getCode(), TscSsipApiErrorCode.SUCCESS.getMessage());
|
|
|
- result.setNodes(tscSsipApiService.getNodeInfoList());
|
|
|
- result.setCount(result.getNodes().size());
|
|
|
|
|
|
- // 이력저장
|
|
|
- this.tscSsipApiService.insertInvokeHs(apiInvokeVo, true);
|
|
|
- return new ResponseEntity<>(result, HttpStatus.OK);
|
|
|
- }
|
|
|
+// TscSsipApiResultNodeInfo result = new TscSsipApiResultNodeInfo(TscSsipApiErrorCode.SUCCESS.getCode(), TscSsipApiErrorCode.SUCCESS.getMessage());
|
|
|
+// result.setNodes(tscSsipApiService.getNodeInfoList());
|
|
|
+// result.setCount(result.getNodes().size());
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- @GetMapping(value = {SSIP_API_BROKER_INFO}, produces = {"application/json; charset=utf8"})
|
|
|
- public ResponseEntity<AbstractTscSsipApiResult> getBrokerInfo(@PathVariable("apiToken") String apiToken, HttpServletRequest request) {
|
|
|
+ @PostMapping(value = {SSIP_API_BROKER_INFO}, produces = {"application/json; charset=utf8"})
|
|
|
+ public ResponseEntity<TscSsipApiResultBrokerInfo> getBrokerInfo(@PathVariable("apiToken") String apiToken, HttpServletRequest request) {
|
|
|
|
|
|
String apiId = SSIP_API_BROKER_INFO;
|
|
|
String remoteIP = ApiUtils.getRemoteIP(request);
|
|
@@ -98,34 +105,46 @@ public class TscSsipApiController {
|
|
|
.error(TscSsipApiErrorCode.SUCCESS.getCode())
|
|
|
.build();
|
|
|
|
|
|
+ TscApiResultCode errorCode = null;
|
|
|
try {
|
|
|
- TscSsipApiErrorCode authorizedInfo = this.tscSsipApiService.getAuthorizedInfo(apiId, apiToken, remoteIP);
|
|
|
- if (authorizedInfo != TscSsipApiErrorCode.SUCCESS) {
|
|
|
+ errorCode = this.tscSsipApiService.getTscAuthorizedInfo(apiId, apiToken, remoteIP);
|
|
|
+ if (errorCode != TscApiResultCode.SUCCESS) {
|
|
|
// api token 인증 오류
|
|
|
- log.error("인증오류: [{}] ==> [{}]: [{}].[{}]" + apiId, remoteIP, apiToken, authorizedInfo.getCode(), authorizedInfo.getMessage());
|
|
|
- apiInvokeVo.setError(authorizedInfo.getCode());
|
|
|
+ //log.error("인증오류: [{}] ==> [{}]: [{}].[{}]" + apiId, remoteIP, apiToken, authorizedInfo.getCode(), authorizedInfo.getMessage());
|
|
|
+ log.error("인증오류: [{}] ==> [{}]: [{}].[{}]" + apiId, remoteIP, apiToken, errorCode.getValue(), errorCode.toString());
|
|
|
+ apiInvokeVo.setError(errorCode.getValue());
|
|
|
this.tscSsipApiService.insertInvokeHs(apiInvokeVo, true);
|
|
|
- TscSsipApiResultError error = new TscSsipApiResultError(authorizedInfo.getCode(), authorizedInfo.getMessage());
|
|
|
- return new ResponseEntity<> (error, HttpStatus.UNAUTHORIZED);
|
|
|
+ //TscSsipApiResultError error = new TscSsipApiResultError(authorizedInfo.getCode(), authorizedInfo.getMessage());
|
|
|
+ //return new ResponseEntity<> (error, HttpStatus.UNAUTHORIZED);
|
|
|
+ return new ResponseEntity<>(new TscSsipApiResultBrokerInfo(errorCode, null), HttpStatus.OK);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception e) {
|
|
|
log.error("getBrokerInfo: {}", e.getMessage());
|
|
|
// 데이터베이스 오류
|
|
|
TscSsipApiResultError error = new TscSsipApiResultError(TscSsipApiErrorCode.ERROR_INTERNAL_DATA.getCode(), TscSsipApiErrorCode.ERROR_INTERNAL_DATA.getMessage());
|
|
|
- return new ResponseEntity<>(error, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ apiInvokeVo.setError(TscSsipApiErrorCode.ERROR_INTERNAL_DATA.getCode());
|
|
|
+ this.tscSsipApiService.insertInvokeHs(apiInvokeVo, true);
|
|
|
+ //return new ResponseEntity<>(error, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ errorCode = TscApiResultCode.FAIL_INTERNAL_ERROR;
|
|
|
+ return new ResponseEntity<>(new TscSsipApiResultBrokerInfo(errorCode, null), HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
- BrokerVo brokerVo = null;
|
|
|
try {
|
|
|
- brokerVo = this.tscSsipApiService.getBrokerInfo(apiToken);
|
|
|
+ BrokerVo brokerVo = this.tscSsipApiService.getBrokerInfo(apiToken);
|
|
|
if (brokerVo == null) {
|
|
|
apiInvokeVo.setError(TscSsipApiErrorCode.NOTFOUND_BROKER_INFO.getCode());
|
|
|
log.error("{}", apiInvokeVo.toString());
|
|
|
this.tscSsipApiService.insertInvokeHs(apiInvokeVo, true);
|
|
|
- TscSsipApiResultError error = new TscSsipApiResultError(TscSsipApiErrorCode.NOTFOUND_BROKER_INFO.getCode(), TscSsipApiErrorCode.NOTFOUND_BROKER_INFO.getMessage());
|
|
|
- return new ResponseEntity<> (error, HttpStatus.NON_AUTHORITATIVE_INFORMATION);
|
|
|
+ errorCode = TscApiResultCode.DATA_NOT_FOUND;
|
|
|
+ return new ResponseEntity<>(new TscSsipApiResultBrokerInfo(errorCode, null), HttpStatus.OK);
|
|
|
+// TscSsipApiResultError error = new TscSsipApiResultError(TscSsipApiErrorCode.NOTFOUND_BROKER_INFO.getCode(), TscSsipApiErrorCode.NOTFOUND_BROKER_INFO.getMessage());
|
|
|
+// return new ResponseEntity<> (error, HttpStatus.NON_AUTHORITATIVE_INFORMATION);
|
|
|
}
|
|
|
+ // 이력저장
|
|
|
+ this.tscSsipApiService.insertInvokeHs(apiInvokeVo, true);
|
|
|
+ //return new ResponseEntity<>(result, HttpStatus.OK);
|
|
|
+ return new ResponseEntity<>(new TscSsipApiResultBrokerInfo(errorCode, brokerVo.toDto()), HttpStatus.OK);
|
|
|
}
|
|
|
catch (Exception e) {
|
|
|
log.error("getBrokerInfo: {}", e.getMessage());
|
|
@@ -133,16 +152,15 @@ public class TscSsipApiController {
|
|
|
TscSsipApiResultError error = new TscSsipApiResultError(TscSsipApiErrorCode.ERROR_INTERNAL_DATA.getCode(), TscSsipApiErrorCode.ERROR_INTERNAL_DATA.getMessage());
|
|
|
apiInvokeVo.setError(TscSsipApiErrorCode.ERROR_INTERNAL_DATA.getCode());
|
|
|
this.tscSsipApiService.insertInvokeHs(apiInvokeVo, true);
|
|
|
- return new ResponseEntity<>(error, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ //return new ResponseEntity<>(error, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ errorCode = TscApiResultCode.FAIL_INTERNAL_ERROR;
|
|
|
+ return new ResponseEntity<>(new TscSsipApiResultBrokerInfo(errorCode, null), HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
- TscSsipApiResultBrokerInfo result = new TscSsipApiResultBrokerInfo(TscSsipApiErrorCode.SUCCESS.getCode(), TscSsipApiErrorCode.SUCCESS.getMessage());
|
|
|
- result.setBrokerInfo(brokerVo);
|
|
|
- result.setCount(1);
|
|
|
+// TscSsipApiResultBrokerInfo result = new TscSsipApiResultBrokerInfo(TscSsipApiErrorCode.SUCCESS.getCode(), TscSsipApiErrorCode.SUCCESS.getMessage());
|
|
|
+// result.setBrokerInfo(brokerVo);
|
|
|
+// result.setCount(1);
|
|
|
|
|
|
- // 이력저장
|
|
|
- this.tscSsipApiService.insertInvokeHs(apiInvokeVo, true);
|
|
|
- return new ResponseEntity<>(result, HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = {SSIP_API_UUID})
|