시스템 로그: 대상 수정, 목록 조회 추가

dev
mjkhan21 6 months ago
parent aade2d437e
commit aaef3b2112

@ -10,16 +10,23 @@ import cokr.xit.base.syslog.service.bean.LogFilter;
*/
@Component("logFilter")
public class AppLogFilter extends LogFilter {
private String[] ignore = {
"login.do", "logout.do",
"/user/", "/authority/", "/code/", "/menu/", "/syslog/", "/error/"
};
@Override
protected boolean customFilter(ServiceLog log) {
switch (log.getType()) {
case ServiceLog.LOG_INOUT:
case ServiceLog.DOWNLOAD: return true;
case ServiceLog.WEB:
String url = log.getUrl();
return !url.contains("login.do")
&& !url.contains("logout.do")
&& !url.contains("/error/");
String url = blankIfEmpty(log.getUrl());
for (String str: ignore) {
if (url.contains(str))
return false;
}
return true;
default: return false;
}
}

@ -0,0 +1,7 @@
package cokr.xit.base;
import org.springframework.stereotype.Component;
@Component
public class LoggingController extends cokr.xit.base.syslog.web.LoggingController {
}

@ -48,11 +48,12 @@ DELETE FROM TB_ACTION_GRP
WHERE GRP_ID IN (<foreach collection="groupIDs" item="groupID" separator=",">#{groupID}</foreach>)</delete>
<select id="getActionList" parameterType="map" resultType="dataobject">/* 그룹별 기능 가져오기(actionGroupMapper.getActionList) */
<include refid="utility.paging-prefix" />
SELECT *
FROM TB_GRP_ACTION
<if test="groupIDs != null">WHERE GRP_ID IN (<foreach collection="groupIDs" item="groupID" separator=",">#{groupID}</foreach>)</if>
ORDER BY GRP_ID, ACTION
</select>
<include refid="utility.orderBy" />
<include refid="utility.paging-suffix" /></select>
<insert id="addActions" parameterType="map">/* 그룹별 기능 추가(actionGroupMapper.addActions) */
INSERT INTO TB_GRP_ACTION (GRP_ID, ACTION, REG_DT, RGTR)

@ -16,6 +16,46 @@
<result property="ipAddress" column="IP_ADDR"/> <!-- 등록 일시 -->
</resultMap>
<select id="getLogs" parameterType="map" resultType="dataobject">/* 시스템 로그 조회(loggingMapper.getLogs) */
<include refid="utility.paging-prefix" />
SELECT LOG_ID
, A.LOG_TYPE
, CASE MTD_NM WHEN 'onLogin' THEN '로그인'
WHEN 'onLogout' THEN '로그아웃'
WHEN 'onFailure' THEN '로그인 실패'
ELSE LOG_TYPE_NM
END LOG_TYPE_NM
, URL
, CLS_NM
, MTD_NM
, NULL DSCRP
, FILE_NM
, DATA_CNT
, DATA_NM
, PSNL_INFO
, A.USER_ID
, USER_ACNT
, USER_NM
, NSTT_CD
, IP_ADDR
, A.REG_DT
FROM TB_SYS_LOG A LEFT OUTER JOIN
TB_USER B ON A.USER_ID = B.USER_ID,
(SELECT 'log-inout' LOG_TYPE, '로그인아웃' LOG_TYPE_NM FROM DUAL UNION
SELECT 'download' LOG_TYPE, '다운로드' LOG_TYPE_NM FROM DUAL UNION
SELECT 'service' LOG_TYPE, '서비스' LOG_TYPE_NM FROM DUAL UNION
SELECT 'web' LOG_TYPE, '웹' LOG_TYPE_NM FROM DUAL
) C
<where><if test="fromDate != null"> AND LOG_ID >= CONCAT(#{fromDate}, LPAD(0, 16, '0'))</if>
<if test="toDate != null"> AND LOG_ID &lt;= CONCAT(#{toDate}, LPAD(9, 16, '9'))</if>
<if test="logTypes != null"> AND A.LOG_TYPE IN (<foreach collection="logTypes" item="logType" separator=",">#{logType}</foreach>)</if>
<if test="userIDs != null"> AND USER_ID IN (<foreach collection="userIDs" item="userID" separator=",">#{userID}</foreach>)</if>
<if test="userAccounts != null"> AND USER_ACNT IN (<foreach collection="userAccounts" item="userAccount" separator=",">#{userAccount}</foreach>)</if>
<if test="userName != null"> AND USER_NM LIKE CONCAT('%', #{userName}, '%')</if>
AND A.LOG_TYPE = C.LOG_TYPE</where>
<include refid="utility.sortBy" />
<include refid="utility.paging-suffix" /></select>
<insert id="insertLog" parameterType="cokr.xit.base.syslog.ServiceLog">/* 시스템 로그 등록(loggingMapper.insertLog) */
<selectKey keyProperty="id" keyColumn="NEW_ID" resultType="string" order="BEFORE">
SELECT CONCAT(TODAY, LPAD(NVL(SUBSTR(MAX(LOG_ID), 9) + 1, 1), 16, '0')) NEW_ID

@ -0,0 +1,155 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" session="false"%>
<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%>
<c:set var="prefixName" scope="request">시스템 로그</c:set>
<!-- Page Body -->
<div class="d-flex flex-column flex-grow-1">
<div class="dataTables_wrapper dt-bootstrap5 no-footer">
<div id="${infoPrefix}-query" class="d-flex flex-row justify-content-between p-3">
<div class="d-flex flex-row">
<div class="input-group">
<select id="logType" class="form-select">
<option value="">로그유형</option>
<option value="log-inout">로그인/아웃</option>
<option value="download">다운로드</option>
<option value="web">웹</option>
</select>
</div>
<div class="input-group" style="margin: 0 1rem 0 1rem">
<select id="by" onchange="document.getElementById('term').focus();" class="form-select">
<option value="userName">사용자 이름</option>
<option value="userAccount">사용자 계정</option>
<option value="userID">사용자 아이디</option>
</select>
<input id="term" type="text" placeholder="조회 조건을 입력하십시오." class="form-control">
</div>
<div class="input-group">
<input id="fromDate" type="text" value="${fromDate}" required placeholder="시작일자" class="form-control">
<span style="margin: 0 .5rem 0 .5rem"> ~ </span>
<input id="toDate" type="text" value="${toDate}" required placeholder="종료일자" class="form-control">
</div>
</div>
<div>
<button onclick="search${infoPrefix}s();" class="btn btn-primary">찾기</button>
<button onclick="${infoPrefix}Control.download();" class="btn btn-primary not-empty">다운로드</button>
</div>
</div>
<div class="table-responsive">
<table class="datatables-ajax table table-bordered dataTable no-footer" id="DataTables_Table_0" aria-describedby="DataTables_Table_0_info">
<thead>
<tr><th style="width: auto;">계정</th>
<th style="width: auto;">사용자이름</th>
<th style="width: auto;">IP 주소</th>
<th style="width: max-content;">로그유형</th>
<th style="width: max-content;">접속일시</th>
<th style="width: auto;">URL</th>
<th style="width: auto;">설명</th>
<th style="width: auto;">파일이름</th>
<th style="width: auto;">민감정보</th>
</tr>
</thead>
<tbody id="${infoPrefix}List">
</tbody>
<template id="${infoPrefix}Row">
<tr data-key="{LOG_ID}" {onclick}>
<td>{USER_ACNT}</td>
<td>{USER_NM}</td>
<td>{IP_ADDR}</td>
<td>{LOG_TYPE_NM}</td>
<td>{REG_DT}</td>
<td>{URL}</td>
<td>{DSCRP}</td>
<td>{FILE_NM}</td>
<td>{PSNL_INFO}</td>
</tr>
</template>
<template id="${infoPrefix}NotFound">
<tr class="odd">
<td valign="top" colspan="8" class="dataTables_empty text-center">${prefixName} 정보를 찾지 못했습니다.</td>
</tr>
</template>
</table>
</div>
<div class="d-flex flex-row p-3 justify-content-between">
<label id="${infoPrefix}PagingInfo" class="dataTables_info" role="status" aria-live="polite"></label>
<ul id="${infoPrefix}Paging" class="pagination pagination-primary">
</ul>
</div>
</div>
</div>
<!--/ Page Body -->
<script >
var ${infoPrefix}Control = new DatasetControl({
prefix: "${infoPrefix}",
prefixName: "${prefixName}",
keymapper: row => row.LOG_ID,
dataGetter: obj => obj.${infoPrefix}List,
query: {}
});
function search${infoPrefix}s() {
let logType = $("#logType").val(),
params = {
logTypes: logType ? [logType] : [],
fromDate: $("#fromDate").val().replace(/-/gi, ""),
toDate: $("#toDate").val().replace(/-/gi, "")
},
terms = $("#${infoPrefix}-query #term").val();
if (terms) {
switch ($("#${infoPrefix}-query #by").val()) {
case "userName": params.userName = terms; break;
case "userAccount": params.userAccounts = [terms]; break;
case "userID": params.userIDs = [terms]; break;
default: break;
}
}
${infoPrefix}Control.query = params;
${infoPrefix}Control.load(1);
}
${infoPrefix}Control.onDatasetChange = obj => {
let ${infoPrefix}List = ${infoPrefix}Control.dataset,
empty = ${infoPrefix}List.empty,
trs = empty ?
[document.getElementById("${infoPrefix}NotFound").innerHTML] : <%-- from template#${infoPrefix}NotFound --%>
${infoPrefix}List.inStrings(
document.getElementById("${infoPrefix}Row").innerHTML, <%-- from template#${infoPrefix}Row --%>
(str, dataItem) => str
.replace(/{onclick}=""/gi, 'onclick="syslogControl.setCurrent(\'' + dataItem.getValue("LOG_ID") + '\');"')
);
$("#${infoPrefix}List").html(trs.join());
$("#${infoPrefix}-query button.not-empty").prop("disabled", empty);
$("#${infoPrefix}Paging").setPaging({
list:${infoPrefix}Control.dataset,
prefix:${infoPrefix}Control.prefix,
start:obj.${infoPrefix}Start,
totalSize:obj.${infoPrefix}Total,
fetchSize:obj.${infoPrefix}Fetch,
func:"${infoPrefix}Control.load({index})"
});
};
${infoPrefix}Control.onCurrentChange = item => {
if (!item) return;
let key = item.data.LOG_ID;
$("#${infoPrefix}List").setCurrentRow(key);
};
$("#term").onEnterPress(search${infoPrefix}s);
$(function(){
${onload}
${infoPrefix}Control.setData({
${infoPrefix}List:${syslogList},
${infoPrefix}Start:${syslogStart},
${infoPrefix}Fetch:${syslogFetch},
${infoPrefix}Total:${syslogTotal}
});
$("#${infoPrefix}-query #fromDate, #${infoPrefix}-query #toDate").datePicker();
});
//# sourceURL=${infoPrefix}-main.jsp
</script>

@ -57,6 +57,11 @@ class ActionGroupControl {
onGroupSelect(selected) {}
getActions(groupID, pageNum) {
this.actions.query.groupIDs = groupID;
this.actions.load(pageNum);
}
async selectActionGroup() {
return new Promise((resolve, reject) => {
ajax.get({

Loading…
Cancel
Save