API 관리 > API 신청 관리 - API 신청 목록 표시, 승인 처리
parent
55ebfd4645
commit
23c95c2380
|
|
@ -100,4 +100,78 @@ public class ApiManagementController {
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* API 관리 > API 신청 관리 화면
|
||||
* @param params
|
||||
* @param model
|
||||
* @param response
|
||||
* @param request
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "admins/mgmtApi/mgmt-api-key.do")
|
||||
public String goMgmtApiKey(@RequestParam HashMap<String, Object> params, ModelMap model, HttpServletResponse response, HttpServletRequest request) throws Exception {
|
||||
|
||||
if (!UserInfo.isValidSession(request, response, "admin")) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
model.addAttribute("params", params);
|
||||
return "admins/mgmtApi/mgmt-api-key";
|
||||
}
|
||||
|
||||
/**
|
||||
* API 관리 > 관리 API 신청 목록
|
||||
* @param params
|
||||
* @param model
|
||||
* @param response
|
||||
* @param request
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/admins/mgmtApiKey/list.do", method = RequestMethod.POST)
|
||||
public HashMap<String, Object> getMgmtApiKeyList(@RequestParam HashMap<String, Object> params, ModelMap model, HttpServletResponse response, HttpServletRequest request) throws Exception {
|
||||
HashMap<String, Object> result = new HashMap<String, Object>();
|
||||
|
||||
List<?> listData = apiManagementService.selectWebApiKeyList(params);
|
||||
|
||||
result.put("code", "SUCCESS");
|
||||
result.put("msg", "API 신청 목록 조회를 성공했습니다.");
|
||||
result.put("data", listData);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* API 관리 > API 호출 활성상태 변경
|
||||
* @param params
|
||||
* @param model
|
||||
* @param response
|
||||
* @param request
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/admins/mgmtApiKey/approve.do", method = RequestMethod.POST)
|
||||
public HashMap<String, Object> modMgmtApiKeyApprove(@RequestParam(value="apiSeq") int apiSeq, ModelMap model, HttpServletResponse response, HttpServletRequest request) throws Exception {
|
||||
HashMap<String, Object> result = new HashMap<String, Object>();
|
||||
|
||||
HashMap<String,Object> params = new HashMap<>();
|
||||
params.put("apiSeq", apiSeq);
|
||||
params.put("approveYn", "Y");
|
||||
|
||||
apiManagementService.updateWebApiKeyApprove(params);
|
||||
|
||||
List<?> listData = apiManagementService.selectWebApiKeyList(params);
|
||||
|
||||
result.put("code", "SUCCESS");
|
||||
result.put("msg", " API 신청 목록 조회를 성공했습니다.");
|
||||
result.put("data", listData);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,4 +21,7 @@ public interface ApiManagementMapper {
|
|||
|
||||
public void updateInfoStatus(HashMap<String, Object> params) throws Exception;
|
||||
|
||||
public List<?> selectWebApiKeyList(HashMap<String, Object> params) throws Exception;
|
||||
|
||||
public void updateWebApiKeyApprove(HashMap<String, Object> params) throws Exception;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,4 +21,7 @@ public interface ApiManagementService {
|
|||
|
||||
public void updateInfoStatus(HashMap<String, Object> params) throws Exception;
|
||||
|
||||
public List<?> selectWebApiKeyList(HashMap<String, Object> params) throws Exception;
|
||||
|
||||
public void updateWebApiKeyApprove(HashMap<String, Object> params) throws Exception;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,4 +46,14 @@ public class ApiManagementServiceImpl implements ApiManagementService {
|
|||
masterMapper.updateInfoStatus(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> selectWebApiKeyList(HashMap<String, Object> params) throws Exception {
|
||||
return masterMapper.selectWebApiKeyList(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWebApiKeyApprove(HashMap<String, Object> params) throws Exception {
|
||||
masterMapper.updateWebApiKeyApprove(params);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,4 +63,38 @@
|
|||
)
|
||||
</update>
|
||||
|
||||
|
||||
<!-- API 신청 관리 목록 조회 -->
|
||||
<select id="selectWebApiKeyList" parameterType="map" resultType="egovMap">
|
||||
SELECT TB.RN
|
||||
,TB.API_SEQ
|
||||
,TB.USERID
|
||||
,TB.USER_TYPE
|
||||
,TB.API_KEY
|
||||
,TO_CHAR(TB.START_DT, 'YYYY-MM-DD HH24:MI') AS START_DT
|
||||
,TO_CHAR(TB.END_DT, 'YYYY-MM-DD HH24:MI') AS END_DT
|
||||
,TB.APPROVE_YN
|
||||
FROM (SELECT API_SEQ
|
||||
,USERID
|
||||
,USER_TYPE
|
||||
,API_KEY
|
||||
,START_DT
|
||||
,END_DT
|
||||
,APPROVE_YN
|
||||
,ROW_NUMBER() OVER(ORDER BY API_SEQ ASC) RN
|
||||
,TO_CHAR(LAST_VALUE(ROWNUM) OVER (ORDER BY ROWNUM ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)) AS TOTALROWS
|
||||
FROM WEB_API_KEY
|
||||
WHERE 1=1) TB
|
||||
<!-- WHERE RN BETWEEN #{firstIndex} + 1 AND #{firstIndex} + #{recordCountPerPage} -->
|
||||
</select>
|
||||
|
||||
<!-- API 신청 승인상태 변경 -->
|
||||
<update id="updateWebApiKeyApprove" parameterType="map">
|
||||
UPDATE WEB_API_KEY
|
||||
SET
|
||||
<if test="approveYn != null and approveYn !=''">
|
||||
APPROVE_YN = #{approveYn}
|
||||
</if>
|
||||
WHERE API_SEQ IN (#{apiSeq})
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
@ -75,7 +75,14 @@ img { border:0; }
|
|||
<tr>
|
||||
<td>
|
||||
<div class="menu-item active">
|
||||
<span style="cursor:hand" onClick="javascript:goUrl('api-request-statistics-index', '${menuId}')"><img src="${pageContext.request.contextPath}/images/renew/arrow-right.png" /> API 통계</span>
|
||||
<span style="cursor:hand" onClick="javascript:goUrl('mgmt-api-index', '${menuId}')"><img src="${pageContext.request.contextPath}/images/renew/arrow-right.png" /> API 통계</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="menu-item active">
|
||||
<span style="cursor:hand" onClick="javascript:goUrl('mgmt-api-key', '${menuId}')"><img src="${pageContext.request.contextPath}/images/renew/arrow-right.png" /> API 신청 관리</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,174 @@
|
|||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<!-- MUI + Chart.js + jQuery -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/@mui/material@5.15.14/dist/material.min.css" rel="stylesheet">
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
|
||||
|
||||
<style>
|
||||
body { font-family: 'Pretendard', 'Roboto', sans-serif; background-color: #f5f6fa; margin: 0; padding: 20px; }
|
||||
|
||||
/* 로그 테이블 */
|
||||
.table-container {
|
||||
margin-top: 25px; background: #fff; border-radius: 12px; padding: 20px;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
|
||||
}
|
||||
table { width: 100%; border-collapse: collapse; }
|
||||
thead { background: #f0f3f8; }
|
||||
th, td { padding: 10px; border-bottom: 1px solid #eee; text-align: left; }
|
||||
th { color: #555; font-weight: 600; }
|
||||
|
||||
.pagination {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-top: 15px;
|
||||
}
|
||||
.pagination button {
|
||||
border: none;
|
||||
background-color: #e2e8f0;
|
||||
color: #334155;
|
||||
padding: 6px 12px;
|
||||
border-radius: 8px;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
.pagination button.active {
|
||||
background-color: #3b82f6;
|
||||
color: white;
|
||||
}
|
||||
.pagination button:hover:not(.active) {
|
||||
background-color: #cbd5e1;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!-- API 신청 테이블 -->
|
||||
<div class="table-container home-trainning">
|
||||
<h3>API 신청 내역</h3>
|
||||
<table class="Table_Main course-list-table">
|
||||
<colgroup>
|
||||
<col style="width: 3%">
|
||||
<col style="width: 10%">
|
||||
<col style="width: 10%">
|
||||
<col style="width: auto">
|
||||
<col style="width: 15%">
|
||||
<col style="width: 15%">
|
||||
<col style="width: 8%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>No.</th>
|
||||
<th>사용자 ID</th>
|
||||
<th>사용자 구분</th>
|
||||
<th>API KEY</th>
|
||||
<th>신청일</th>
|
||||
<th>만료일</th>
|
||||
<th>승인상태</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="apiKeyBody">
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- 페이징 영역 -->
|
||||
<div id="pagination" class="pagination"></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function(){
|
||||
// API 호출 통제 목록 조회
|
||||
getMgmtApiKeyList();
|
||||
});
|
||||
|
||||
// API 호출 통제 목록 조회
|
||||
function getMgmtApiKeyList(){
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url : "/admins/mgmtApiKey/list.do" ,
|
||||
data : {},
|
||||
dataType :"json",
|
||||
success : function(res){ // res.code, res.msg, res.data
|
||||
if (res.code == "SUCCESS") {
|
||||
let procList = res.data; //Array List
|
||||
const $listContainer = $("#apiKeyBody");
|
||||
$listContainer.empty(); // 기존 내용 제거
|
||||
// 데이터 반복
|
||||
$.each(res.data, function(i, item) {
|
||||
// DOM에 추가
|
||||
$listContainer.append(drawApiKeyList(item));
|
||||
});
|
||||
} else {
|
||||
alert("관리 API 목록 조회중 오류가 발생하였습니다. 다시 시도해주세요.");
|
||||
}
|
||||
},
|
||||
error : function(response){
|
||||
alert("관리 API 목록 조회중 내부 오류가 발생하였습니다. 다시 시도해주세요.");
|
||||
}
|
||||
});
|
||||
}
|
||||
function drawApiKeyList(item) {
|
||||
// 승인 상태에 따른 표시
|
||||
let approveHtml = "";
|
||||
if (item.approveYn == "Y") {
|
||||
approveHtml = "승인";
|
||||
} else {
|
||||
approveHtml = `<button class="approve-btn" data-id="\${item.apiSeq}" onclick="approveKey(this);">승인</button>`;
|
||||
}
|
||||
// HTML 문자열 생성
|
||||
const html = `
|
||||
<tr data-idx="\${item.apiSeq}">
|
||||
<td>\${item.rn}</td>
|
||||
<td>\${item.userid}</td>
|
||||
<td>\${item.userType}</td>
|
||||
<td>\${item.apiKey}</td>
|
||||
<td>\${item.startDt}</td>
|
||||
<td>\${item.endDt}</td>
|
||||
<td>\${approveHtml}</td>
|
||||
</tr>
|
||||
`;
|
||||
return html;
|
||||
}
|
||||
|
||||
// 승인처리하기
|
||||
function approveKey(e) {
|
||||
let apiSeq = $(e).data("id")
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url : "/admins/mgmtApiKey/approve.do" ,
|
||||
data : {apiSeq:apiSeq},
|
||||
traditional: true,
|
||||
dataType :"json",
|
||||
success : function(res){ // res.code, res.msg, res.data
|
||||
if (res.code == "SUCCESS") {
|
||||
let procList = res.data; //Array List
|
||||
const $listContainer = $("#apiKeyBody");
|
||||
$listContainer.empty(); // 기존 내용 제거
|
||||
// 데이터 반복
|
||||
$.each(res.data, function(i, item) {
|
||||
// DOM에 추가
|
||||
$listContainer.append(drawApiKeyList(item));
|
||||
});
|
||||
} else {
|
||||
alert("승인처리 중 오류가 발생했습니다. 다시 시도해주세요");
|
||||
}
|
||||
},
|
||||
error : function(response){
|
||||
alert("승인처리 중 내부 오류가 발생했습니다. 다시 시도해주세요");
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue