자동 생성된 API Spec 목록 및 개수 추가

This commit is contained in:
Rinjae
2026-01-17 23:15:21 +09:00
parent cb551d6888
commit 88710dd4b4
4 changed files with 61 additions and 8 deletions
@@ -156,6 +156,12 @@ public class ClientController extends OnlBaseAnnotationController {
response.put("invalidApis", result.getInvalidApis());
}
// 자동 생성된 API Spec 목록 포함
if (result.getCreatedApiSpecs() != null && !result.getCreatedApiSpecs().isEmpty()) {
response.put("createdApiSpecs", result.getCreatedApiSpecs());
response.put("createdApiSpecCount", result.getCreatedApiSpecCount());
}
return ResponseEntity.ok(response);
} catch (Exception e) {
// 에러 처리
@@ -1,5 +1,7 @@
package com.eactive.eai.rms.onl.manage.authserver.client;
import com.eactive.apim.portal.apispec.entity.ApiSpecInfo;
import com.eactive.apim.portal.apispec.service.ApiSpecInfoService;
import com.eactive.apim.portal.app.entity.Credential;
import com.eactive.apim.portal.portalorg.entity.PortalOrg;
import com.eactive.eai.data.entity.onl.message.EAIMessageEntity;
@@ -43,6 +45,7 @@ public class ClientManService extends OnlBaseService {
private CredentialManService credentialManService;
private CredentialService credentialService;
private EAIMessageService eaiMessageService;
private ApiSpecInfoService apiSpecInfoService;
@Autowired
public ClientManService(ClientEntityService clientEntityService,
@@ -51,7 +54,8 @@ public class ClientManService extends OnlBaseService {
PortalOrgUIMapper portalOrgUIMapper,
CredentialManService credentialManService,
CredentialService credentialService,
EAIMessageService eaiMessageService) {
EAIMessageService eaiMessageService,
ApiSpecInfoService apiSpecInfoService) {
this.clientEntityService = clientEntityService;
this.clientUIMapper = clientUIMapper;
this.portalOrgService = portalOrgService;
@@ -59,6 +63,7 @@ public class ClientManService extends OnlBaseService {
this.credentialManService = credentialManService;
this.credentialService = credentialService;
this.eaiMessageService = eaiMessageService;
this.apiSpecInfoService = apiSpecInfoService;
}
@@ -168,10 +173,29 @@ public class ClientManService extends OnlBaseService {
DataSourceType monitoringType = DataSourceTypeManager.getDataSourceType("MONITORING");
DataSourceContextHolder.setDataSourceType(monitoringType);
// 5. 기존 Credential 확인
// 5. PTL_API_SPEC_INFO에 없는 API 자동 생성
List<String> createdApiSpecs = new ArrayList<>();
if (clientEntity.getApiList() != null && !clientEntity.getApiList().isEmpty()) {
for (EAIMessageEntity apiEntity : clientEntity.getApiList()) {
String apiId = apiEntity.getEaisvcname();
if (!apiSpecInfoService.findById(apiId).isPresent()) {
// PTL_API_SPEC_INFO에 없으면 자동 생성
ApiSpecInfo newApiSpec = new ApiSpecInfo();
newApiSpec.setApiId(apiId);
newApiSpec.setApiName(StringUtils.isNotBlank(apiEntity.getEaisvcdesc())
? apiEntity.getEaisvcdesc() : apiId);
newApiSpec.setApiSimpleDescription(apiEntity.getEaisvcdesc());
newApiSpec.setDisplayYn("Y"); // 기본값: 공개
apiSpecInfoService.create(newApiSpec);
createdApiSpecs.add(apiId);
}
}
}
// 6. 기존 Credential 확인
Credential existingCredential = credentialService.findByClientidAndOrgid(clientId, orgId);
// 6. 데이터 변환 (ClientEntity → CredentialUI)
// 7. 데이터 변환 (ClientEntity → CredentialUI)
CredentialUI credentialUI = convertToCredentialUI(clientEntity);
SyncResult.SyncAction action;
@@ -188,7 +212,7 @@ public class ClientManService extends OnlBaseService {
credentialUI.setServer(existing.getServer());
}
// 7. 포탈 스키마에 업데이트
// 8. 포탈 스키마에 업데이트
credentialManService.update(credentialUI);
action = SyncResult.SyncAction.UPDATED;
} else {
@@ -197,7 +221,7 @@ public class ClientManService extends OnlBaseService {
credentialUI.setAppDescription("APIGW에서 반영된 인증정보");
}
// 7. 포탈 스키마에 신규 생성
// 8. 포탈 스키마에 신규 생성
credentialManService.insert(credentialUI);
action = SyncResult.SyncAction.INSERTED;
}
@@ -210,6 +234,8 @@ public class ClientManService extends OnlBaseService {
.targetApiCount(requestedApiIds.size())
.syncedApis(requestedApiIds)
.syncedApiCount(requestedApiIds.size())
.createdApiSpecs(createdApiSpecs)
.createdApiSpecCount(createdApiSpecs.size())
.build();
} catch (Exception e) {
@@ -56,6 +56,16 @@ public class SyncResult {
*/
private List<String> invalidApis;
/**
* 자동 생성된 API Spec 목록 (PTL_API_SPEC_INFO에 없어서 새로 생성된 API)
*/
private List<String> createdApiSpecs;
/**
* 자동 생성된 API Spec 개수
*/
private int createdApiSpecCount;
/**
* 반영 액션 타입
*/