build: merge with master

thkim
thkim 2024-02-29 16:13:52 +09:00
commit c0504044ad
23 changed files with 1137 additions and 156 deletions

View File

@ -9,7 +9,7 @@ import EgovPaging from 'components/EgovPaging';
import { itemIdxByPage } from 'utils/calc';
function EgovAdminBoardList(props) {
function AdminPostMgtList(props) {
console.group("EgovAdminBoardList");
console.log("[Start] EgovAdminBoardList ------------------------------");
console.log("EgovAdminBoardList [props] : ", props);
@ -100,7 +100,7 @@ function EgovAdminBoardList(props) {
<ul>
<li><Link to={URL.MAIN} className="home">Home</Link></li>
<li><Link to={URL.ADMIN}>사이트관리</Link></li>
<li>게시판생성 관리</li>
<li>게시 관리</li>
</ul>
</div>
{/* <!--// Location --> */}
@ -117,7 +117,7 @@ function EgovAdminBoardList(props) {
<h1 className="tit_1">사이트관리</h1>
</div>
<h2 className="tit_2">게시판생성 관리</h2>
<h2 className="tit_2">게시 관리</h2>
{/* <!-- 검색조건 --> */}
<div className="condition">
@ -196,4 +196,4 @@ function EgovAdminBoardList(props) {
);
}
export default EgovAdminBoardList;
export default AdminPostMgtList;

View File

@ -1,13 +1,90 @@
import React, { useState, useEffect, useCallback } from 'react';
import { Link, useLocation } from 'react-router-dom';
import React, {useState, useEffect, useCallback} from 'react';
import {Link, useLocation} from 'react-router-dom';
import * as EgovNet from 'api/egovFetch';
import URL from 'constants/url';
import { default as EgovLeftNav } from 'components/leftmenu/EgovLeftNavAdmin';
import {default as EgovLeftNav} from 'components/leftmenu/EgovLeftNavAdmin';
import Modal from "react-bootstrap/Modal";
import CODE from "../../../constants/code";
import EgovAdminBoardEdit from "../board/EgovAdminBoardEdit";
import {format} from "date-fns";
function StandardCodeMgt(props) {
const location = useLocation();
const [searchCondition, setSearchCondition] = useState(location.state?.searchCondition || { pageIndex: 1, searchCnd: '0', searchWrd: '' });// ||
const [paginationInfo, setPaginationInfo] = useState({});
const [listTag, setListTag] = useState([]);
const [show, setShow] = useState(false);
const [modalBody, setModalBody] = useState();
const handleClose = () => setShow(false);
const handleShow = () => setShow(true);
const retrieveList = useCallback(() => {
handleClose();
console.groupCollapsed("AdminBoardList.retrieveList()");
const retrieveListURL = '/admin/boards/board-list';
const requestOptions = {
method: "GET",
headers: {
'Content-type': 'application/json',
},
body: JSON.stringify()
}
EgovNet.requestFetch(retrieveListURL,
requestOptions,
(resp) => {
let mutListTag = [];
listTag.push(<p className="no_data" key="0">검색된 결과가 없습니다.</p>); //
//
resp.result.boardList.forEach(function (item, index) {
if (index === 0) mutListTag = []; //
mutListTag.push(
<div className="list_item">
<div>{item.bbsSeq}</div>
<div>{item.bbsId}</div>
<div>{item.bbsTitle}</div>
<div>{item.frstCrtId}</div>
<div>{item.frstCrtDt ? format(item.frstCrtDt, "yyyy-MM-dd HH:mm") : ""}</div>
<div>{item.lastChgDt ? format(item.lastChgDt, "yyyy-MM-dd HH:mm") : ""}</div>
<div><button className={"btn btn_blue_h31 px-1"} onClick={()=>{editBoard(item)}}>수정</button></div>
</div>
);
});
setListTag(mutListTag);
console.log("@@@ resp : ");
},
function (resp) {
console.log("err response : ", resp);
}
);
console.groupEnd("EgovAdminBoardList.retrieveList()");
},[]);
useEffect(() => {
retrieveList(searchCondition);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
function editBoard(item){
handleShow();
if(item != undefined) {
item.mode = CODE.MODE_MODIFY;
}
setModalBody(<EgovAdminBoardEdit props={item} reloadFunction={retrieveList}/>)
}
return (
<div className="container">
<div className="c_wrap">
@ -15,7 +92,7 @@ function StandardCodeMgt(props) {
<div className="location">
<ul>
<li><Link to={URL.MAIN} className="home">Home</Link></li>
<li><Link to={URL.ADMIN} >사이트관리</Link></li>
<li><Link to={URL.ADMIN}>사이트관리</Link></li>
<li>게시판현황</li>
<li>키워드 관리</li>
</ul>
@ -29,11 +106,78 @@ function StandardCodeMgt(props) {
<div className="contents NOTICE_LIST" id="contents">
<div className="top_tit">
<h1 className="tit_1">키워드 관리</h1>
<h1 className="tit_1">사이트관리</h1>
</div>
<h2 className="tit_2">키워드 관리</h2>
{/* <!-- 검색조건 --> */}
{/*<div className="condition">
<ul>
<li className="third_1 L">
<span className="lb">검색유형선택</span>
<label className="f_select" htmlFor="searchCnd">
<select id="searchCnd" name="searchCnd" title="검색유형선택" ref={cndRef}
onChange={e => {
cndRef.current.value = e.target.value;
}}
>
<option value="0">게시판명</option>
<option value="1">게시판유형</option>
</select>
</label>
</li>
<li className="third_2 R">
<span className="lb">검색어</span>
<span className="f_search w_400">
<input type="text" name="" defaultValue={searchCondition && searchCondition.searchWrd} placeholder="" ref={wrdRef}
onChange={e => {
wrdRef.current.value = e.target.value;
}}
/>
<button type="button"
onClick={() => {
retrieveList({ ...searchCondition, pageIndex: 1, searchCnd: cndRef.current.value, searchWrd: wrdRef.current.value });
}}>조회</button>
</span>
</li>
<li>
<Link to={URL.ADMIN_BOARD_CREATE} className="btn btn_blue_h46 pd35">등록</Link>
</li>
</ul>
</div>*/}
{/* <!--// 검색조건 --> */}
{/* <!-- 게시판목록 --> */}
<div className="board_list BRD006">
<div className="head">
<span>번호</span>
<span>아이디</span>
<span>제목</span>
<span>작성자</span>
<span>작성일</span>
<span>수정일</span>
<span><button className={"btn btn_blue_h31 px-1"} onClick={()=>{editBoard(undefined)}}>추가</button></span>
</div>
<div className="result">
{listTag}
</div>
</div>
{/* <!--// 게시판목록 --> */}
<div className="board_bot">
{/* <!-- Paging --> */}
{/*<EgovPaging pagination={paginationInfo} moveToPage={passedPage => {
retrieveList({ ...searchCondition, pageIndex: passedPage, searchCnd: cndRef.current.value, searchWrd: wrdRef.current.value })
}} />*/}
{/* <!--/ Paging --> */}
</div>
{/* <!--// 본문 --> */}
</div>
</div>
</div>
<Modal show={show} onHide={handleClose} keyboard={false}>
{modalBody}
</Modal>
</div>
);
}

View File

@ -100,7 +100,7 @@ function EgovAdminBoardList(props) {
<ul>
<li><Link to={URL.MAIN} className="home">Home</Link></li>
<li><Link to={URL.ADMIN}>사이트관리</Link></li>
<li>게시판생성 관리</li>
<li>게시판 관리</li>
</ul>
</div>
{/* <!--// Location --> */}
@ -117,7 +117,7 @@ function EgovAdminBoardList(props) {
<h1 className="tit_1">사이트관리</h1>
</div>
<h2 className="tit_2">게시판생성 관리</h2>
<h2 className="tit_2">게시판 관리</h2>
{/* <!-- 검색조건 --> */}
{/*<div className="condition">

View File

@ -5,9 +5,85 @@ import * as EgovNet from 'api/egovFetch';
import URL from 'constants/url';
import { default as EgovLeftNav } from 'components/leftmenu/EgovLeftNavAdmin';
import CODE from "../../../constants/code";
import Modal from "react-bootstrap/Modal";
import AboutSiteModal from "./aboutSiteMgt/AboutSiteModal";
function StandardCodeMgt(props) {
const location = useLocation();
const [searchCondition, setSearchCondition] = useState(location.state?.searchCondition || { pageIndex: 1, searchCnd: '0', searchWrd: '' });// ||
const [paginationInfo, setPaginationInfo] = useState({});
const [listTag, setListTag] = useState([]);
const [show, setShow] = useState(false);
const [modalBody, setModalBody] = useState();
const handleClose = () => setShow(false);
const handleShow = () => setShow(true);
const retrieveList = useCallback(() => {
handleClose();
console.groupCollapsed("AdminPartnerSiteList.retrieveList()");
const retrieveListURL = '/admin/config/partner-site-list';
const requestOptions = {
method: "GET",
headers: {
'Content-type': 'application/json',
},
body: JSON.stringify()
}
EgovNet.requestFetch(retrieveListURL,
requestOptions,
(resp) => {
let mutListTag = [];
listTag.push(<p className="no_data" key="0">검색된 결과가 없습니다.</p>); //
//
resp.result.partnerSiteList.forEach(function (item, index) {
if (index === 0) mutListTag = []; //
mutListTag.push(
<div className="list_item">
<div>{item.siteSeq}</div>
<div>{item.siteTitle}</div>
<div>{item.siteUrl}</div>
<div>{item.fileGrpId}</div>
<div>{item.siteOrder}</div>
<div>{item.useYn}</div>
<div><button className={"btn btn_blue_h31 px-1"} onClick={()=>{editBoard(item)}}>수정</button></div>
</div>
);
});
setListTag(mutListTag);
console.log("@@@ resp : ");
},
function (resp) {
console.log("err response : ", resp);
}
);
console.groupEnd("EgovAdminBoardList.retrieveList()");
},[]);
useEffect(() => {
retrieveList(searchCondition);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
function editBoard(item){
handleShow();
if(item != undefined) {
item.mode = CODE.MODE_MODIFY;
}
setModalBody(<AboutSiteModal props={item} reloadFunction={retrieveList}/>)
}
return (
<div className="container">
<div className="c_wrap">
@ -15,7 +91,7 @@ function StandardCodeMgt(props) {
<div className="location">
<ul>
<li><Link to={URL.MAIN} className="home">Home</Link></li>
<li><Link to={URL.ADMIN} >사이트관리</Link></li>
<li><Link to={URL.ADMIN}>사이트관리</Link></li>
<li>환경설정</li>
<li>관련사이트 관리</li>
</ul>
@ -31,9 +107,75 @@ function StandardCodeMgt(props) {
<div className="top_tit">
<h1 className="tit_1">관련사이트 관리</h1>
</div>
{/* <!-- 검색조건 --> */}
{/*<div className="condition">
<ul>
<li className="third_1 L">
<span className="lb">검색유형선택</span>
<label className="f_select" htmlFor="searchCnd">
<select id="searchCnd" name="searchCnd" title="검색유형선택" ref={cndRef}
onChange={e => {
cndRef.current.value = e.target.value;
}}
>
<option value="0">게시판명</option>
<option value="1">게시판유형</option>
</select>
</label>
</li>
<li className="third_2 R">
<span className="lb">검색어</span>
<span className="f_search w_400">
<input type="text" name="" defaultValue={searchCondition && searchCondition.searchWrd} placeholder="" ref={wrdRef}
onChange={e => {
wrdRef.current.value = e.target.value;
}}
/>
<button type="button"
onClick={() => {
retrieveList({ ...searchCondition, pageIndex: 1, searchCnd: cndRef.current.value, searchWrd: wrdRef.current.value });
}}>조회</button>
</span>
</li>
<li>
<Link to={URL.ADMIN_BOARD_CREATE} className="btn btn_blue_h46 pd35">등록</Link>
</li>
</ul>
</div>*/}
{/* <!--// 검색조건 --> */}
{/* <!-- 게시판목록 --> */}
<div className="board_list BRD006">
<div className="head">
<span>번호</span>
<span>사이트명</span>
<span>URL</span>
<span>배너이미지</span>
<span>정렬순서</span>
<span>사용여부</span>
<span><button className={"btn btn_blue_h31 px-1"} onClick={()=>{editBoard(undefined)}}>추가</button></span>
</div>
<div className="result">
{listTag}
</div>
</div>
{/* <!--// 게시판목록 --> */}
<div className="board_bot">
{/* <!-- Paging --> */}
{/*<EgovPaging pagination={paginationInfo} moveToPage={passedPage => {
retrieveList({ ...searchCondition, pageIndex: passedPage, searchCnd: cndRef.current.value, searchWrd: wrdRef.current.value })
}} />*/}
{/* <!--/ Paging --> */}
</div>
{/* <!--// 본문 --> */}
</div>
</div>
</div>
<Modal show={show} onHide={handleClose} keyboard={false}>
{modalBody}
</Modal>
</div>
);
}

View File

@ -0,0 +1,182 @@
import React, {useState, useEffect, useRef} from 'react';
import {Link, useNavigate, useLocation, useParams} from 'react-router-dom';
import Modal from "react-bootstrap/Modal";
import * as EgovNet from 'api/egovFetch';
import URL from 'constants/url';
import CODE from 'constants/code';
import {default as EgovLeftNav} from 'components/leftmenu/EgovLeftNavAdmin';
import EgovRadioButtonGroup from 'components/EgovRadioButtonGroup';
import {Form} from "react-bootstrap";
function AboutSiteModal({props, reloadFunction}) {
console.group("AboutSiteModal");
console.log("[Start] AboutSiteModal ------------------------------");
console.log("AboutSiteModal [props] : ", props);
const navigate = useNavigate();
const location = useLocation();
const checkRef = useRef([]);
console.log("AboutSiteModal [location] : ", location);
let item = null;
item = props;
console.log("@@@ item : " + JSON.stringify(item));
const [modeInfo, setModeInfo] = useState(item != null ? {mode: props.mode} : {mode: CODE.MODE_CREATE});
const [boardDetail, setBoardDetail] = useState({});
console.log("@@@ mode : " + modeInfo.mode);
useEffect(() => {
initMode();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const initMode = () => {
if (modeInfo.mode === CODE.MODE_MODIFY) {
setBoardDetail(item);
}
}
function editPartnerSite(e) {
e.preventDefault();
e.stopPropagation();
const form = e.target;
const info = {
siteTitle: form.siteTitle.value,
siteUrl: form.siteUrl.value,
fileGrpId: form.fileGrpId.value,
siteOrder: form.siteOrder.value,
useYn: form.useYn.value
}
if (modeInfo.mode === CODE.MODE_MODIFY) {
info.siteSeq = props.siteSeq;
}
EgovNet.requestFetch(
'/admin/config/partner-site-mgt',
{
method: "PUT",
headers: {
'Content-type': 'application/json'
},
body: JSON.stringify(info)
},
(resp) => {
if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) {
alert("저장되었습니다.");
reloadFunction();
} else if (Number(resp.resultCode) === Number(CODE.RCV_ERROR_AUTH)) {
console.log("토큰 갱신중.")
} else {
alert(resp.result.resultMessage)
}
}
)
}
function deletePartnerSite(partnerSite){
if(window.confirm("삭제하시겠습니까?")) {
EgovNet.requestFetch(
'/admin/config/partner-site-mgt',
{
method: "DELETE",
headers: {
'Content-type': 'application/json'
},
body: JSON.stringify(partnerSite)
},
(resp) => {
if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) {
alert("삭제되었습니다.")
reloadFunction();
} else if (Number(resp.resultCode) === Number(CODE.RCV_ERROR_AUTH)) {
console.log("토큰 갱신중.")
} else {
alert(resp.result.resultMessage)
}
}
)
}
}
console.log("------------------------------AboutSiteModal [End]");
console.groupEnd("AboutSiteModal");
const defaultUseYn = props?.useYn ? props.useYn : "Y";
return (
<>
{/* <!-- 본문 --> */}
<Modal.Header closeButton>
<Modal.Title>
{modeInfo.mode === CODE.MODE_CREATE && '관련사이트 생성'}
{modeInfo.mode === CODE.MODE_MODIFY && '관련사이트 수정'}
</Modal.Title>
</Modal.Header>
<Modal.Body>
<div className="board_view2">
<Form onSubmit={(e) => {editPartnerSite(e)}} noValidate>
<dl>
<dt><label htmlFor="siteTitle">사이트명</label><span className="req">필수</span></dt>
<dd>
<Form.Control className="f_input2 w_full" type="text" name="siteTitle" placeholder="사이트명" required
defaultValue={props?.siteTitle} readOnly={props!==undefined}/>
</dd>
</dl>
<dl>
<dt><label htmlFor="siteUrl">URL</label><span className="req">필수</span></dt>
<dd>
<Form.Control className="f_input2 w_full" type="text" name="siteUrl" placeholder="URL" required
defaultValue={props?.siteUrl}/>
</dd>
</dl>
<dl>
<dt><label htmlFor="fileGrpId">배너이미지</label><span className="req">필수</span></dt>
<dd>
<Form.Control className="f_txtar w_full" type="text" name="fileGrpId" placeholder="배너이미지" required
defaultValue={props?.fileGrpId}/>
</dd>
</dl>
<dl>
<dt><label htmlFor="siteOrder">정렬순서</label><span className="req">필수</span></dt>
<dd>
<Form.Control className="f_txtar w_full" type="text" name="siteOrder" placeholder="정렬순서" required
defaultValue={props?.siteOrder}/>
</dd>
</dl>
<dl>
<dt><label htmlFor="useYn">사용여부</label><span className="req">필수</span></dt>
<dd>
<Form.Check inline type="radio" label="Y" name="useYn" value="Y" defaultChecked={defaultUseYn === "Y"}/>
<Form.Check inline type="radio" label="N" name="useYn" value="N" defaultChecked={defaultUseYn === "N"}/>
</dd>
</dl>
{/* <!-- 버튼영역 --> */}
<div className="board_btn_area">
<div className="left_col btn1">
<button type="submit" className="btn btn_skyblue_h46 w_100">저장
</button>
{modeInfo.mode === CODE.MODE_MODIFY &&
<button type={"button"} className="btn btn_skyblue_h46 w_100" onClick={()=>{deletePartnerSite(props)}}>삭제</button>
}
</div>
<div className="right_col btn1">
<button type={"button"} className="btn btn_blue_h46 w_100" onClick={()=>{reloadFunction()}}>목록</button>
</div>
</div>
{/* <!--// 버튼영역 --> */}
</Form>
</div>
</Modal.Body>
</>
);
}
export default AboutSiteModal;

View File

@ -31,8 +31,6 @@ function EgovAdminDashboard(props) {
//
// const [searchCondition, setSearchCondition] = useState(location.state?.searchCondition || {schdulSe: '', year: TODAY.getFullYear(), month: TODAY.getMonth(), date: TODAY.getDate()});
// const [calendarTag, setCalendarTag] = useState([]);
//
// const [scheduleList, setScheduleList] = useState([]);
// const innerConsole = (...args) => {
// console.log(...args);
@ -51,29 +49,48 @@ function EgovAdminDashboard(props) {
// setSearchCondition({...searchCondition, year: changedDate.getFullYear(), month: changedDate.getMonth(), date: changedDate.getDate()});
// }
// const retrieveList = useCallback((srchcnd) => {
// console.groupCollapsed("EgovAdminScheduleList.retrieveList()");
//
// const retrieveListURL = '/schedule/month' + EgovNet.getQueryString(srchcnd);
//
// const requestOptions = {
// method: "GET",
// headers: {
// 'Content-type': 'application/json',
// }
// }
//
// EgovNet.requestFetch(retrieveListURL,
// requestOptions,
// (resp) => {
// setScheduleList(resp.result.resultList);
// },
// function (resp) {
// console.log("err response : ", resp);
// }
// );
// console.groupEnd("EgovAdminScheduleList.retrieveList()");
// }, []);
// const [countTag, setCountTag] = useState([]);
const [dashboardCnt, setDashboardCnt] = useState({
ConnMonthlyCount: [[0, 0.0, 0]],
DocuMonthlyCount: [[0, 0.0, 0]]
});
// const [item0, setItem0] = useState([]);
const retrieveList = useCallback(() => {
const retrieveListURL = '/admin/dashboard/dash-count';
const requestOptions = {
method: "POST",
headers: {
'Content-type': 'application/json',
}
}
EgovNet.requestFetch(retrieveListURL,
requestOptions,
(resp) => {
// let mutCountTag = [];
setDashboardCnt(resp.result);
console.log(resp.result.ConnMonthlyCount);
// mutCountTag.push(
// <div key={listIdx} className="list_item">
// <div>{listIdx}</div>
// <div>{item.userId}</div>
// <div>{item.targetUserId}</div>
// <div>{item.accessType === "PRV_LIST" ? " " : item.accessType === "PRV_VIEW" ? "User " : "User "}</div>
// <div>{item.ipAddress}</div>
// <div>{item.accessDt}</div>
// </div>
// );
// setCountTag(mutCountTag);
},
function (resp) {
console.log("err response : ", resp);
}
);
// eslint-disable-next-lie react-hooks/exhaustive-deps
}, []);
// const Location = React.memo(function Location() {
@ -88,10 +105,9 @@ function EgovAdminDashboard(props) {
// )
// });
// useEffect(() => {
// //retrieveList(searchCondition); disabled by thkim
// // eslint-disable-next-line react-hooks/exhaustive-deps
// }, [searchCondition]);
useEffect(() => {
retrieveList();
}, [retrieveList]);
// const [dailyUserLogList, setDailyUserLogList] = useState([]);
// const [isDailyChart, setIsDailyChart] = useState(true);
@ -236,16 +252,16 @@ function EgovAdminDashboard(props) {
{/* <Typography variant="h5">Dashboard</Typography>*/}
{/*</Grid>*/}
<Grid item xs={12} sm={6} md={4} lg={3}>
<AnalyticEcommerce title={`총접속자수 (${DATE.getMonth() + 1}월)`} count="442,236" percentage={59.3} extra="35,000" />
<AnalyticEcommerce title={`총접속자수 (${DATE.getMonth() + 1}월)`} count={dashboardCnt.ConnMonthlyCount[0]?.[0]?.toLocaleString() || '0'} percentage={parseFloat(dashboardCnt.ConnMonthlyCount[0]?.[1]) || 0} extra={dashboardCnt.ConnMonthlyCount[0]?.[2]?.toLocaleString() || '0'} isLoss={dashboardCnt.ConnMonthlyCount[0]?.[1] < 0} color={dashboardCnt.ConnMonthlyCount[0]?.[1] < 0 ? "warning" : "primary"} />
</Grid>
<Grid item xs={12} sm={6} md={4} lg={3}>
<AnalyticEcommerce title={`건설기준 오류건수 (${DATE.getMonth() + 1}월)`} count="78,250" percentage={70.5} extra="8,900" />
</Grid>
<Grid item xs={12} sm={6} md={4} lg={3}>
<AnalyticEcommerce title={`기준코드 등록건수 (${DATE.getMonth() + 1}월)`} count="18,800" percentage={27.4} isLoss color="warning" extra="1,943" />
<AnalyticEcommerce title={`기준코드 등록건수 (${DATE.getMonth() + 1}월)`} count={dashboardCnt.DocuMonthlyCount[0]?.[0]?.toLocaleString() || '0'} percentage={parseFloat(dashboardCnt.DocuMonthlyCount[0]?.[1]) || 0} extra={dashboardCnt.DocuMonthlyCount[0]?.[2]?.toLocaleString() || '0'} isLoss={dashboardCnt.DocuMonthlyCount[0]?.[1] < 0} color={dashboardCnt.DocuMonthlyCount[0]?.[1] < 0 ? "warning" : "primary"} />
</Grid>
<Grid item xs={12} sm={6} md={4} lg={3}>
<AnalyticEcommerce title={`민원건수 (${DATE.getMonth() + 1}월)`} count="5" percentage={80} isLoss color="warning" extra="1" />
<AnalyticEcommerce title={`민원건수 (${DATE.getMonth() + 1}월)`} count="5" percentage={80} extra="1" isLoss color="warning" />
</Grid>
<Grid item md={8} sx={{ display: { sm: 'none', md: 'block', lg: 'none' } }} />

View File

@ -1,10 +1,11 @@
import { useEffect, useState } from 'react';
import {useCallback, useEffect, useState} from 'react';
// material-ui
import { useTheme } from '@mui/material/styles';
// third-party
import ReactApexChart from 'react-apexcharts';
import * as EgovNet from 'api/egovFetch';
// chart options
const areaChartOptions = {
@ -23,7 +24,7 @@ const areaChartOptions = {
enabled: true
},
title: {
text: '2024년 2월',
text: `${new Date().getFullYear()}${new Date().getMonth() + 1}`,
align: 'center'
},
responsive: [{
@ -53,8 +54,35 @@ const ReportAreaChart = () => {
const line = theme.palette.divider;
const [options, setOptions] = useState(areaChartOptions);
const [connectMethod, setConnectMethod] = useState([]);
//
const retrieveList = useCallback(() => {
const retrieveListURL = '/admin/dashboard/connect-method'
const requestOptions = {
method: "POST",
headers: {
'Content-type': 'application/json',
},
// body: JSON.stringify()
}
EgovNet.requestFetch(retrieveListURL,
requestOptions,
(resp) => {
setConnectMethod(resp.result.connectMethod[0]);
},
function (resp) {
console.log("err response : ", resp);
}
);
// eslint-disable-next-lie react-hooks/exhaustive-deps
}, []);
useEffect(() => {
retrieveList();
setOptions((prevState) => ({
...prevState,
labels: ['PC', 'Mobile'],
@ -73,9 +101,13 @@ const ReportAreaChart = () => {
}
}
}));
}, [primary, secondary, line, theme]);
}, [primary, secondary, line, theme, retrieveList]);
const [series] = useState([90, 10]);
const [series, setSeries] = useState([]);
useEffect(() => {
setSeries(connectMethod);
}, [connectMethod]);
return <ReactApexChart options={options} series={series} type="donut" />;
};

View File

@ -117,6 +117,7 @@ import StandardCodeInfo from "../pages/standardCode/info/StandardCodeInfo";
import * as EgovNet from 'api/egovFetch'; // jwt
import initPage from 'js/ui';
import AdminPostMgtList from "../pages/admin/board/AdminPostMgtList";
const RootRoutes = () => {
//useLocation /admin/~ ( 1) */}
@ -291,7 +292,7 @@ const SecondRoutes = () => {
{/* 관리자 - 게시판 현황 */}
<Route path={URL.ADMIN__BOARDS__LIST} element={<AdminBoardsList />} />
<Route path={URL.ADMIN__BOARDS__POSTS} element={<AdminBoardsPosts />} />
<Route path={URL.ADMIN__BOARDS__POSTS} element={<AdminPostMgtList />} />
<Route path={URL.ADMIN__BOARDS__KEYWORDS} element={<AdminBoardsKeywords />} />
{/* 관리자 - 건설기준 관리 */}

View File

@ -130,4 +130,5 @@ public class AdminBoardsController extends BaseController {
resultVO.setResult(resultMap);
return resultVO;
}
}

View File

@ -1,6 +1,8 @@
package com.dbnt.kcscbackend.admin.config;
import com.dbnt.kcscbackend.admin.boards.entity.TnBbs;
import com.dbnt.kcscbackend.admin.config.entity.TcMenu;
import com.dbnt.kcscbackend.admin.config.entity.TnPartnerSite;
import com.dbnt.kcscbackend.admin.config.model.CreateCommitteeCodeManagementVO;
import com.dbnt.kcscbackend.admin.config.service.AdminCommitteeCodeManagementService;
import com.dbnt.kcscbackend.admin.standardResearch.service.AdminStandardResearchService;
@ -456,11 +458,11 @@ public class AdminConfigController extends BaseController {
})
@DeleteMapping(value = "/committee-code-management/{orgId}")
public ResultVO deleteSchedule
(
@AuthenticationPrincipal LoginVO user,
HttpServletRequest request,
@PathVariable("orgId") String strOrgId
) throws Exception {
(
@AuthenticationPrincipal LoginVO user,
HttpServletRequest request,
@PathVariable("orgId") String strOrgId
) throws Exception {
ResultVO resultVO = new ResultVO();
Long orgId = Long.valueOf(strOrgId);
@ -473,15 +475,95 @@ public class AdminConfigController extends BaseController {
System.out.println(
"\n--------------------------------------------------------------\n" +
request.getRequestURI() + " OUT:" +
"\n--------------------------------------------------------------\n" +
"resultVO.toString():" + "\n" +
resultVO.toString() + "\n" +
"\n--------------------------------------------------------------\n"
"\n--------------------------------------------------------------\n" +
request.getRequestURI() + " OUT:" +
"\n--------------------------------------------------------------\n" +
"resultVO.toString():" + "\n" +
resultVO.toString() + "\n" +
"\n--------------------------------------------------------------\n"
);
return resultVO;
}
/* ---- 관련사이트 관리 ----- */
@Operation(
summary = "관련사이트 목록 조회",
description = "관련사이트 목록 조회",
tags = {"AdminConfigController"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "조회 성공"),
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
})
@RequestMapping(method = RequestMethod.GET, value = "/partner-site-list", consumes = MediaType.APPLICATION_JSON_VALUE)
public ResultVO getPartnerSiteList() throws Exception {
ResultVO resultVO = new ResultVO();
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("partnerSiteList", adminConfigService.selectPartnerSiteList());
resultVO.setResult(resultMap);
return resultVO;
}
@Operation(
summary = "관련사이트 저장",
description = "관련사이트 저장",
tags = {"AdminConfigController"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "저장 성공"),
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
})
@RequestMapping(method = RequestMethod.PUT, value = "/partner-site-mgt")
public ResultVO savePartnerSite(@RequestBody @Valid TnPartnerSite tnPartnerSite, Errors errors, @AuthenticationPrincipal LoginVO user) {
ResultVO resultVO = new ResultVO();
if (user == null) {
resultVO.setResultCode(ResponseCode.TOKEN_EXPIRED.getCode());
} else {
if (errors.hasErrors()) {
StringBuilder msg = new StringBuilder();
for (FieldError error : errors.getFieldErrors()) {
msg.append(error.getDefaultMessage());
msg.append("\n");
}
resultVO.setResultCode(ResponseCode.INPUT_CHECK_ERROR.getCode());
resultVO.setResultMessage(msg.toString());
} else {
System.out.println("@@@ bbs.getBbsSeq() : " + tnPartnerSite.getSiteSeq());
adminConfigService.savePartnerSite(tnPartnerSite, user.getId());
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
}
}
return resultVO;
}
@Operation(
summary = "관련사이트 삭제",
description = "관련사이트 삭제",
tags = {"AdminConfigController"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "삭제 성공"),
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
})
@RequestMapping(method = RequestMethod.DELETE, value = "/partner-site-mgt")
public ResultVO removePartnerSite(@RequestBody TnPartnerSite tnPartnerSite, @AuthenticationPrincipal LoginVO user) {
ResultVO resultVO = new ResultVO();
if (user == null) {
resultVO.setResultCode(ResponseCode.TOKEN_EXPIRED.getCode());
} else {
String result = adminConfigService.deletePartnerSite(tnPartnerSite, user.getId());
if (result == null) {
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
} else if (result.equals("notFind")) {
resultVO.setResultCode(ResponseCode.SAVE_ERROR.getCode());
resultVO.setResultMessage("대상이 존재하지 않습니다.");
}
}
return resultVO;
}
}

View File

@ -0,0 +1,38 @@
package com.dbnt.kcscbackend.admin.config.entity;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.*;
@Getter
@Setter
@Entity
@NoArgsConstructor
@DynamicInsert
@DynamicUpdate
@Table(name = "tn_partner_site")
public class TnPartnerSite {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "site_seq")
private Long siteSeq;
@Column(name = "site_title", nullable = false, length = 500)
private String siteTitle;
@Column(name = "site_url", nullable = false, length = 500)
private String siteUrl;
@Column(name = "file_grp_id", length = 255)
private String fileGrpId;
@Column(name = "site_order", nullable = false)
private Long siteOrder;
@Column(name = "use_yn", nullable = false, length = 1)
private String useYn;
}

View File

@ -0,0 +1,13 @@
package com.dbnt.kcscbackend.admin.config.repository;
import com.dbnt.kcscbackend.admin.config.entity.TnPartnerSite;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
public interface TnPartnerSiteRepository extends JpaRepository<TnPartnerSite, Long> {
List<TnPartnerSite> findAllByOrderBySiteOrder();
}

View File

@ -1,10 +1,13 @@
package com.dbnt.kcscbackend.admin.config.service;
import com.dbnt.kcscbackend.admin.boards.entity.TnBbs;
import com.dbnt.kcscbackend.admin.config.entity.TbMenuRole;
import com.dbnt.kcscbackend.admin.config.entity.TcMenu;
import com.dbnt.kcscbackend.admin.config.entity.TnPartnerSite;
import com.dbnt.kcscbackend.admin.config.mapper.TcMenuMapper;
import com.dbnt.kcscbackend.admin.config.repository.TbMenuRoleRepository;
import com.dbnt.kcscbackend.admin.config.repository.TcMenuRepository;
import com.dbnt.kcscbackend.admin.config.repository.TnPartnerSiteRepository;
import com.dbnt.kcscbackend.commonCode.entity.TcCodeGrp;
import com.dbnt.kcscbackend.commonCode.entity.TcCodeItem;
import com.dbnt.kcscbackend.commonCode.repository.TcCodeGrpRepository;
@ -17,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@Service
@RequiredArgsConstructor
@ -27,6 +31,7 @@ public class AdminConfigService extends EgovAbstractServiceImpl {
private final TcMenuRepository menuRepository;
private final TbMenuRoleRepository menuRoleRepository;
private final TcMenuMapper menuMapper;
private final TnPartnerSiteRepository tnPartnerSiteRepository;
public List<TcCodeGrp> selectCodeGrpList(){
return codeGrpRepository.findByUseYn("Y");
@ -165,4 +170,33 @@ public class AdminConfigService extends EgovAbstractServiceImpl {
}
menuRoleRepository.saveAll(roleList);
}
public List<TnPartnerSite> selectPartnerSiteList() {
return tnPartnerSiteRepository.findAllByOrderBySiteOrder();
}
@Transactional
public void savePartnerSite(TnPartnerSite tnPartnerSite, String userId) {
if (tnPartnerSite.getSiteSeq() == null) {
tnPartnerSiteRepository.save(tnPartnerSite);
} else {
TnPartnerSite savedPartnerSite = tnPartnerSiteRepository.findById(tnPartnerSite.getSiteSeq()).orElse(null);
savedPartnerSite.setSiteTitle(tnPartnerSite.getSiteTitle());
savedPartnerSite.setSiteUrl(tnPartnerSite.getSiteUrl());
savedPartnerSite.setFileGrpId(tnPartnerSite.getFileGrpId());
savedPartnerSite.setSiteOrder(tnPartnerSite.getSiteOrder());
savedPartnerSite.setUseYn(tnPartnerSite.getUseYn());
tnPartnerSiteRepository.save(savedPartnerSite);
}
}
@Transactional
public String deletePartnerSite(TnPartnerSite tnPartnerSite, String userId) {
Optional<TnPartnerSite> optionalTnPartnerSite = tnPartnerSiteRepository.findById(tnPartnerSite.getSiteSeq());
optionalTnPartnerSite.ifPresent(partnerSite -> {
tnPartnerSiteRepository.delete(partnerSite);
});
return optionalTnPartnerSite.isPresent() ? null : "notFind";
}
}

View File

@ -27,6 +27,34 @@ public class AdminDashboardController extends BaseController {
private final AdminDashboardService adminDashboardService;
@Operation(
summary = "Dashboard 상단 총접속자수 ~ 민원건수 카운트",
description = "상단 카운트 조회",
tags = {"AdminDashboardController"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "조회 성공"),
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
})
@RequestMapping(method = RequestMethod.POST, value = "/dash-count", consumes = MediaType.APPLICATION_JSON_VALUE)
public ResultVO getDashCount(@AuthenticationPrincipal LoginVO user)
throws Exception {
ResultVO resultVO = new ResultVO();
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("ConnMonthlyCount", adminDashboardService.selectConnMonthly());
resultMap.put("DocuMonthlyCount", adminDashboardService.selectDocuMonthly());
// resultMap.put("loginMonthlyList", adminDashboardService.selectLoginMonthly());
// resultMap.put("loginDailyList", adminDashboardService.selectLoginDaily());
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage());
resultVO.setResult(resultMap);
return resultVO;
}
@Operation(
summary = "해당년도 메뉴/방문자수 월/요일별 조회",
description = "해당년도 메뉴/방문자수 월/요일별 조회",
@ -80,6 +108,29 @@ public class AdminDashboardController extends BaseController {
}
@Operation(
summary = "해당월 접속방법 조회",
description = "해당월 PC/MOBILE 조회",
tags = {"AdminDashboardController"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "조회 성공"),
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
})
@RequestMapping(method = RequestMethod.POST, value = "/connect-method", consumes = MediaType.APPLICATION_JSON_VALUE)
public ResultVO getConnectMethod(@AuthenticationPrincipal LoginVO user)
throws Exception {
ResultVO resultVO = new ResultVO();
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("connectMethod", adminDashboardService.selectConnectMonthly());
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage());
resultVO.setResult(resultMap);
return resultVO;
}

View File

@ -0,0 +1,131 @@
package com.dbnt.kcscbackend.admin.dashboard.repository;
import com.dbnt.kcscbackend.admin.logs.entity.TnDailyMenuLog;
import com.dbnt.kcscbackend.admin.logs.entity.TnDailyUserLog;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
public interface DashboardRepository extends JpaRepository<TnDailyMenuLog, Long> {
@Query(value = "WITH this_month_logs AS ( " +
" SELECT sum(log_cnt) AS this_month_cnt " +
" FROM tn_daily_user_log " +
" WHERE log_dt >= DATE_TRUNC('month', CURRENT_DATE) " +
" AND log_dt < DATE_TRUNC('month', CURRENT_DATE) + INTERVAL '1 month' " +
"), " +
"last_month_logs AS ( " +
" SELECT sum(log_cnt) AS last_month_cnt " +
" FROM tn_daily_user_log " +
" WHERE log_dt >= DATE_TRUNC('month', CURRENT_DATE - INTERVAL '1 month') " +
" AND log_dt < DATE_TRUNC('month', CURRENT_DATE) " +
") " +
"SELECT " +
" this_month_cnt, " +
" ROUND(((CAST(this_month_cnt AS NUMERIC) - last_month_cnt) / last_month_cnt * 100), 1) AS ratio, " +
" last_month_cnt " +
"FROM this_month_logs, last_month_logs", nativeQuery = true)
List<Object[]> ConnMonthlyCount();
@Query(value = "WITH this_month_logs AS ( " +
" SELECT count(*) AS this_month_cnt " +
" FROM tn_document_info " +
" WHERE last_yn = 'Y' AND use_yn = 'Y' " +
" AND frst_crt_dt >= DATE_TRUNC('month', CURRENT_DATE) " +
" AND frst_crt_dt < DATE_TRUNC('month', CURRENT_DATE) + INTERVAL '1 month' " +
"), " +
"last_month_logs AS ( " +
" SELECT count(*) AS last_month_cnt " +
" FROM tn_document_info " +
" WHERE last_yn = 'Y' AND use_yn = 'Y' " +
" AND frst_crt_dt >= DATE_TRUNC('month', CURRENT_DATE - INTERVAL '1 month') " +
" AND frst_crt_dt < DATE_TRUNC('month', CURRENT_DATE) " +
") " +
"SELECT " +
" this_month_cnt, " +
" ROUND(((CAST(this_month_cnt AS NUMERIC) - last_month_cnt) / last_month_cnt * 100), 1) AS ratio, " +
" last_month_cnt " +
"FROM this_month_logs, last_month_logs", nativeQuery = true)
List<Object[]> DocuMonthlyCount();
@Query(value = "WITH all_months AS (" +
" SELECT generate_series(DATE_TRUNC('year', CURRENT_DATE), DATE_TRUNC('year', CURRENT_DATE) + INTERVAL '11 month', INTERVAL '1 month') AS month_start" +
")" +
"SELECT COALESCE(SUM(tn.log_cnt), 0) AS log_cnt " +
"FROM all_months " +
"LEFT JOIN tn_daily_menu_log tn ON TO_CHAR(all_months.month_start, 'yyyy-mm') = TO_CHAR(tn.log_dt, 'yyyy-mm') " +
"GROUP BY TO_CHAR(all_months.month_start, 'yyyy-mm') " +
"ORDER BY TO_CHAR(all_months.month_start, 'yyyy-mm') ASC", nativeQuery = true)
List<Long> MenuMonthlyList();
@Query(value = "WITH all_days AS (" +
" SELECT generate_series(" +
" DATE_TRUNC('year', now())," +
" DATE_TRUNC('year', now()) + INTERVAL '1 year' - INTERVAL '1 day'," +
" INTERVAL '1 day'" +
" ) AS day" +
")" +
"SELECT COALESCE(SUM(tn.log_cnt), 0) AS log_cnt " +
"FROM all_days ad " +
"LEFT JOIN tn_daily_menu_log tn ON ad.day = DATE_TRUNC('day', tn.log_dt) " +
"GROUP BY TO_CHAR(ad.day, 'Day') " +
"ORDER BY MIN(ad.day)", nativeQuery = true)
List<Long> MenuDailyList();
@Query(value = "WITH all_months AS (" +
" SELECT generate_series(" +
" DATE_TRUNC('year', now())," +
" DATE_TRUNC('year', now()) + INTERVAL '11 month'," +
" INTERVAL '1 month'" +
" ) AS month_start" +
")" +
"SELECT COALESCE(SUM(tn.log_cnt), 0) AS log_cnt " +
"FROM all_months " +
"LEFT JOIN tn_daily_user_log tn ON TO_CHAR(all_months.month_start, 'yyyy-mm') = TO_CHAR(tn.log_dt, 'yyyy-mm') " +
"GROUP BY TO_CHAR(all_months.month_start, 'yyyy-mm') " +
"ORDER BY TO_CHAR(all_months.month_start, 'yyyy-mm') ASC", nativeQuery = true)
List<Long> LoginMonthlyList();
@Query(value = "WITH all_days AS (" +
" SELECT generate_series(" +
" DATE_TRUNC('year', CURRENT_DATE)," +
" DATE_TRUNC('year', CURRENT_DATE) + INTERVAL '1 year' - INTERVAL '1 day'," +
" INTERVAL '1 day'" +
" ) AS day" +
")" +
"SELECT COALESCE(SUM(tn.log_cnt), 0) AS log_cnt " +
"FROM all_days ad " +
"LEFT JOIN tn_daily_user_log tn ON ad.day = tn.log_dt " +
"GROUP BY TO_CHAR(ad.day, 'Day') " +
"ORDER BY MIN(ad.day)", nativeQuery = true)
List<Long> LoginDailyList();
@Query(value = "WITH all_days AS (" +
" SELECT generate_series(" +
" DATE_TRUNC('year', CURRENT_DATE)," +
" DATE_TRUNC('year', CURRENT_DATE) + INTERVAL '1 year' - INTERVAL '1 day'," +
" INTERVAL '1 day'" +
" ) AS day" +
")" +
"SELECT COALESCE(COUNT(tn.access_dt), 0) AS log_cnt " +
"FROM all_days ad " +
"LEFT JOIN (SELECT access_dt FROM public.th_attach_file_log WHERE\n" +
" access_dt >= CURRENT_DATE - INTERVAL '6 day') tn ON ad.day = DATE_TRUNC('day', tn.access_dt) " +
"GROUP BY TO_CHAR(ad.day, 'Day') " +
"ORDER BY MIN(ad.day)", nativeQuery = true)
List<Long> FileDailyList();
@Query(value = "SELECT sum(pc_cnt) AS p_cnt, sum(mobile_cnt) AS m_cnt " +
"FROM tn_daily_user_log " +
"WHERE log_dt >= DATE_TRUNC('month', CURRENT_DATE) " +
"AND log_dt < DATE_TRUNC('month', CURRENT_DATE) + INTERVAL '1 month'", nativeQuery = true)
List<Object[]> findConnMonthly();
}

View File

@ -1,83 +0,0 @@
package com.dbnt.kcscbackend.admin.dashboard.repository;
import com.dbnt.kcscbackend.admin.logs.entity.TnDailyMenuLog;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
public interface MenuMonthlyRepository extends JpaRepository<TnDailyMenuLog, Long> {
@Query(value = "WITH all_months AS (" +
" SELECT generate_series(DATE_TRUNC('year', CURRENT_DATE), DATE_TRUNC('year', CURRENT_DATE) + INTERVAL '11 month', INTERVAL '1 month') AS month_start" +
")" +
"SELECT COALESCE(SUM(tn.log_cnt), 0) AS log_cnt " +
"FROM all_months " +
"LEFT JOIN tn_daily_menu_log tn ON TO_CHAR(all_months.month_start, 'yyyy-mm') = TO_CHAR(tn.log_dt, 'yyyy-mm') " +
"GROUP BY TO_CHAR(all_months.month_start, 'yyyy-mm') " +
"ORDER BY TO_CHAR(all_months.month_start, 'yyyy-mm') ASC", nativeQuery = true)
List<Long> MenuMonthlyList();
@Query(value = "WITH all_days AS (" +
" SELECT generate_series(" +
" DATE_TRUNC('year', now())," +
" DATE_TRUNC('year', now()) + INTERVAL '1 year' - INTERVAL '1 day'," +
" INTERVAL '1 day'" +
" ) AS day" +
")" +
"SELECT COALESCE(SUM(tn.log_cnt), 0) AS log_cnt " +
"FROM all_days ad " +
"LEFT JOIN tn_daily_menu_log tn ON ad.day = DATE_TRUNC('day', tn.log_dt) " +
"GROUP BY TO_CHAR(ad.day, 'Day') " +
"ORDER BY MIN(ad.day)", nativeQuery = true)
List<Long> MenuDailyList();
@Query(value = "WITH all_months AS (" +
" SELECT generate_series(" +
" DATE_TRUNC('year', now())," +
" DATE_TRUNC('year', now()) + INTERVAL '11 month'," +
" INTERVAL '1 month'" +
" ) AS month_start" +
")" +
"SELECT COALESCE(SUM(tn.log_cnt), 0) AS log_cnt " +
"FROM all_months " +
"LEFT JOIN tn_daily_user_log tn ON TO_CHAR(all_months.month_start, 'yyyy-mm') = TO_CHAR(tn.log_dt, 'yyyy-mm') " +
"GROUP BY TO_CHAR(all_months.month_start, 'yyyy-mm') " +
"ORDER BY TO_CHAR(all_months.month_start, 'yyyy-mm') ASC", nativeQuery = true)
List<Long> LoginMonthlyList();
@Query(value = "WITH all_days AS (" +
" SELECT generate_series(" +
" DATE_TRUNC('year', CURRENT_DATE)," +
" DATE_TRUNC('year', CURRENT_DATE) + INTERVAL '1 year' - INTERVAL '1 day'," +
" INTERVAL '1 day'" +
" ) AS day" +
")" +
"SELECT COALESCE(SUM(tn.log_cnt), 0) AS log_cnt " +
"FROM all_days ad " +
"LEFT JOIN tn_daily_user_log tn ON ad.day = tn.log_dt " +
"GROUP BY TO_CHAR(ad.day, 'Day') " +
"ORDER BY MIN(ad.day)", nativeQuery = true)
List<Long> LoginDailyList();
@Query(value = "WITH all_days AS (" +
" SELECT generate_series(" +
" DATE_TRUNC('year', CURRENT_DATE)," +
" DATE_TRUNC('year', CURRENT_DATE) + INTERVAL '1 year' - INTERVAL '1 day'," +
" INTERVAL '1 day'" +
" ) AS day" +
")" +
"SELECT COALESCE(COUNT(tn.access_dt), 0) AS log_cnt " +
"FROM all_days ad " +
"LEFT JOIN (SELECT access_dt FROM public.th_attach_file_log WHERE\n" +
" access_dt >= CURRENT_DATE - INTERVAL '6 day') tn ON ad.day = DATE_TRUNC('day', tn.access_dt) " +
"GROUP BY TO_CHAR(ad.day, 'Day') " +
"ORDER BY MIN(ad.day)", nativeQuery = true)
List<Long> FileDailyList();
}

View File

@ -1,8 +1,9 @@
package com.dbnt.kcscbackend.admin.dashboard.service;
//import com.dbnt.kcscbackend.admin.dashboard.entity.TnDailyUserLog;
import com.dbnt.kcscbackend.admin.dashboard.repository.MenuMonthlyRepository;
//import com.dbnt.kcscbackend.admin.logs.entity.TnDailyUserLog;
//import com.dbnt.kcscbackend.admin.dashboard.repository.TnDailyUserLogRepository;
import com.dbnt.kcscbackend.admin.dashboard.repository.DashboardRepository;
import com.dbnt.kcscbackend.admin.logs.entity.TnDailyUserLog;
import lombok.RequiredArgsConstructor;
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
import org.springframework.stereotype.Service;
@ -14,19 +15,23 @@ import java.util.List;
@RequiredArgsConstructor
public class AdminDashboardService extends EgovAbstractServiceImpl {
// private final TnDailyUserLogRepository tnDailyUserLogRepository;
private final MenuMonthlyRepository menuMonthlyRepository;
private final DashboardRepository dashboardRepository;
public List<Long> selectMenuMonthly() { return menuMonthlyRepository.MenuMonthlyList(); }
public List<Object[]> selectConnMonthly() { return dashboardRepository.ConnMonthlyCount(); }
public List<Long> selectMenuDaily() { return menuMonthlyRepository.MenuDailyList(); }
public List<Object[]> selectDocuMonthly() { return dashboardRepository.DocuMonthlyCount(); }
public List<Long> selectLoginMonthly() { return menuMonthlyRepository.LoginMonthlyList(); }
public List<Long> selectMenuMonthly() { return dashboardRepository.MenuMonthlyList(); }
public List<Long> selectLoginDaily() { return menuMonthlyRepository.LoginDailyList(); }
public List<Long> selectMenuDaily() { return dashboardRepository.MenuDailyList(); }
public List<Long> selectFileDaily() { return menuMonthlyRepository.FileDailyList(); }
public List<Long> selectLoginMonthly() { return dashboardRepository.LoginMonthlyList(); }
public List<Long> selectLoginDaily() { return dashboardRepository.LoginDailyList(); }
public List<Long> selectFileDaily() { return dashboardRepository.FileDailyList(); }
public List<Object[]> selectConnectMonthly() { return dashboardRepository.findConnMonthly(); }
// public List<TnDailyUserLog> selectDailyUserLogList(LocalDate startDate, LocalDate endDate) {
// return tnDailyUserLogRepository.findByLogDtBetweenOrderByLogDt(startDate, endDate);

View File

@ -63,7 +63,7 @@ public class CustomUrlAuthenticationSuccessHandler extends SimpleUrlAuthenticati
MediaType jsonMimeType = MediaType.APPLICATION_JSON;
HashMap<String, Object> resultMap = new HashMap<>();
/*if(securityUser.getUserId().equals("admin") && !adminIpList.contains(accessIp)){
if(securityUser.getUserId().equals("admin") && !adminIpList.contains(accessIp)){
resultMap.put("resultCode", ResponseCode.FAILED.getCode());
resultMap.put("resultMessage", "관리자 계정은 지정된 아이피에서만 접속할 수 있습니다.\n필요한 경우 관리자에게 요청하십시오.\n접속자 아이피: "+ClientUtils.getRemoteIP(request));
}else{
@ -72,10 +72,7 @@ public class CustomUrlAuthenticationSuccessHandler extends SimpleUrlAuthenticati
resultMap.put("resultCode", ResponseCode.SUCCESS.getCode());
resultMap.put("accessToken", accessToken);
resultMap.put("refreshToken", refreshToken);
// response.addHeader("Authorization", "BEARER "+accessToken);
// Cookie refreshTokenCookie = new Cookie("refreshToken", refreshToken);
// response.addCookie(refreshTokenCookie);
}*/
}
String accessToken = jwtTokenUtil.generateAccessToken(securityUser, request.getRemoteAddr());
String refreshToken = jwtTokenUtil.generateRefreshTokenToken(securityUser, request.getRemoteAddr());

View File

@ -1,6 +1,9 @@
package com.dbnt.kcscbackend.config.util;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
public class ClientUtils {
public static String getRemoteIP(HttpServletRequest request){
@ -45,4 +48,59 @@ public class ClientUtils {
}
return webType;
}
private static String getBrowser(HttpServletRequest request) {
String header = request.getHeader("User-Agent");
if (header.indexOf("MSIE") > -1) {
return "MSIE";
} else if (header.indexOf("Trident") > -1) { // IE11 문자열 깨짐 방지
return "Trident";
} else if (header.indexOf("Chrome") > -1) {
return "Chrome";
} else if (header.indexOf("Opera") > -1) {
return "Opera";
}
return "Firefox";
}
public static void setDisposition(String filename, HttpServletRequest request, HttpServletResponse response) throws IOException {
String browser = getBrowser(request);
String dispositionPrefix = "attachment; filename=";
String encodedFilename = null;
if (browser.equals("MSIE")) {
encodedFilename = URLEncoder.encode(filename, "UTF-8").replaceAll("\\+", "%20");
} else if (browser.equals("Trident")) { // IE11 문자열 깨짐 방지
encodedFilename = URLEncoder.encode(filename, "UTF-8").replaceAll("\\+", "%20");
} else if (browser.equals("Firefox")) {
encodedFilename = "\"" + new String(filename.getBytes("UTF-8"), "8859_1") + "\"";
} else if (browser.equals("Opera")) {
encodedFilename = "\"" + new String(filename.getBytes("UTF-8"), "8859_1") + "\"";
} else if (browser.equals("Chrome")) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < filename.length(); i++) {
char c = filename.charAt(i);
if(c==','){
sb.append(URLEncoder.encode("", "UTF-8"));
} else if (c > '~') {
sb.append(URLEncoder.encode("" + c, "UTF-8"));
} else {
sb.append(c);
}
}
encodedFilename = sb.toString();
} else {
throw new IOException("Not supported browser");
}
response.setHeader("Content-Disposition", dispositionPrefix + encodedFilename);
if ("Opera".equals(browser)) {
response.setContentType("application/octet-stream;charset=UTF-8");
}
if(filename.contains("zip")){
response.setContentType("application/zip");
}
}
}

View File

@ -0,0 +1,46 @@
package com.dbnt.kcscbackend.file;
import com.dbnt.kcscbackend.config.util.ClientUtils;
import com.dbnt.kcscbackend.file.entity.TnAttachFile;
import com.dbnt.kcscbackend.file.service.FileService;
import lombok.RequiredArgsConstructor;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
@RestController
@RequiredArgsConstructor
@RequestMapping("/file")
public class FileController {
private final FileService fileService;
@RequestMapping(method = RequestMethod.GET, value = "/download")
public void download(HttpServletRequest request, HttpServletResponse response, TnAttachFile tnAttachFile) throws Exception{
tnAttachFile = fileService.selectTnAttachFile(tnAttachFile);
if(tnAttachFile != null){
BufferedInputStream in;
BufferedOutputStream out;
try {
File file = new File(tnAttachFile.getFilePath());
ClientUtils.setDisposition(tnAttachFile.getFileOldName(), request, response);
in = new BufferedInputStream(new FileInputStream(file));
out = new BufferedOutputStream(response.getOutputStream());
FileCopyUtils.copy(in, out);
out.flush();
if(out!=null) out.close();
if(in!=null )in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

View File

@ -0,0 +1,57 @@
package com.dbnt.kcscbackend.file.entity;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.*;
import java.time.LocalDateTime;
@Getter
@Setter
@Entity
@NoArgsConstructor
@DynamicInsert
@DynamicUpdate
@Table(name = "tn_attach_file")
public class TnAttachFile {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "file_seq")
private Integer fileSeq;
@Column(name = "file_grp_id")
private String fileGrpId;
@Column(name = "file_order")
private Integer fileOrder;
@Column(name = "file_old_name")
private String fileOldName;
@Column(name = "file_new_name")
private String fileNewName;
@Column(name = "file_path")
private String filePath;
@Column(name = "file_size")
private Integer fileSize;
@Column(name = "file_ext")
private String fileExt;
@Column(name = "down_cnt")
private Integer downCnt;
@Column(name = "frst_crt_id")
private String frstCrtId;
@Column(name = "frst_crt_dt")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime frstCrtDt;
@Column(name = "last_chg_id")
private String lastChgId;
@Column(name = "last_chg_dt")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime lastChgDt;
@Column(name = "use_yn")
private String useYn;
@Column(name = "old_seq")
private Integer oldSeq;
}

View File

@ -0,0 +1,11 @@
package com.dbnt.kcscbackend.file.repository;
import com.dbnt.kcscbackend.file.entity.TnAttachFile;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.Optional;
public interface TnAttachFileRepository extends JpaRepository<TnAttachFile, Integer> {
Optional<TnAttachFile> findByFileGrpId(String fileGrpId);
}

View File

@ -0,0 +1,23 @@
package com.dbnt.kcscbackend.file.service;
import com.dbnt.kcscbackend.file.entity.TnAttachFile;
import com.dbnt.kcscbackend.file.repository.TnAttachFileRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class FileService {
private final TnAttachFileRepository tnAttachFileRepository;
public TnAttachFile selectTnAttachFile(TnAttachFile tnAttachFile) {
if(tnAttachFile.getFileSeq()!=null){
return tnAttachFileRepository.findById(tnAttachFile.getFileSeq()).orElse(null);
}else{
return tnAttachFileRepository.findByFileGrpId(tnAttachFile.getFileGrpId()).orElse(null);
}
}
}