diff --git a/egovframe-template-simple-react-contribution/package.json b/egovframe-template-simple-react-contribution/package.json
index ed30ed4..23ee0c8 100644
--- a/egovframe-template-simple-react-contribution/package.json
+++ b/egovframe-template-simple-react-contribution/package.json
@@ -19,7 +19,8 @@
"react-scripts": "5.0.1",
"recharts": "^2.10.3",
"styled-components": "^6.0.9",
- "web-vitals": "^2.1.4"
+ "web-vitals": "^2.1.4",
+ "date-fns": "^3.2.0"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.16.4",
diff --git a/egovframe-template-simple-react-contribution/src/css/component.css b/egovframe-template-simple-react-contribution/src/css/component.css
index 46b1639..a831a71 100644
--- a/egovframe-template-simple-react-contribution/src/css/component.css
+++ b/egovframe-template-simple-react-contribution/src/css/component.css
@@ -251,6 +251,7 @@ select::-ms-expand {display:none;}
.active {background-color: #007bff; color: #fff;}
.f_input {height: 46px; padding: 0 20px; border: 0; border-radius: 5px; color: #222; font-size: 16px; background: #f7f7f7;}
+.f_input1 {width:200px; height: 32px; padding: 0 30px 0 0; border: 0; border-radius: 5px; color: #222; font-size: 16px; background: #f7f7f7 url(css/images/bg_btn_calendar.png) no-repeat;background-position: right center; background-size: 32px 32px; cursor: pointer;} /* made by lim f_input1*/
.f_input2 {height: 46px; padding: 0 20px; border: 1px solid #dde2e5; border-radius: 5px !important; color: #222; font-size: 16px; background: #fff;}
.f_txtar {padding: 10px 19px; border: 1px solid #dde2e5; border-radius: 5px; color: #222; font-size: 16px; line-height: 24px; resize: none;}
@@ -301,4 +302,30 @@ select::-ms-expand {display:none;}
.react-datepicker__input-container {display: inline-block; vertical-align: top; width: auto;}
/* 리액트 관련 */
-.react-datepicker__tab-loop {display: inline-block;}
\ No newline at end of file
+.react-datepicker__tab-loop {display: inline-block;}
+
+/* recharts */
+.recharts-tooltip-wrapper .custom-tooltip {
+ background-color: hsla(0,0%,100%,.8);
+ border: 1px solid #f5f5f5;
+ line-height: 24px;
+ margin: 0;
+ padding: 10px;
+ width: 200px
+}
+
+.recharts-tooltip-wrapper .custom-tooltip .label {
+ color: #666;
+ font-weight: 700;
+ margin: 0
+}
+
+.recharts-tooltip-wrapper .custom-tooltip .desc {
+ color: #999;
+ margin: 0
+}
+
+.recharts-tooltip-wrapper .custom-tooltip .intro {
+ border-top: 1px solid #f5f5f5;
+ margin: 0
+}
\ No newline at end of file
diff --git a/egovframe-template-simple-react-contribution/src/css/page.css b/egovframe-template-simple-react-contribution/src/css/page.css
index dd51e33..5c0faf7 100644
--- a/egovframe-template-simple-react-contribution/src/css/page.css
+++ b/egovframe-template-simple-react-contribution/src/css/page.css
@@ -250,6 +250,12 @@
.BRD009 .result .list_item > div:nth-child(5) {width: 150px;}
.BRD009 .result .list_item > div:nth-child(6) {width: 150px;}
+ /* 로그현황 - 메뉴별/사용자별 접속현황*/
+ .BRD010 .head > span:nth-child(1) {width: 60%;}
+ .BRD010 .head > span:nth-child(2) {width: 40%;}
+ .BRD010 .result .list_item > div:nth-child(1) {width: 60%; text-overflow: ellipsis; white-space: nowrap; overflow: hidden;}
+ .BRD010 .result .list_item > div:nth-child(2) {width: 40%;}
+
/* 게시판 사용관리 등록 */
.BOARD_USE_LIST .board_view2 dl dt {width: 185px;}
.BOARD_USE_LIST .board_view2 dl:nth-child(2) dd .f_input2 {width: 490px; margin-left: 17px;}
diff --git a/egovframe-template-simple-react-contribution/src/css/response.css b/egovframe-template-simple-react-contribution/src/css/response.css
index 782e0ed..a133244 100644
--- a/egovframe-template-simple-react-contribution/src/css/response.css
+++ b/egovframe-template-simple-react-contribution/src/css/response.css
@@ -447,6 +447,13 @@
.BRD009 .result .list_item > div:nth-child(6)::after {content: ""; display: inline-block; width: 1px; height: 11px; margin-left: 6px; background: #ccc; vertical-align: 0px;}
.BRD009 .result .list_item > div:nth-child(6)::after {content: none;}
+ /* 로그현황 - 메뉴별/사용자별 접속현황*/
+ .BRD010 .head {border-top: 1px solid #dde2e5;}
+ .BRD010 .result .list_item {padding: 16px 0; border-bottom: 1px solid #dde2e5;}
+ .BRD010 .result .list_item > div {border-bottom: 0; font-size: 14px;}
+ .BRD010 .result .list_item > div:nth-child(1) {width: 60%;}
+ .BRD010 .result .list_item > div:nth-child(2) {width: 40%; padding: 0 0 2px 0; font-weight: 700; text-align: left;}
+
.BOARD_USE_LIST .board_view2 dl dt {width: 95px;}
.BOARD_USE_LIST .board_view2 dl:nth-child(2) dd .f_select {width: 100%;}
.BOARD_USE_LIST .board_view2 dl:nth-child(2) dd .f_input2 {width: 100%; margin: 15px 0 0 0;}
@@ -553,5 +560,7 @@
.BRD009 .result .list_item > div:nth-child(4)::after,
.BRD009 .result .list_item > div:nth-child(5)::after,
.BRD009 .result .list_item > div:nth-child(6)::after {margin-left: 15px;}
-
+
+ /* 로그현황 - 메뉴별/사용자별 접속현황*/
+ /*.BRD010 .result .list_item > div:nth-child(1)*/
}
\ No newline at end of file
diff --git a/egovframe-template-simple-react-contribution/src/pages/admin/logs/MenuAccessInfo.jsx b/egovframe-template-simple-react-contribution/src/pages/admin/logs/MenuAccessInfo.jsx
index 455de22..0815629 100644
--- a/egovframe-template-simple-react-contribution/src/pages/admin/logs/MenuAccessInfo.jsx
+++ b/egovframe-template-simple-react-contribution/src/pages/admin/logs/MenuAccessInfo.jsx
@@ -1,13 +1,230 @@
-import React from 'react';
+import React, {useState, useEffect, useCallback, useRef, PureComponent} from 'react';
+import { Link, useLocation } from 'react-router-dom';
+import {BarChart, Bar, Rectangle, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer} from 'recharts';
+
+import DatePicker from 'react-datepicker';
+import 'react-datepicker/dist/react-datepicker.css';
+
+import {format, sub} from "date-fns";
+import { ko } from 'date-fns/locale';
+
+import * as EgovNet from 'api/egovFetch';
+import URL from 'constants/url';
+
+import { default as EgovLeftNav } from 'components/leftmenu/EgovLeftNavAdmin';
+
+import { itemIdxByPage } from 'utils/calc';
-function MenuAccessInfo(props) {
+function MenuConnections(props) {
+ // console.group("EgovAdminPrivacyList");
+ // console.log("[Start] EgovAdminPrivacyList ------------------------------");
+ // console.log("EgovAdminPrivacyList [props] : ", props);
+ const nowDate = new Date();
+ const oneMonthAgoDate = sub(nowDate, { months: 1 });
+ const [start_date, setStartDate] = useState(oneMonthAgoDate);
+ const [end_date, setEndDate] = useState(nowDate); // new Date()
+
+ const location = useLocation();
+ // console.log("EgovAdminPrivacyList [location] : ", location);
+
+ // eslint-disable-next-line no-unused-vars
+ const [searchCondition, setSearchCondition] = useState(location.state?.searchCondition || {start_date: format(start_date, "yyyy-MM-dd"), end_date: format(end_date, "yyyy-MM-dd")});
+ const [chartData, setChartData] = useState([]);
+
+ const [listTag, setListTag] = useState([]);
+
+ const retrieveList = useCallback((srchCnd) => {
+ // console.groupCollapsed("EgovAdminUsageList.retrieveList()");
+ const retrieveListURL = '/admin/logs/menu';
+
+ const requestOptions = {
+ method: "POST",
+ headers: {
+ 'Content-type': 'application/json',
+ },
+ body: JSON.stringify(srchCnd)
+ }
+
+ EgovNet.requestFetch(
+ retrieveListURL,
+ requestOptions,
+ (resp) => {
+ let mutListTag = [];
+
+ const resultCnt = parseInt(resp.result.resultCnt);
+ const currentPageNo = 1; // resp.result.paginationInfo.currentPageNo;
+ const pageSize = resultCnt; // resp.result.paginationInfo.pageSize;
+
+ // 리스트 항목 구성
+ if (resultCnt === 0) {
+ mutListTag.push(
데이터가 없습니다.
);
+ } else {
+ resp.result.resultList.forEach(function (item, index) {
+ // if (index === 0) mutListTag = []; // 목록 초기화
+ const listIdx = itemIdxByPage(resultCnt, currentPageNo, pageSize, index);
+
+ mutListTag.push(
+
+
{item[1]}
+
{item[2].toLocaleString()}
+
+ );
+ });
+ }
+ setListTag(mutListTag);
+
+ let chartDataArray = resp.result.resultList.map((item, index) => ({
+ logCnt: item[1], // Assuming logCnt is the x-axis data
+ "접속수": item[2], // Assuming menuTitle is the y-axis data
+ }));
+ setChartData(chartDataArray);
+ },
+ function (resp) {
+ console.log("err response : ", resp);
+ }
+ );
+ // console.groupEnd("EgovAdminPrivacyList.retrieveList()");
+ },[listTag]);
+
+ const CustomTooltip = ({ active, payload, label }) => {
+ if (active && payload && payload.length) {
+ return (
+
+
메뉴별 접속현황
+
{`${label} : ${payload[0].value}`}
+ {/*
Anything you want can be displayed here.
*/}
+
+ );
+ }
+ return null;
+ };
+
+ useEffect(() => {
+ retrieveList(searchCondition);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [start_date, end_date]);
+
+ // console.log("------------------------------EgovAdminPrivacyList [End]");
+ // console.groupEnd("EgovAdminPrivacyList");
return (
- MenuAccessInfo
+
+ {/* */}
+
+
+ Home
+ 사이트관리
+ 로그현황
+ 메뉴별 접속현황
+
+
+ {/* */}
+
+
+ {/* */}
+
+ {/* */}
+
+
+ {/* */}
+
+
+
메뉴별 접속현황
+
+
+ {/* */}
+
+
+
+ {
+ setStartDate(date);
+ setSearchCondition({
+ start_date: format(date, "yyyy-MM-dd"),
+ end_date: format(end_date, "yyyy-MM-dd")
+ });
+ }}
+ /> -
+
+
+ {
+ setEndDate(date);
+ setSearchCondition({
+ start_date: format(start_date, "yyyy-MM-dd"),
+ end_date: format(date, "yyyy-MM-dd")
+ });
+ }}
+ />
+
+
+
+ {/* */}
+
+ {/* */}
+
+
+
+
+ 메뉴명
+ 접속횟수
+
+
+ {listTag}
+
+
+
+
+
+
+
+
+
+ } />
+
+ } />
+
+
+
+
+ {/* */}
+
+ {/* */}
+
+
+
);
}
-export default MenuAccessInfo;
\ No newline at end of file
+export default MenuConnections;
\ No newline at end of file
diff --git a/egovframe-template-simple-react-contribution/src/pages/admin/logs/PrivacyLogs.jsx b/egovframe-template-simple-react-contribution/src/pages/admin/logs/PrivacyLogs.jsx
index 7fadf32..86d95d6 100644
--- a/egovframe-template-simple-react-contribution/src/pages/admin/logs/PrivacyLogs.jsx
+++ b/egovframe-template-simple-react-contribution/src/pages/admin/logs/PrivacyLogs.jsx
@@ -96,6 +96,7 @@ function PrivacyConnections(props) {
Home
사이트관리
로그현황
+ 개인정보 로그현황
{/* */}
@@ -112,7 +113,7 @@ function PrivacyConnections(props) {
개인정보 로그현황
- {/* */}
+ {/* */}
번호
@@ -126,7 +127,7 @@ function PrivacyConnections(props) {
{listTag}
- {/* */}
+ {/* */}
{/* */}
diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/AdminLogsController.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/AdminLogsController.java
index 568959f..398de83 100644
--- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/AdminLogsController.java
+++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/AdminLogsController.java
@@ -1,6 +1,8 @@
package com.dbnt.kcscbackend.admin.logs;
+import com.dbnt.kcscbackend.admin.logs.entity.TnDailyMenuLog;
import com.dbnt.kcscbackend.admin.logs.entity.ThPrivacyLog;
+import com.dbnt.kcscbackend.admin.logs.service.AdminMenuService;
import com.dbnt.kcscbackend.admin.logs.service.AdminLogsService;
import com.dbnt.kcscbackend.auth.entity.LoginVO;
import com.dbnt.kcscbackend.config.common.BaseController;
@@ -11,17 +13,16 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
-import org.egovframe.rte.fdl.property.EgovPropertyService;
-import org.egovframe.rte.ptl.mvc.tags.ui.pagination.PaginationInfo;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.*;
+
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.util.Date;
-import javax.annotation.Resource;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
@RestController
@@ -30,20 +31,47 @@ import java.util.Map;
@Tag(name="AdminLogsController", description = "사이트관리 로그현황 메뉴 컨트롤러")
public class AdminLogsController extends BaseController {
- @Resource(name = "propertiesService")
- protected EgovPropertyService propertyService;
-
+ private final AdminMenuService adminMenuService;
private final AdminLogsService adminLogsService;
@Operation(
- summary = "로그현황 - 개인정보 로그",
- description = "개인정보 로그현황",
+ summary = "로그현황 - 메뉴별 접속현황",
+ description = "메뉴별 접속현황",
tags = {"AdminLogsController"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "조회 성공"),
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
})
+ @RequestMapping(method = RequestMethod.POST, value = "/menu", consumes = MediaType.APPLICATION_JSON_VALUE)
+ public ResultVO MenuListCount(@RequestBody Map dateRange,
+ @AuthenticationPrincipal LoginVO user)
+ throws Exception {
+
+ ResultVO resultVO = new ResultVO();
+ Map resultMap = new HashMap<>();
+
+ String startDate = dateRange.get("start_date");
+ String endDate = dateRange.get("end_date");
+
+ resultMap.put("resultCnt", adminMenuService.selectMenuCountCnt(startDate, endDate));
+ resultMap.put("resultList", adminMenuService.selectMenuCount(startDate, endDate));
+ resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
+ resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage());
+ resultVO.setResult(resultMap);
+ return resultVO;
+ }
+
+
+ @Operation(
+ summary = "로그현황 - 개인정보 로그",
+ description = "개인정보 로그현황",
+ tags = {"AdminLogsController"}
+ )
+ @ApiResponses(value = {
+ @ApiResponse(responseCode = "200", description = "조회 성공"),
+ @ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
+ })
@RequestMapping(method = RequestMethod.POST, value = "/privacy", consumes = MediaType.APPLICATION_JSON_VALUE)
public ResultVO selectPrivacyLogsList(@RequestBody ThPrivacyLog thPrivacyLog, @AuthenticationPrincipal LoginVO user)
throws Exception {
@@ -62,5 +90,4 @@ public class AdminLogsController extends BaseController {
return resultVO;
}
-
}
diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/entity/TnDailyMenuLog.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/entity/TnDailyMenuLog.java
new file mode 100644
index 0000000..5fd0bd6
--- /dev/null
+++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/entity/TnDailyMenuLog.java
@@ -0,0 +1,40 @@
+package com.dbnt.kcscbackend.admin.logs.entity;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+import org.hibernate.annotations.DynamicInsert;
+import org.hibernate.annotations.DynamicUpdate;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import javax.persistence.*;
+import java.time.LocalDate;
+import java.awt.*;
+
+@Getter
+@Setter
+@Accessors(chain = true)
+@Entity
+@NoArgsConstructor
+@DynamicInsert
+@DynamicUpdate
+@Table(name = "tn_daily_menu_log")
+public class TnDailyMenuLog {
+ @Id
+ @Column(name = "dml_seq")
+ private Long dmlSeq;
+
+ @Column(name = "menu_id")
+ private String menuId;
+
+ @Column(name = "menu_title")
+ private String menuTitle;
+
+ @Column(name = "log_cnt")
+ private Long logCnt;
+
+ @Column(name = "log_dt")
+ @DateTimeFormat(pattern = "yyyy-MM-dd")
+ private LocalDate logDt;
+}
diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/repository/MenuLogsRepository.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/repository/MenuLogsRepository.java
new file mode 100644
index 0000000..0ea127a
--- /dev/null
+++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/repository/MenuLogsRepository.java
@@ -0,0 +1,26 @@
+package com.dbnt.kcscbackend.admin.logs.repository;
+
+import com.dbnt.kcscbackend.admin.logs.entity.TnDailyMenuLog;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
+
+import java.time.LocalDate;
+import java.util.List;
+
+public interface MenuLogsRepository extends JpaRepository {
+
+ @Query(value = "SELECT COUNT(DISTINCT menu_id) "
+ + "FROM tn_daily_menu_log "
+ + "WHERE log_dt BETWEEN TO_DATE(:startDate, 'YYYY-MM-DD') AND TO_DATE(:endDate, 'YYYY-MM-DD')", nativeQuery = true)
+ long countDistinctMenuIds(@Param("startDate") String startDate, @Param("endDate") String endDate);
+
+ @Query(value = "SELECT menu_id, MAX(menu_title) as menu_title, sum(log_cnt) as log_cnt "
+ + "FROM tn_daily_menu_log "
+ + "WHERE log_dt BETWEEN TO_DATE(:startDate, 'YYYY-MM-DD') AND TO_DATE(:endDate, 'YYYY-MM-DD') "
+ + "GROUP BY menu_id "
+ + "ORDER BY log_cnt desc", nativeQuery = true)
+ List selectCountMenu(@Param("startDate") String startDate, @Param("endDate") String endDate);
+
+
+}
diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/repository/PrivacyLogsRepository.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/repository/PrivacyLogsRepository.java
index aca2cb7..ad0fe00 100644
--- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/repository/PrivacyLogsRepository.java
+++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/repository/PrivacyLogsRepository.java
@@ -6,7 +6,5 @@ import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface PrivacyLogsRepository extends JpaRepository {
- long count(); // 전체 레코드 수를 반환하는 메서드
-
List findAllByOrderByUplSeqDesc();
}
diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/service/AdminLogsService.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/service/AdminLogsService.java
index 11ad845..97db4df 100644
--- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/service/AdminLogsService.java
+++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/service/AdminLogsService.java
@@ -16,9 +16,6 @@ public class AdminLogsService extends EgovAbstractServiceImpl {
private final PrivacyLogsRepository privacyLogsRepository;
-// public List selectPrivacyList(){
-// return privacyLogsRepository.findAll();
-// }
public Map selectPrivacyList() {
Map resultMap = new HashMap<>();
diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/service/AdminMenuService.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/service/AdminMenuService.java
new file mode 100644
index 0000000..03f1f85
--- /dev/null
+++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/service/AdminMenuService.java
@@ -0,0 +1,27 @@
+package com.dbnt.kcscbackend.admin.logs.service;
+
+import com.dbnt.kcscbackend.admin.logs.entity.TnDailyMenuLog;
+import com.dbnt.kcscbackend.admin.logs.repository.MenuLogsRepository;
+import lombok.RequiredArgsConstructor;
+import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDate;
+import java.util.List;
+
+@Service
+@RequiredArgsConstructor
+public class AdminMenuService extends EgovAbstractServiceImpl {
+ private final MenuLogsRepository menuLogsRepository;
+
+ // 메뉴별 접속횟수
+ public List selectMenuCount(String startDate, String endDate) {
+ return menuLogsRepository.selectCountMenu(startDate, endDate);
+ }
+
+ // 전체 레코드 수 가져오기
+ public long selectMenuCountCnt(String startDate, String endDate) {
+ return menuLogsRepository.countDistinctMenuIds(startDate, endDate);
+ }
+
+}