API 관리 > API 신청 관리 - 관리자가 사용자의 API 키 말소시키기

main
유지인 2025-11-10 17:48:58 +09:00
parent 23c95c2380
commit bb3acba7c3
7 changed files with 93 additions and 12 deletions

View File

@ -174,4 +174,32 @@ public class ApiManagementController {
return result;
}
/**
* API > API .
* @param params
* @param model
* @param response
* @param request
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping(value = "/admins/mgmtApiKey/revoke.do", method = RequestMethod.POST)
public HashMap<String, Object> modMgmtApiKeyRevoke(@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);
apiManagementService.deleteWebApiKey(params);
List<?> listData = apiManagementService.selectWebApiKeyList(params);
result.put("code", "SUCCESS");
result.put("msg", " API 신청 목록 조회를 성공했습니다.");
result.put("data", listData);
return result;
}
}

View File

@ -24,4 +24,6 @@ public interface ApiManagementMapper {
public List<?> selectWebApiKeyList(HashMap<String, Object> params) throws Exception;
public void updateWebApiKeyApprove(HashMap<String, Object> params) throws Exception;
public void deleteWebApiKey(HashMap<String, Object> params) throws Exception;
}

View File

@ -24,4 +24,6 @@ public interface ApiManagementService {
public List<?> selectWebApiKeyList(HashMap<String, Object> params) throws Exception;
public void updateWebApiKeyApprove(HashMap<String, Object> params) throws Exception;
public void deleteWebApiKey(HashMap<String, Object> params) throws Exception;
}

View File

@ -56,4 +56,10 @@ public class ApiManagementServiceImpl implements ApiManagementService {
masterMapper.updateWebApiKeyApprove(params);
}
@Override
public void deleteWebApiKey(HashMap<String, Object> params) throws Exception {
masterMapper.deleteWebApiKey(params);
}
}

View File

@ -97,4 +97,11 @@
</if>
WHERE API_SEQ IN (#{apiSeq})
</update>
<!-- 사용자 API 신청 철회하기 -->
<delete id="deleteWebApiKey" parameterType="map">
DELETE
FROM WEB_API_KEY
WHERE API_SEQ IN (#{apiSeq})
</delete>
</mapper>

View File

@ -16,7 +16,7 @@ var waitWin;
727보다 크게 하는 경우는 문제 없습니다.
-->
<iframe src="${pageContext.request.contextPath}/admins/${menuId}/${pId}.do?isFirst=true" frameborder="0" height="650" width="1200" scrolling="yes" name="iframeMain" style="overflow-x: hidden;"></iframe>
<iframe src="${pageContext.request.contextPath}/admins/${menuId}/${pId}.do?isFirst=true" frameborder="0" height="650" width="1300" scrolling="yes" name="iframeMain" style="overflow-x: hidden;"></iframe>
</body>
</html>

View File

@ -15,7 +15,8 @@
<style>
body { font-family: 'Pretendard', 'Roboto', sans-serif; background-color: #f5f6fa; margin: 0; padding: 20px; }
/* 로그 테이블 */
.text-center {text-align: center}
/* API 신청 내역 테이블 */
.table-container {
margin-top: 25px; background: #fff; border-radius: 12px; padding: 20px;
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
@ -64,16 +65,18 @@
<col style="width: 15%">
<col style="width: 15%">
<col style="width: 8%">
<col style="width: 8%">
</colgroup>
<thead>
<tr>
<th>No.</th>
<th class="text-center">No.</th>
<th>사용자 ID</th>
<th>사용자 구분</th>
<th class="text-center">사용자 구분</th>
<th>API KEY</th>
<th>신청일</th>
<th>만료일</th>
<th>승인상태</th>
<th class="text-center">신청일</th>
<th class="text-center">만료일</th>
<th class="text-center">승인상태</th>
<th class="text-center">삭제</th>
</tr>
</thead>
<tbody id="apiKeyBody">
@ -128,13 +131,14 @@
// HTML 문자열 생성
const html = `
<tr data-idx="\${item.apiSeq}">
<td>\${item.rn}</td>
<td class="text-center">\${item.rn}</td>
<td>\${item.userid}</td>
<td>\${item.userType}</td>
<td class="text-center">\${item.userType}</td>
<td>\${item.apiKey}</td>
<td>\${item.startDt}</td>
<td>\${item.endDt}</td>
<td>\${approveHtml}</td>
<td class="text-center">\${item.startDt}</td>
<td class="text-center">\${item.endDt}</td>
<td class="text-center">\${approveHtml}</td>
<td class="text-center"><button class="approve-btn" data-id="\${item.apiSeq}" onclick="revokeKey(this);">철회</button></td>
</tr>
`;
return html;
@ -168,6 +172,38 @@
}
});
}
// 사용자 API 신청 철회하기
function revokeKey(e) {
if(confirm("사용자의 API 신청을 삭제합니다.")) {
let apiSeq = $(e).data("id")
$.ajax({
type : "POST",
url : "/admins/mgmtApiKey/revoke.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>