자동 생성된 API Spec 목록 및 개수 추가
This commit is contained in:
@@ -713,6 +713,10 @@
|
|||||||
color: #dc3545;
|
color: #dc3545;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
.api-created {
|
||||||
|
color: #007bff;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -732,12 +736,15 @@ function showSyncResultModal(response) {
|
|||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
statusClass = "status-success";
|
statusClass = "status-success";
|
||||||
|
var createdCount = response.createdApiSpecCount || 0;
|
||||||
|
var createdMsg = createdCount > 0 ? "<br/><span style='color:#007bff;'>* " + createdCount + "개의 API Spec이 자동 생성되었습니다.</span>" : "";
|
||||||
|
|
||||||
if (response.action === 'INSERTED') {
|
if (response.action === 'INSERTED') {
|
||||||
statusMsg = "<strong>반영 완료</strong> - 포탈에 새로운 인증정보가 생성되었습니다.";
|
statusMsg = "<strong>반영 완료</strong> - 포탈에 새로운 인증정보가 생성되었습니다." + createdMsg;
|
||||||
} else if (response.action === 'UPDATED') {
|
} else if (response.action === 'UPDATED') {
|
||||||
statusMsg = "<strong>반영 완료</strong> - 기존 포탈 인증정보가 업데이트되었습니다.";
|
statusMsg = "<strong>반영 완료</strong> - 기존 포탈 인증정보가 업데이트되었습니다." + createdMsg;
|
||||||
} else {
|
} else {
|
||||||
statusMsg = "<strong>반영 완료</strong> - " + response.message;
|
statusMsg = "<strong>반영 완료</strong> - " + response.message + createdMsg;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (response.action === 'SKIPPED_NO_ORG') {
|
if (response.action === 'SKIPPED_NO_ORG') {
|
||||||
@@ -759,6 +766,7 @@ function showSyncResultModal(response) {
|
|||||||
var targetApis = response.targetApis || [];
|
var targetApis = response.targetApis || [];
|
||||||
var syncedApis = response.syncedApis || [];
|
var syncedApis = response.syncedApis || [];
|
||||||
var invalidApis = response.invalidApis || [];
|
var invalidApis = response.invalidApis || [];
|
||||||
|
var createdApiSpecs = response.createdApiSpecs || [];
|
||||||
|
|
||||||
$targetCount.text(targetApis.length);
|
$targetCount.text(targetApis.length);
|
||||||
|
|
||||||
@@ -772,6 +780,9 @@ function showSyncResultModal(response) {
|
|||||||
if (invalidApis.includes(apiId)) {
|
if (invalidApis.includes(apiId)) {
|
||||||
status = "미존재 (APIGW에 없음)";
|
status = "미존재 (APIGW에 없음)";
|
||||||
statusClass = "api-invalid";
|
statusClass = "api-invalid";
|
||||||
|
} else if (createdApiSpecs.includes(apiId)) {
|
||||||
|
status = "반영됨 (Spec 신규생성)";
|
||||||
|
statusClass = "api-created";
|
||||||
} else if (syncedApis.includes(apiId)) {
|
} else if (syncedApis.includes(apiId)) {
|
||||||
status = "반영됨";
|
status = "반영됨";
|
||||||
statusClass = "api-synced";
|
statusClass = "api-synced";
|
||||||
|
|||||||
@@ -156,6 +156,12 @@ public class ClientController extends OnlBaseAnnotationController {
|
|||||||
response.put("invalidApis", result.getInvalidApis());
|
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);
|
return ResponseEntity.ok(response);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// 에러 처리
|
// 에러 처리
|
||||||
|
|||||||
+31
-5
@@ -1,5 +1,7 @@
|
|||||||
package com.eactive.eai.rms.onl.manage.authserver.client;
|
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.app.entity.Credential;
|
||||||
import com.eactive.apim.portal.portalorg.entity.PortalOrg;
|
import com.eactive.apim.portal.portalorg.entity.PortalOrg;
|
||||||
import com.eactive.eai.data.entity.onl.message.EAIMessageEntity;
|
import com.eactive.eai.data.entity.onl.message.EAIMessageEntity;
|
||||||
@@ -43,6 +45,7 @@ public class ClientManService extends OnlBaseService {
|
|||||||
private CredentialManService credentialManService;
|
private CredentialManService credentialManService;
|
||||||
private CredentialService credentialService;
|
private CredentialService credentialService;
|
||||||
private EAIMessageService eaiMessageService;
|
private EAIMessageService eaiMessageService;
|
||||||
|
private ApiSpecInfoService apiSpecInfoService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public ClientManService(ClientEntityService clientEntityService,
|
public ClientManService(ClientEntityService clientEntityService,
|
||||||
@@ -51,7 +54,8 @@ public class ClientManService extends OnlBaseService {
|
|||||||
PortalOrgUIMapper portalOrgUIMapper,
|
PortalOrgUIMapper portalOrgUIMapper,
|
||||||
CredentialManService credentialManService,
|
CredentialManService credentialManService,
|
||||||
CredentialService credentialService,
|
CredentialService credentialService,
|
||||||
EAIMessageService eaiMessageService) {
|
EAIMessageService eaiMessageService,
|
||||||
|
ApiSpecInfoService apiSpecInfoService) {
|
||||||
this.clientEntityService = clientEntityService;
|
this.clientEntityService = clientEntityService;
|
||||||
this.clientUIMapper = clientUIMapper;
|
this.clientUIMapper = clientUIMapper;
|
||||||
this.portalOrgService = portalOrgService;
|
this.portalOrgService = portalOrgService;
|
||||||
@@ -59,6 +63,7 @@ public class ClientManService extends OnlBaseService {
|
|||||||
this.credentialManService = credentialManService;
|
this.credentialManService = credentialManService;
|
||||||
this.credentialService = credentialService;
|
this.credentialService = credentialService;
|
||||||
this.eaiMessageService = eaiMessageService;
|
this.eaiMessageService = eaiMessageService;
|
||||||
|
this.apiSpecInfoService = apiSpecInfoService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -168,10 +173,29 @@ public class ClientManService extends OnlBaseService {
|
|||||||
DataSourceType monitoringType = DataSourceTypeManager.getDataSourceType("MONITORING");
|
DataSourceType monitoringType = DataSourceTypeManager.getDataSourceType("MONITORING");
|
||||||
DataSourceContextHolder.setDataSourceType(monitoringType);
|
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);
|
Credential existingCredential = credentialService.findByClientidAndOrgid(clientId, orgId);
|
||||||
|
|
||||||
// 6. 데이터 변환 (ClientEntity → CredentialUI)
|
// 7. 데이터 변환 (ClientEntity → CredentialUI)
|
||||||
CredentialUI credentialUI = convertToCredentialUI(clientEntity);
|
CredentialUI credentialUI = convertToCredentialUI(clientEntity);
|
||||||
|
|
||||||
SyncResult.SyncAction action;
|
SyncResult.SyncAction action;
|
||||||
@@ -188,7 +212,7 @@ public class ClientManService extends OnlBaseService {
|
|||||||
credentialUI.setServer(existing.getServer());
|
credentialUI.setServer(existing.getServer());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7. 포탈 스키마에 업데이트
|
// 8. 포탈 스키마에 업데이트
|
||||||
credentialManService.update(credentialUI);
|
credentialManService.update(credentialUI);
|
||||||
action = SyncResult.SyncAction.UPDATED;
|
action = SyncResult.SyncAction.UPDATED;
|
||||||
} else {
|
} else {
|
||||||
@@ -197,7 +221,7 @@ public class ClientManService extends OnlBaseService {
|
|||||||
credentialUI.setAppDescription("APIGW에서 반영된 인증정보");
|
credentialUI.setAppDescription("APIGW에서 반영된 인증정보");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7. 포탈 스키마에 신규 생성
|
// 8. 포탈 스키마에 신규 생성
|
||||||
credentialManService.insert(credentialUI);
|
credentialManService.insert(credentialUI);
|
||||||
action = SyncResult.SyncAction.INSERTED;
|
action = SyncResult.SyncAction.INSERTED;
|
||||||
}
|
}
|
||||||
@@ -210,6 +234,8 @@ public class ClientManService extends OnlBaseService {
|
|||||||
.targetApiCount(requestedApiIds.size())
|
.targetApiCount(requestedApiIds.size())
|
||||||
.syncedApis(requestedApiIds)
|
.syncedApis(requestedApiIds)
|
||||||
.syncedApiCount(requestedApiIds.size())
|
.syncedApiCount(requestedApiIds.size())
|
||||||
|
.createdApiSpecs(createdApiSpecs)
|
||||||
|
.createdApiSpecCount(createdApiSpecs.size())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -56,6 +56,16 @@ public class SyncResult {
|
|||||||
*/
|
*/
|
||||||
private List<String> invalidApis;
|
private List<String> invalidApis;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 자동 생성된 API Spec 목록 (PTL_API_SPEC_INFO에 없어서 새로 생성된 API)
|
||||||
|
*/
|
||||||
|
private List<String> createdApiSpecs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 자동 생성된 API Spec 개수
|
||||||
|
*/
|
||||||
|
private int createdApiSpecCount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 반영 액션 타입
|
* 반영 액션 타입
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user