인터페이스관리 - 배포 버튼(uploadfull) 추가
eapim-admin CI / build (push) Has been cancelled

This commit is contained in:
eastargh
2026-08-14 18:04:19 +09:00
parent 3bb0325bf7
commit 0149da372e
3 changed files with 226 additions and 1 deletions
@@ -0,0 +1,140 @@
<%@ page language="java" contentType="text/html; charset=utf-8" %>
<%@ page import="java.io.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="/jsp/common/include/localemessage.jsp" %>
<%
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Expires", "0");
%>
<html>
<head>
<title>인터페이스 배포</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<jsp:include page="/jsp/common/include/css.jsp"/>
<jsp:include page="/jsp/common/include/script.jsp"/>
<script language="javascript">
var url = '<c:url value="/onl/transaction/apim/apiInterfaceMan.json"/>';
var url_loader = '<c:url value="/loader.do"/>';
function loadList() {
$.ajax({
type: "POST",
url: url,
dataType: "json",
data: {cmd: 'LIST_DEPLOY_FILES'},
success: function (json) {
console.log('list', json)
if (json) {
$('#grid').jqGrid('clearGridData').jqGrid('setGridParam', {data: json.rows || []}).trigger('reloadGrid');
}
},
error: function (e) {
alert(e.responseText);
}
});
}
function callDeploy(filePath) {
var postData = [];
postData.push({name: "cmd", value: "interface"});
postData.push({name: "control", value: "uploadfull"});
postData.push({name: "filePath", value: filePath});
return new Promise(function (resolve, reject) {
$.ajax({
type: "POST",
url: url_loader,
data: postData,
success: function (response) {
resolve(response);
},
error: function (error) {
reject(error);
}
});
});
}
$(document).ready(function () {
$("#btn_close").click(function () {
window.close();
});
$('#grid').jqGrid({
datatype: "local",
colNames: ['업무그룹', '인터페이스', '생성일시', 'filePath'],
colModel: [
{name: 'bizCode', align: 'center', width: '80', sortable: true},
{name: 'interfaceId', align: 'left', sortable: true},
{name: 'createdDate', align: 'center', width: '130', sortable: true},
{name: 'filePath', hidden: true}
],
pager: $('#pager'),
rowNum: 20,
rowList: [10, 20, 50, 100],
autoheight: false,
height: 460,
width: 650,
autowidth: false,
viewrecords: true,
shrinkToFit: true,
multiselect: true,
multiboxonly: false
});
loadList();
$("#btn_deploy").click(async function () {
var rowIds = $('#grid').jqGrid('getGridParam', 'selarrrow');
if (rowIds.length === 0) {
alert('배포할 인터페이스를 선택하세요.');
return;
}
if (!confirm(rowIds.length + '건을 배포 하시겠습니까?')) {
return;
}
$("#btn_deploy").prop("disabled", true);
var successCount = 0;
var failedList = [];
for (var i = 0; i < rowIds.length; i++) {
var rowData = $("#grid").getRowData(rowIds[i]);
var target = rowData['bizCode'] + '/' + rowData['interfaceId'];
try {
var response = await callDeploy(rowData['filePath']);
if (response != null && response.includes('status=success')) {
successCount++;
} else {
failedList.push(target);
}
} catch (error) {
failedList.push(target);
}
}
$("#btn_deploy").prop("disabled", false);
var msg = '배포 완료 - 성공[' + successCount + ']건, 실패[' + failedList.length + ']건';
if (failedList.length > 0) {
msg += '\n실패목록 : ' + failedList.join(', ');
}
alert(msg);
});
});
</script>
</head>
<body>
<div class="popup_box">
<div class="search_wrap">
<button type="button" class="cssbtn" id="btn_deploy" level="W"><i class="material-icons">cloud_upload</i> 배포
</button>
<button type="button" class="cssbtn" id="btn_close" level="R"><i class="material-icons">cancel</i> <%= localeMessage.getString("button.close") %>
</button>
</div>
<div class="title">배포 대상 인터페이스 목록</div>
<table id="grid"></table>
<div id="pager"></div>
</div>
</body>
</html>
@@ -1,5 +1,6 @@
<%@ page language="java" contentType="text/html; charset=utf-8" %> <%@ page language="java" contentType="text/html; charset=utf-8" %>
<%@ page import="java.io.*" %> <%@ page import="java.io.*" %>
<%@ page import="com.eactive.eai.common.util.SystemUtil" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="/jsp/common/include/localemessage.jsp" %> <%@ include file="/jsp/common/include/localemessage.jsp" %>
<% <%
@@ -246,6 +247,11 @@
window.alert('이관 대상 API 성공['+successCount+']건, 실패['+failedCount+']건 서버에 다운로드 완료'); window.alert('이관 대상 API 성공['+successCount+']건, 실패['+failedCount+']건 서버에 다운로드 완료');
}); });
$("#btn_deploy").click(function(){
var url2 = '<c:url value="/onl/transaction/apim/apiInterfaceMan.view"/>?cmd=DEPLOY_POPUP';
showModal2(url2, {}, 663, 600);
});
buttonControl(); buttonControl();
// 25.11.25 파일 가져오기 할 때 중복 검사 기능추가. // 25.11.25 파일 가져오기 할 때 중복 검사 기능추가.
@@ -381,6 +387,9 @@
<div class="content_middle" id="content_middle"> <div class="content_middle" id="content_middle">
<div class="search_wrap"> <div class="search_wrap">
<button type="button" class="cssbtn" id="btn_download" level="W" status="DETAIL"><i class="material-icons">cloud_download</i> 이관</button> <button type="button" class="cssbtn" id="btn_download" level="W" status="DETAIL"><i class="material-icons">cloud_download</i> 이관</button>
<% if (SystemUtil.isProdServer()) { %>
<button type="button" class="cssbtn" id="btn_deploy" level="W" status="DETAIL"><i class="material-icons">cloud_upload</i> 배포</button>
<% } %>
<button type="button" class="cssbtn" id="btn_import" level="R" data-bs-toggle="modal" <button type="button" class="cssbtn" id="btn_import" level="R" data-bs-toggle="modal"
data-bs-target="#uploadModal"><i data-bs-target="#uploadModal"><i
class="material-icons">upload</i> <%=localeMessage.getString("button.import")%> class="material-icons">upload</i> <%=localeMessage.getString("button.import")%>
@@ -4,6 +4,7 @@ import com.eactive.apim.portal.portalproperty.service.PortalPropertyService;
import com.eactive.eai.agent.command.Command; import com.eactive.eai.agent.command.Command;
import com.eactive.eai.agent.command.CommonCommand; import com.eactive.eai.agent.command.CommonCommand;
import com.eactive.eai.rms.common.base.OnlBaseAnnotationController; import com.eactive.eai.rms.common.base.OnlBaseAnnotationController;
import com.eactive.eai.rms.common.context.MonitoringContext;
import com.eactive.eai.rms.common.login.SessionManager; import com.eactive.eai.rms.common.login.SessionManager;
import com.eactive.eai.rms.common.vo.GridResponse; import com.eactive.eai.rms.common.vo.GridResponse;
import com.eactive.eai.rms.data.entity.onl.authserver.ClientEntityService; import com.eactive.eai.rms.data.entity.onl.authserver.ClientEntityService;
@@ -32,7 +33,15 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.file.Files;
import java.nio.file.attribute.BasicFileAttributes;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -49,19 +58,26 @@ public class ApiInterfaceController extends OnlBaseAnnotationController {
private final ApiInterfaceService service; private final ApiInterfaceService service;
private final ClientEntityService clientEntityService; private final ClientEntityService clientEntityService;
private final PortalPropertyService portalPropertyService; private final PortalPropertyService portalPropertyService;
private final MonitoringContext monitoringContext;
@Autowired @Autowired
public ApiInterfaceController(ApiInterfaceService service, ClientEntityService clientEntityService, public ApiInterfaceController(ApiInterfaceService service, ClientEntityService clientEntityService,
PortalPropertyService portalPropertyService) { PortalPropertyService portalPropertyService, MonitoringContext monitoringContext) {
this.service = service; this.service = service;
this.clientEntityService = clientEntityService; this.clientEntityService = clientEntityService;
this.portalPropertyService = portalPropertyService; this.portalPropertyService = portalPropertyService;
this.monitoringContext = monitoringContext;
} }
@GetMapping(value = "/onl/transaction/apim/apiInterfaceMan.view") @GetMapping(value = "/onl/transaction/apim/apiInterfaceMan.view")
public void view() { public void view() {
} }
@GetMapping(value = "/onl/transaction/apim/apiInterfaceMan.view", params = "cmd=DEPLOY_POPUP")
public String deployPopupView() {
return "/onl/transaction/apim/apiInterfaceDeployPopup";
}
@GetMapping(value = "/onl/transaction/apim/apiInterfaceMan.view", params = "cmd=DETAIL") @GetMapping(value = "/onl/transaction/apim/apiInterfaceMan.view", params = "cmd=DETAIL")
public String viewDetail(Model model) { public String viewDetail(Model model) {
model.addAttribute("apiSpecV1Enabled", resolveApiSpecV1Enabled()); model.addAttribute("apiSpecV1Enabled", resolveApiSpecV1Enabled());
@@ -312,4 +328,64 @@ public class ApiInterfaceController extends OnlBaseAnnotationController {
throw new BizException("오류가 발생했습니다. 확인바랍니다. 오류메시지: "+e.getMessage()); throw new BizException("오류가 발생했습니다. 확인바랍니다. 오류메시지: "+e.getMessage());
} }
} }
/**
* 모니터링 프로퍼티 iomap.upload.path 경로 하위의 {업무그룹}/{인터페이스명}.json 파일 목록을 조회한다.
*/
@PostMapping(value = "/onl/transaction/apim/apiInterfaceMan.json", params = "cmd=LIST_DEPLOY_FILES")
public ResponseEntity<Map<String, Object>> listDeployFiles() {
List<Map<String, String>> rows = new ArrayList<>();
String uploadPath = monitoringContext.getStringProperty(MonitoringContext.IOMAP_UPLOAD_PATH);
if (StringUtils.isNotBlank(uploadPath)) {
File uploadDir = new File(uploadPath);
// 업무그룹 없이 iomap.upload.path 바로 하위에 있는 {인터페이스}.json
File[] rootJsonFiles = uploadDir.listFiles((dir, name) -> name.toLowerCase().endsWith(".json"));
if (rootJsonFiles != null) {
Arrays.sort(rootJsonFiles, Comparator.comparing(File::getName));
for (File jsonFile : rootJsonFiles) {
Map<String, String> row = new HashMap<>();
row.put("bizCode", "");
row.put("interfaceId", FilenameUtils.getBaseName(jsonFile.getName()));
row.put("filePath", jsonFile.getName());
row.put("createdDate", getFileCreatedDate(jsonFile));
rows.add(row);
}
}
File[] bizDirs = uploadDir.listFiles(File::isDirectory);
if (bizDirs != null) {
Arrays.sort(bizDirs, Comparator.comparing(File::getName));
for (File bizDir : bizDirs) {
File[] jsonFiles = bizDir.listFiles((dir, name) -> name.toLowerCase().endsWith(".json"));
if (jsonFiles == null) {
continue;
}
Arrays.sort(jsonFiles, Comparator.comparing(File::getName));
for (File jsonFile : jsonFiles) {
Map<String, String> row = new HashMap<>();
row.put("bizCode", bizDir.getName());
row.put("interfaceId", FilenameUtils.getBaseName(jsonFile.getName()));
row.put("filePath", bizDir.getName() + File.separator + jsonFile.getName());
row.put("createdDate", getFileCreatedDate(jsonFile));
rows.add(row);
}
}
}
}
Map<String, Object> result = new HashMap<>();
result.put("rows", rows);
return ResponseEntity.ok(result);
}
private String getFileCreatedDate(File file) {
try {
BasicFileAttributes attrs = Files.readAttributes(file.toPath(), BasicFileAttributes.class);
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(attrs.creationTime().toMillis()));
} catch (Exception e) {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(file.lastModified()));
}
}
} }