Merge branch 'master' of http://118.219.150.34:50501/DBNT/kcscDev
commit
5d380ab794
|
|
@ -4,7 +4,7 @@ import 'react-quill/dist/quill.snow.css';
|
|||
|
||||
// react-quill에 기반을 둔 텍스트 에디터 컴포넌트
|
||||
const RichTextEditor = ({item, setText}) => {
|
||||
const style = { height: "400px"};
|
||||
const style = { height: "400px", paddingBottom: "69px"};
|
||||
|
||||
const onChangeEvent = (e) => {
|
||||
setText(e);
|
||||
|
|
|
|||
|
|
@ -98,12 +98,14 @@ const URL = {
|
|||
ADMIN__STANDARDS__INFO_DISCLOSURE : "/admin/standards/info-disclosure", // 건설기준 관리/정보공개 관리
|
||||
|
||||
// 관리자 - 컨텐츠 관리
|
||||
ADMIN__CONTENTS__SURVEY : "/admin/contents/survey", // 컨텐츠 관리/설문 관리
|
||||
ADMIN__CONTENTS__POP_UP : "/admin/contents/pop-up", // 컨텐츠 관리/팝업 관리
|
||||
ADMIN__CONTENTS__POP_UP__CREATE : "/admin/contents/pop-up/create", // 관리자 - 컨텐츠 관리/팝업 관리/팝업 추가
|
||||
ADMIN__CONTENTS__POP_UP__MODIFY : "/admin/contents/pop-up/modify", // 관리자 - 컨텐츠 관리/팝업 관리/팝업 수정
|
||||
ADMIN__CONTENTS__STANDARDS_RESEARCH : "/admin/contents/standards-research", // 컨텐츠 관리/건설기준연구 관리
|
||||
ADMIN__CONTENTS__TEXT_MESSAGES : "/admin/contents/text-messages", // 컨텐츠 관리/문자 발송
|
||||
ADMIN__CONTENTS__SURVEY : "/admin/contents/survey", // 컨텐츠 관리/설문 관리
|
||||
ADMIN__CONTENTS__POP_UP : "/admin/contents/pop-up", // 컨텐츠 관리/팝업 관리
|
||||
ADMIN__CONTENTS__POP_UP__CREATE : "/admin/contents/pop-up/create", // 관리자 - 컨텐츠 관리/팝업 관리/팝업 추가
|
||||
ADMIN__CONTENTS__POP_UP__MODIFY : "/admin/contents/pop-up/modify", // 관리자 - 컨텐츠 관리/팝업 관리/팝업 수정
|
||||
ADMIN__CONTENTS__STANDARDS_RESEARCH : "/admin/contents/standards-research", // 컨텐츠 관리/건설기준연구 관리
|
||||
ADMIN__CONTENTS__STANDARDS_RESEARCH__CREATE : "/admin/contents/standards-research/create", // 컨텐츠 관리/건설기준연구 관리/추가
|
||||
ADMIN__CONTENTS__STANDARDS_RESEARCH__MODIFY : "/admin/contents/standards-research/modify", // 컨텐츠 관리/건설기준연구 관리/수정
|
||||
ADMIN__CONTENTS__TEXT_MESSAGES : "/admin/contents/text-messages", // 컨텐츠 관리/문자 발송
|
||||
|
||||
// 관리자 - 위원회 관리
|
||||
ADMIN__COMMITTEE__PROGRESS_STATUS : "/admin/committee/progress-status", // 위원회 관리/진행현황 관리
|
||||
|
|
|
|||
|
|
@ -21,14 +21,10 @@ const StyledDiv = styled.div`
|
|||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.board_btn_area {
|
||||
|
||||
margin-top: 70px;
|
||||
}
|
||||
|
||||
`;
|
||||
|
||||
function PopupWriter(props) {
|
||||
function PopupEditor(props) {
|
||||
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
|
|
@ -373,4 +369,4 @@ function PopupWriter(props) {
|
|||
}
|
||||
|
||||
|
||||
export default PopupWriter;
|
||||
export default PopupEditor;
|
||||
|
|
@ -1,13 +1,85 @@
|
|||
import React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Link, useLocation, useNavigate } from 'react-router-dom';
|
||||
import Switch from '@mui/material/Switch';
|
||||
|
||||
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 EgovPagingPaginationInfo from 'components/EgovPagingPaginationInfo';
|
||||
|
||||
|
||||
import styled from "styled-components";
|
||||
|
||||
const StyledDiv = styled.div`
|
||||
.board_btn_area {
|
||||
margin: 12px 0px;
|
||||
}
|
||||
`;
|
||||
|
||||
const label = { inputProps: { 'aria-label': '사용여부' } };
|
||||
|
||||
function StandardResearch(props) {
|
||||
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [list, setList] = useState([]);
|
||||
const [searchCondition, setSearchCondition] = useState(location.state?.searchCondition || { pageIndex: 1, searchCnd: '0', searchWrd: '' });
|
||||
const [paginationInfo, setPaginationInfo] = useState({});
|
||||
|
||||
useEffect(function () {
|
||||
getList(searchCondition);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
const requestOptions = {
|
||||
method: "GET",
|
||||
headers: {
|
||||
'Content-type': 'application/json'
|
||||
}
|
||||
}
|
||||
|
||||
const getList = (searchCondition) => {
|
||||
|
||||
EgovNet.requestFetch(`/contents/standard-research/list?page=${searchCondition.pageIndex-1}&size=10&sort=rsSeq,desc`,
|
||||
requestOptions,
|
||||
function (resp) {
|
||||
console.log('%o', resp);
|
||||
setList(resp.result.list);
|
||||
setPaginationInfo({...resp.result.paginationInfo});
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
const onChangeActivationSwitch = (e, rsId) => {
|
||||
const checked = e.target.checked;
|
||||
const requestURL = `/contents/api/popup-manage/activation-switch/${rsId}?checked=${checked}`;
|
||||
|
||||
const requestOptions = {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
'Content-type': 'application/json',
|
||||
}
|
||||
}
|
||||
|
||||
EgovNet.requestFetch(requestURL,
|
||||
requestOptions,
|
||||
(resp) => {
|
||||
console.log("====>>> Schdule delete= ", resp);
|
||||
if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) {
|
||||
navigate(URL.ADMIN__CONTENTS__POP_UP ,{ replace: true });
|
||||
} else {
|
||||
navigate({pathname: URL.ERROR}, {state: {msg : resp.resultMessage}});
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const Location = React.memo(function Location() {
|
||||
return (
|
||||
<div className="location">
|
||||
|
|
@ -35,11 +107,51 @@ function StandardResearch(props) {
|
|||
|
||||
<div className="contents " id="contents">
|
||||
{/* <!-- 본문 --> */}
|
||||
<div className="top_tit">
|
||||
<h1 className="tit_1">건설기준연구 관리</h1>
|
||||
</div>
|
||||
<StyledDiv>
|
||||
<div className="top_tit">
|
||||
<h1 className="tit_1">건설기준연구 관리</h1>
|
||||
</div>
|
||||
{/* <!-- 버튼영역 --> */}
|
||||
<div className="board_btn_area">
|
||||
<div className="right_col btn1">
|
||||
<Link to={URL.ADMIN__CONTENTS__STANDARDS_RESEARCH__CREATE} className="btn btn_blue_h46 w_100">글 작성</Link>
|
||||
</div>
|
||||
</div>
|
||||
{/* <!--// 버튼영역 --> */}
|
||||
|
||||
{/* <!-- 게시판목록 --> */}
|
||||
<div className="board_list BRD008">
|
||||
<div className="head">
|
||||
<span>번호</span>
|
||||
<span>연구명</span>
|
||||
<span>연구기간</span>
|
||||
<span>연구책임자</span>
|
||||
</div>
|
||||
<div className="result">
|
||||
{/* <!-- case : 데이터 없을때 --> */}
|
||||
{list.length === 0 &&
|
||||
<p className="no_data" key="0">검색된 결과가 없습니다.</p>
|
||||
}
|
||||
{list.map((it)=>(
|
||||
<div className='list_item' key={it.id}>
|
||||
<div>{it.id}</div>
|
||||
<div className="al"><Link to={URL.ADMIN__CONTENTS__STANDARDS_RESEARCH__MODIFY} state={{rsId: it.id} } key={it.id}>{it.title}</Link></div>
|
||||
<div>{it.researchStartDate} ~ {it.researchEndDate}</div>
|
||||
<div>{it.director}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
{/* <!--// 게시판목록 --> */}
|
||||
|
||||
여기에 구현해주세요.
|
||||
<div className="board_bot">
|
||||
{/* <!-- Paging --> */}
|
||||
<EgovPagingPaginationInfo pagination={paginationInfo} setPaginationInfo={setPaginationInfo} moveToPage={passedPage => {
|
||||
getList({ ...searchCondition, pageIndex: passedPage })
|
||||
}} />
|
||||
{/* <!--/ Paging --> */}
|
||||
</div>
|
||||
</StyledDiv>
|
||||
{/* <!--// 본문 --> */}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,412 @@
|
|||
import React, { useState, useEffect } from 'react';
|
||||
import { Link, useLocation, useNavigate } from 'react-router-dom';
|
||||
import DatePicker from "react-datepicker";
|
||||
|
||||
import EgovAttachFile from 'components/EgovAttachFile';
|
||||
import RichTextEditor from "../../../../components/editor/RichTextEditor";
|
||||
import AlertDialogSlide from "../../../../components/alert/AlertDialogSlide";
|
||||
import CODE from 'constants/code';
|
||||
|
||||
|
||||
import * as EgovNet from 'api/egovFetch';
|
||||
import URL from 'constants/url';
|
||||
|
||||
import { default as EgovLeftNav } from 'components/leftmenu/EgovLeftNavAdmin';
|
||||
|
||||
import styled from "styled-components";
|
||||
|
||||
const StyledDiv = styled.div`
|
||||
|
||||
.board_view2 {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.label-text-editor {
|
||||
font-size: 19px;
|
||||
font-weight: 600;
|
||||
color: #212529;
|
||||
margin-bottom: 10px;
|
||||
.req {
|
||||
display: inline-block;
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
margin-left: 2px;
|
||||
font-size: 0;
|
||||
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTM4IDc5LjE1OTgyNCwgMjAxNi8wOS8xNC0wMTowOTowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTcgKFdpbmRvd3MpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjdCNDNBMURDRjVFRDExRUJBMkM3OUEyMERCMzg3NTBGIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjdCNDNBMURERjVFRDExRUJBMkM3OUEyMERCMzg3NTBGIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6N0I0M0ExREFGNUVEMTFFQkEyQzc5QTIwREIzODc1MEYiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6N0I0M0ExREJGNUVEMTFFQkEyQzc5QTIwREIzODc1MEYiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz5vOlo3AAAAbElEQVR42mL4//8/Awy/zij/D8ShMD7Tm8wKQQYsACTOCFS5Csh2AeKzUPoeVP49E5BIB+JOIFaCCoJMWg3Erkwi0zveAxmzoIL3oPRZkDgTVHUHVMIEqrAcJMgClQQZywA1JR3omFAQHyDAAEctLdb1Cc0kAAAAAElFTkSuQmCC) no-repeat;
|
||||
vertical-align: 17px;
|
||||
}
|
||||
}
|
||||
|
||||
`;
|
||||
|
||||
function StandardResearchEditor(props) {
|
||||
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
|
||||
const [modeInfo, setModeInfo] = useState({ mode: props.mode });
|
||||
const [purpose, setPurpose] = useState("");
|
||||
const [purposeOriginal, setPurposeOriginal] = useState("");
|
||||
const [content, setContent] = useState("");
|
||||
const [contentOriginal, setContentOriginal] = useState("");
|
||||
const [effectContent, setEffectContent] = useState("");
|
||||
const [effectContentOriginal, setEffectContentOriginal] = useState("");
|
||||
|
||||
|
||||
|
||||
const [standardResearchDetail, setStandardResearchDetail] = useState({ researchStartDate: new Date(), researchEndDate: new Date() });
|
||||
const [confirm, setConfirm] = React.useState();
|
||||
|
||||
|
||||
|
||||
useEffect(function () {
|
||||
initMode();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
const formValidator = (formData) => {
|
||||
if (formData.get('title') === null || formData.get('title') === "") {
|
||||
alert("연구명은 필수 값입니다.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (formData.get('schdulBgnde') > formData.get('schdulEndde')) {
|
||||
alert("종료일시는 시작일시보다 앞 설 수 없습니다.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (formData.get('director') === null || formData.get('director') === "") {
|
||||
alert("연구책임자는 필수 값입니다.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (formData.get('purpose') === null || formData.get('purpose') === "") {
|
||||
alert("연구목적은 필수 값입니다.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (formData.get('content') === null || formData.get('content') === "") {
|
||||
alert("연구내용은 필수 값입니다.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (formData.get('effectContent') === null || formData.get('effectContent') === "") {
|
||||
alert("기대효과는 필수 값입니다.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const initMode = () => {
|
||||
|
||||
// props.mode 값이 없으면 에러가 발생한다.
|
||||
switch (props.mode) {
|
||||
case CODE.MODE_CREATE:
|
||||
setModeInfo({
|
||||
...modeInfo,
|
||||
modeTitle: "등록",
|
||||
method : "POST",
|
||||
editURL: '/contents/standard-research'
|
||||
});
|
||||
break;
|
||||
case CODE.MODE_MODIFY:
|
||||
setModeInfo({
|
||||
...modeInfo,
|
||||
modeTitle: "수정",
|
||||
method : "PUT",
|
||||
editURL: '/contents/standard-research'
|
||||
});
|
||||
break;
|
||||
default:
|
||||
navigate({pathname: URL.ERROR}, {state: {msg : ""}});
|
||||
}
|
||||
retrieveDetail();
|
||||
}
|
||||
|
||||
const retrieveDetail = () => {
|
||||
|
||||
if (modeInfo.mode === CODE.MODE_CREATE) {// 조회/등록이면 조회 안함
|
||||
return;
|
||||
}
|
||||
|
||||
const retrieveDetailURL = `/contents/standard-research/${location.state?.rsId}`;
|
||||
const requestOptions = {
|
||||
method: "GET",
|
||||
headers: {
|
||||
'Content-type': 'application/json'
|
||||
}
|
||||
}
|
||||
EgovNet.requestFetch(retrieveDetailURL,
|
||||
requestOptions,
|
||||
function (resp) {
|
||||
let rawDetail = resp.result;
|
||||
//기본값 설정
|
||||
setStandardResearchDetail({
|
||||
...standardResearchDetail,
|
||||
...rawDetail,
|
||||
researchStartDate: convertDate(rawDetail.researchStartDate),
|
||||
researchEndDate: convertDate(rawDetail.researchEndDate),
|
||||
});
|
||||
setPurpose(rawDetail.purpose);
|
||||
setPurposeOriginal(rawDetail.purpose);
|
||||
setContent(rawDetail.content);
|
||||
setContentOriginal(rawDetail.content);
|
||||
setEffectContent(rawDetail.effectContent);
|
||||
setEffectContentOriginal(rawDetail.effectContent);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const createItem = () => {
|
||||
const formData = new FormData();
|
||||
|
||||
for (let key in standardResearchDetail) {
|
||||
if ( key === 'researchStartDate' ) {
|
||||
formData.append(key, getDateFourteenDigit( standardResearchDetail[key] ));
|
||||
} else if( key === 'researchEndDate' ) {
|
||||
formData.append(key, getDateFourteenDigit( standardResearchDetail[key] ));
|
||||
} else {
|
||||
formData.append(key, standardResearchDetail[key]);
|
||||
}
|
||||
}
|
||||
|
||||
//연구 목적
|
||||
formData.delete("purpose");
|
||||
formData.append("purpose", purpose);
|
||||
|
||||
//연구 내용
|
||||
formData.delete("content");
|
||||
formData.append("content", content);
|
||||
|
||||
//기대 효과
|
||||
formData.delete("effectContent");
|
||||
formData.append("effectContent", effectContent);
|
||||
|
||||
|
||||
if (formValidator(formData)) {
|
||||
const requestOptions = {
|
||||
method: modeInfo.method,
|
||||
body: formData
|
||||
}
|
||||
|
||||
const requestTask = (callbackParams) => {
|
||||
EgovNet.requestFetch(callbackParams.requestUrl,
|
||||
requestOptions,
|
||||
(resp) => {
|
||||
if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) {
|
||||
if (modeInfo.mode === CODE.MODE_MODIFY) {
|
||||
alert("게시글이 수정 되었습니다.");
|
||||
}
|
||||
navigate({ pathname: URL.ADMIN__CONTENTS__STANDARDS_RESEARCH });
|
||||
} else {
|
||||
navigate({pathname: URL.ERROR}, {state: {msg : resp.resultMessage}});
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
if (modeInfo.mode === CODE.MODE_CREATE) {
|
||||
setConfirm({...confirm, open: true, body: "추가하시겠습니까?", yesCallback: requestTask, yesCallbackParams: {requestUrl:modeInfo.editURL}});
|
||||
} else if (modeInfo.mode === CODE.MODE_MODIFY) {
|
||||
setConfirm({...confirm, open: true, body: "수정하시겠습니까?", yesCallback: requestTask, yesCallbackParams: {requestUrl:`${modeInfo.editURL}/${location.state?.rsId}`}});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const onClickDelete = (rsId) => {
|
||||
const deleteBoardURL = `/contents/standard-research/${rsId}`;
|
||||
|
||||
const requestOptions = {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
'Content-type': 'application/json',
|
||||
}
|
||||
}
|
||||
|
||||
const requestTask = () => {
|
||||
EgovNet.requestFetch(deleteBoardURL,
|
||||
requestOptions,
|
||||
(resp) => {
|
||||
if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) {
|
||||
alert("삭제 되었습니다.");
|
||||
navigate(URL.ADMIN__CONTENTS__STANDARDS_RESEARCH ,{ replace: true });
|
||||
} else {
|
||||
navigate({pathname: URL.ERROR}, {state: {msg : resp.resultMessage}});
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
setConfirm({...confirm, open: true, body: "삭제하시겠습니까?", yesCallback: requestTask});
|
||||
}
|
||||
|
||||
const onClickList = (e) => {
|
||||
|
||||
const requestTask = () => {
|
||||
navigate(URL.ADMIN__CONTENTS__STANDARDS_RESEARCH ,{ replace: true });
|
||||
};
|
||||
|
||||
if( purpose !== purposeOriginal ) {
|
||||
setConfirm({...confirm, open: true, body: "작업 내용을 취소하시겠습니까?", yesCallback: requestTask});
|
||||
} else if( content !== contentOriginal ) {
|
||||
setConfirm({...confirm, open: true, body: "작업 내용을 취소하시겠습니까?", yesCallback: requestTask});
|
||||
} else if( effectContent !== effectContentOriginal ) {
|
||||
setConfirm({...confirm, open: true, body: "작업 내용을 취소하시겠습니까?", yesCallback: requestTask});
|
||||
} else {
|
||||
requestTask();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
const convertDate = (str) => {
|
||||
let year = str.substring(0, 4);
|
||||
let month = str.substring(4, 6);
|
||||
let date = str.substring(6, 8);
|
||||
let hour = str.substring(8, 10);
|
||||
let minute = str.substring(10, 12);
|
||||
return new Date(year, month - 1, date, hour, minute)
|
||||
}
|
||||
const getDateFourteenDigit = (date) => {
|
||||
return `${getYYYYMMDD(date).toString()}${makeTwoDigit(date.getHours())}${makeTwoDigit(date.getMinutes())}${makeTwoDigit(date.getSeconds())}`;
|
||||
}
|
||||
const getYYYYMMDD = (date) => {
|
||||
return date.getFullYear().toString() + makeTwoDigit(Number(date.getMonth() + 1)) + makeTwoDigit(date.getDate());
|
||||
}
|
||||
const makeTwoDigit = (number) => {
|
||||
return number < 10 ? "0" + number : number.toString();
|
||||
}
|
||||
|
||||
|
||||
const Location = React.memo(function Location() {
|
||||
return (
|
||||
<div className="location">
|
||||
<ul>
|
||||
<li><Link to={URL.MAIN} className="home">Home</Link></li>
|
||||
<li><Link to={URL.ADMIN}>사이트 관리</Link></li>
|
||||
<li>컨텐츠 관리</li>
|
||||
<li>건설기준연구 관리</li>
|
||||
</ul>
|
||||
</div>
|
||||
)
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="container">
|
||||
<div className="c_wrap">
|
||||
{/* <!-- Location --> */}
|
||||
<Location />
|
||||
{/* <!--// Location --> */}
|
||||
|
||||
<div className="layout">
|
||||
{/* <!-- Navigation --> */}
|
||||
<EgovLeftNav></EgovLeftNav>
|
||||
{/* <!--// Navigation --> */}
|
||||
|
||||
<div className="contents " id="contents">
|
||||
{/* <!-- 본문 --> */}
|
||||
<StyledDiv>
|
||||
<div className="top_tit">
|
||||
<h1 className="tit_1">건설기준연구 추가</h1>
|
||||
</div>
|
||||
{/* <!-- 상단 입력 form --> */}
|
||||
<div className='board_view2'>
|
||||
<dl>
|
||||
<dt><label htmlFor="title">연구명</label><span className="req">필수</span></dt>
|
||||
<dd>
|
||||
<input className="f_input2 w_full" type="text" name="title" title="연구명" id="title" placeholder="연구명을 입력하세요."
|
||||
value={standardResearchDetail.title}
|
||||
onChange={(e) => setStandardResearchDetail({ ...standardResearchDetail, title: e.target.value })}
|
||||
/>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt>연구 기간<span className="req">필수</span></dt>
|
||||
<dd className="datetime">
|
||||
<span className="line_break">
|
||||
<DatePicker
|
||||
selected={standardResearchDetail.researchStartDate}
|
||||
name="researchStartDate"
|
||||
className="f_input"
|
||||
dateFormat="yyyy-MM-dd"
|
||||
onChange={(date) => {
|
||||
console.log("setStartDate : ", date);
|
||||
setStandardResearchDetail({ ...standardResearchDetail, schdulBgnde: getDateFourteenDigit(date), schdulBgndeYYYMMDD: getYYYYMMDD(date), researchStartDate: date });
|
||||
}} />
|
||||
<span className="f_inn_txt">~</span>
|
||||
</span>
|
||||
<span className="line_break">
|
||||
<DatePicker
|
||||
selected={standardResearchDetail.researchEndDate}
|
||||
name="researchEndDate"
|
||||
className="f_input"
|
||||
dateFormat="yyyy-MM-dd"
|
||||
minDate={standardResearchDetail.researchStartDate}
|
||||
onChange={(date) => {
|
||||
console.log("setEndDate: ", date);
|
||||
setStandardResearchDetail({ ...standardResearchDetail, schdulEndde: getDateFourteenDigit(date), schdulEnddeYYYMMDD: getYYYYMMDD(date), researchEndDate: date });
|
||||
}
|
||||
} />
|
||||
</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label htmlFor="director">연구 책임자</label><span className="req">필수</span></dt>
|
||||
<dd>
|
||||
<input className="f_input2 w_full" type="text" name="director" title="연구 책임자" id="director" placeholder="연구 책임자를 입력하세요."
|
||||
value={standardResearchDetail.director}
|
||||
onChange={(e) => setStandardResearchDetail({ ...standardResearchDetail, director: e.target.value })}
|
||||
/>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
{/* <!--// 상단 입력 form --> */}
|
||||
|
||||
{/* <!-- 게시판 --> */}
|
||||
<label className="label-text-editor">연구 목적<span className="req">필수</span></label>
|
||||
<RichTextEditor item={purpose} setText={setPurpose}/>
|
||||
|
||||
<label className="label-text-editor">연구 내용<span className="req">필수</span></label>
|
||||
<RichTextEditor item={content} setText={setContent}/>
|
||||
|
||||
<label className="label-text-editor">기대 효과<span className="req">필수</span></label>
|
||||
<RichTextEditor item={effectContent} setText={setEffectContent}/>
|
||||
{/* <!--// 게시판 --> */}
|
||||
|
||||
{/* <!-- 버튼영역 --> */}
|
||||
<div className="board_btn_area">
|
||||
<div className="left_col btn1">
|
||||
<button className="btn btn_skyblue_h46 w_100"
|
||||
onClick={() => createItem()}
|
||||
> 저장</button>
|
||||
{modeInfo.mode === CODE.MODE_MODIFY &&
|
||||
<button className="btn btn_skyblue_h46 w_100"
|
||||
onClick={(e) => {
|
||||
onClickDelete(location.state?.rsId);
|
||||
}}>삭제</button>
|
||||
}
|
||||
</div>
|
||||
<div className="right_col btn1">
|
||||
<button className="btn btn_blue_h46 w_100"
|
||||
onClick={onClickList}>목록</button>
|
||||
</div>
|
||||
</div>
|
||||
{/* <!--// 버튼영역 --> */}
|
||||
|
||||
<AlertDialogSlide confirm={confirm} setConfirm={setConfirm} />
|
||||
</StyledDiv>
|
||||
{/* <!--// 본문 --> */}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
export default StandardResearchEditor;
|
||||
|
|
@ -1,30 +1,180 @@
|
|||
import React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
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 Switch from '@mui/material/Switch';
|
||||
|
||||
import * as EgovNet from 'api/egovFetch';
|
||||
import URL from 'constants/url';
|
||||
|
||||
import { default as EgovLeftNav } from 'components/leftmenu/EgovLeftNavAdmin';
|
||||
|
||||
import { itemIdxByPage } from 'utils/calc';
|
||||
import EgovPaging from 'components/EgovPaging';
|
||||
|
||||
|
||||
function ApiKeys(props) {
|
||||
// console.group("EgovAdminPrivacyList");
|
||||
// console.log("[Start] EgovAdminPrivacyList ------------------------------");
|
||||
// console.log("EgovAdminPrivacyList [props] : ", props);
|
||||
const location = useLocation();
|
||||
// console.log("EgovAdminPrivacyList [location] : ", location);
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const [searchCondition, setSearchCondition] = useState(location.state?.searchCondition || { pageIndex: 1, searchCnd: '0', searchWrd: '' });
|
||||
const [paginationInfo, setPaginationInfo] = useState({});
|
||||
const [chartData, setChartData] = useState([]);
|
||||
const [user_id, setuser_id] = useState([]);
|
||||
|
||||
const [listTag, setListTag] = useState([]);
|
||||
// const label = { inputProps: { 'aria-label': '사용여부' } };
|
||||
|
||||
const retrieveList = useCallback((srchCnd) => {
|
||||
// console.groupCollapsed("EgovAdminUsageList.retrieveList()");
|
||||
const retrieveListURL = '/admin/standards/apikey';
|
||||
|
||||
const requestOptions = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(srchCnd)
|
||||
}
|
||||
|
||||
EgovNet.requestFetch(
|
||||
retrieveListURL,
|
||||
requestOptions,
|
||||
(resp) => {
|
||||
setPaginationInfo(resp.result.paginationInfo);
|
||||
|
||||
let mutListTag = [];
|
||||
listTag.push(<p className="no_data" key="0">데이터가 없습니다.</p>); // 게시판 목록 초기값
|
||||
|
||||
const resultCnt = parseInt(resp.result.resultCnt);
|
||||
const currentPageNo = resp.result.paginationInfo.pageIndex;
|
||||
const pageSize = resp.result.paginationInfo.rowCnt;
|
||||
|
||||
const startIndex = (currentPageNo - 1) * pageSize;
|
||||
const endIndex = Math.min(startIndex + pageSize, resultCnt);
|
||||
|
||||
// 리스트 항목 구성
|
||||
for (let index = startIndex; index < endIndex; index++) {
|
||||
const listIdx = itemIdxByPage(resultCnt, currentPageNo, 0, index); // pageSize 로 넣으면 listIdx값이 2배씩 줄어서 0으로 수정
|
||||
const item = resp.result.resultList[index];
|
||||
|
||||
mutListTag.push(
|
||||
<div key={listIdx} className="list_item">
|
||||
<div>{item.userId}</div>
|
||||
<div style={{ cursor: 'pointer' }} onClick={() => handleApiKeyChart(item)}>{item.apiKey}</div>
|
||||
<div>{item.startDt} ~ {item.endDt}</div>
|
||||
<div>{item.idntyYn === 'Y' ? <Switch defaultChecked onChange={() => handleSwitchToggle(item)} /> : <Switch onChange={() => handleSwitchToggle(item)} />}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
setListTag(mutListTag);
|
||||
},
|
||||
function (resp) {
|
||||
console.log("err response : ", resp);
|
||||
}
|
||||
);
|
||||
// console.groupEnd("EgovAdminPrivacyList.retrieveList()");
|
||||
},[listTag]);
|
||||
|
||||
const CustomTooltip = ({ active, payload, label }) => {
|
||||
if (active && payload && payload.length) {
|
||||
return (
|
||||
<div className="custom-tooltip">
|
||||
<p className="intro">API 요청 [{user_id}]</p>
|
||||
<p className="label">{`${label} : ${payload[0].value}`}회</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const handleSwitchToggle = async (item) => {
|
||||
try {
|
||||
const updateApiEndpoint = '/admin/standards/apiupdate';
|
||||
const requestOptions = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(item),
|
||||
};
|
||||
|
||||
const response = await EgovNet.requestFetch(updateApiEndpoint, requestOptions);
|
||||
const data = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
console.log('Data updated successfully:', data);
|
||||
return { success: true, data };
|
||||
} else {
|
||||
console.error('Failed to update data:', data);
|
||||
return { success: false, error: data };
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error during data update:', error);
|
||||
return { success: false, error };
|
||||
}
|
||||
};
|
||||
|
||||
const handleApiKeyChart = (item) => {
|
||||
try {
|
||||
const updateApiEndpoint = '/admin/standards/apiDailyChart';
|
||||
const requestOptions = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(item),
|
||||
};
|
||||
|
||||
EgovNet.requestFetch(
|
||||
updateApiEndpoint,
|
||||
requestOptions,
|
||||
(resp) => {
|
||||
let chartDataArray = resp.result.resultList.map((item, index) => ({
|
||||
logdt: item[0], // Assuming logCnt is the x-axis data
|
||||
"API 요청수": item[1], // Assuming menuTitle is the y-axis data
|
||||
}));
|
||||
setChartData(chartDataArray);
|
||||
// item.userId 값 넣기
|
||||
console.log(`User ID: ${item.userId}`);
|
||||
setuser_id(item.userId);
|
||||
},
|
||||
function (resp) {
|
||||
console.log("err response : ", resp);
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('Error during data update:', error);
|
||||
return { success: false, error };
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
retrieveList(searchCondition);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
// console.log("------------------------------EgovAdminPrivacyList [End]");
|
||||
// console.groupEnd("EgovAdminPrivacyList");
|
||||
|
||||
const Location = React.memo(function Location() {
|
||||
return (
|
||||
<div className="location">
|
||||
<ul>
|
||||
<li><Link to={URL.MAIN} className="home">Home</Link></li>
|
||||
<li><Link to={URL.ADMIN}>건설기준 관리</Link></li>
|
||||
<li>API KEY 관리</li>
|
||||
</ul>
|
||||
</div>
|
||||
)
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="container">
|
||||
<div className="c_wrap">
|
||||
{/* <!-- Location --> */}
|
||||
<Location />
|
||||
<div className="location">
|
||||
<ul>
|
||||
<li><Link to={URL.MAIN} className="home">Home</Link></li>
|
||||
<li><Link to={URL.ADMIN} >사이트관리</Link></li>
|
||||
<li>건설기준 관리</li>
|
||||
<li>API KEY 관리</li>
|
||||
</ul>
|
||||
</div>
|
||||
{/* <!--// Location --> */}
|
||||
|
||||
<div className="layout">
|
||||
|
|
@ -35,13 +185,51 @@ function ApiKeys(props) {
|
|||
<div className="contents " id="contents">
|
||||
{/* <!-- 본문 --> */}
|
||||
<div className="top_tit">
|
||||
<h1 className="tit_1">건설기준 관리</h1>
|
||||
<h1 className="tit_1">API KEY 관리</h1>
|
||||
</div>
|
||||
|
||||
<h2 className="tit_2">API KEY 관리</h2>
|
||||
{/* <!-- 목록 --> */}
|
||||
<div className="board_list BRD012">
|
||||
<div className="head">
|
||||
<span>사용자</span>
|
||||
<span>발급키</span>
|
||||
<span>승인기간</span>
|
||||
<span>승인여부</span>
|
||||
</div>
|
||||
<div className="result">
|
||||
{listTag}
|
||||
</div>
|
||||
</div>
|
||||
{/* <!--// 목록 -->*/}
|
||||
|
||||
여기에 구현해주세요.
|
||||
{/* <!--// 본문 --> */}
|
||||
<div className="board_bot mt-1">
|
||||
{/* <!-- Paging --> */}
|
||||
<EgovPaging pagination={paginationInfo} moveToPage={passedPage => {
|
||||
retrieveList({ ...searchCondition, pageIndex: passedPage }) //, searchCnd: cndRef.current.value, searchWrd: wrdRef.current.value
|
||||
}} />
|
||||
{/* <!--/ Paging --> */}
|
||||
</div>
|
||||
<div className="pt-2">
|
||||
<ResponsiveContainer width="100%" height={477}>
|
||||
<BarChart data={chartData} layout="vertical"
|
||||
height={477}
|
||||
margin={{
|
||||
top: 0,
|
||||
right: 0,
|
||||
left: 20,
|
||||
bottom: 0,
|
||||
}}
|
||||
>
|
||||
<CartesianGrid strokeDasharray="3 3" />
|
||||
<XAxis type="number" />
|
||||
<YAxis type="category" dataKey="logdt" tick={{ fontSize: 10, whiteSpace: 'nowrap' }} />
|
||||
<Tooltip content={<CustomTooltip/>} />
|
||||
<Legend />
|
||||
<Bar dataKey="API 요청수" fill="#87CEFA" activeBar={<Rectangle fill="gold" stroke="purple" />} />
|
||||
</BarChart>
|
||||
</ResponsiveContainer>
|
||||
</div>
|
||||
{/* <!--// 본문 -->*/}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -89,11 +89,12 @@ import AdminStandardsSimilarityCheck from 'pages/admin/standards/SimilarityCheck
|
|||
import AdminStandardsInfoDisclosure from 'pages/admin/standards/InfoDisclosure'; // 관리자 - 건설기준 관리/정보공개 관리
|
||||
|
||||
// 관리자 - 컨텐츠 관리
|
||||
import AdminContentsSurvey from 'pages/admin/contents/Survey'; // 관리자 - 컨텐츠 관리/설문 관리
|
||||
import AdminContentsPopUp from 'pages/admin/contents/PopUp'; // 관리자 - 컨텐츠 관리/팝업 관리
|
||||
import AdminContentsPopUpWriter from 'pages/admin/contents/PopUp/PopupWriter'; // 관리자 - 컨텐츠 관리/팝업 관리/팝업 추가 또는 수정
|
||||
import AdminContentsStandardResearch from 'pages/admin/contents/StandardResearch'; // 관리자 - 컨텐츠 관리/건설기준연구 관리
|
||||
import AdminContentsTextMessages from 'pages/admin/contents/TextMessages'; // 관리자 - 컨텐츠 관리/문자 발송
|
||||
import AdminContentsSurvey from 'pages/admin/contents/Survey'; // 관리자 - 컨텐츠 관리/설문 관리
|
||||
import AdminContentsPopUp from 'pages/admin/contents/PopUp'; // 관리자 - 컨텐츠 관리/팝업 관리
|
||||
import AdminContentsPopUpEditor from 'pages/admin/contents/PopUp/PopupEditor'; // 관리자 - 컨텐츠 관리/팝업 관리/팝업 추가 또는 수정
|
||||
import AdminContentsStandardResearch from 'pages/admin/contents/StandardResearch'; // 관리자 - 컨텐츠 관리/건설기준연구 관리
|
||||
import AdminContentsStandardResearchEditor from 'pages/admin/contents/StandardResearch/StandardResearchEditor'; // 컨텐츠 관리/건설기준연구 관리/추가 또는 수정
|
||||
import AdminContentsTextMessages from 'pages/admin/contents/TextMessages'; // 관리자 - 컨텐츠 관리/문자 발송
|
||||
|
||||
// 관리자 - 위원회 관리
|
||||
import AdminCommitteeProgressStatus from 'pages/admin/committee/ProgressStatus'; // 관리자 - 위원회 관리/진행현황 관리
|
||||
|
|
@ -298,9 +299,11 @@ const SecondRoutes = () => {
|
|||
{/* 관리자 - 컨텐츠 관리 */}
|
||||
<Route path={URL.ADMIN__CONTENTS__SURVEY} element={<AdminContentsSurvey />} />
|
||||
<Route path={URL.ADMIN__CONTENTS__POP_UP} element={<AdminContentsPopUp />} />
|
||||
<Route path={URL.ADMIN__CONTENTS__POP_UP__CREATE} element={<AdminContentsPopUpWriter mode={CODE.MODE_CREATE} />} />
|
||||
<Route path={URL.ADMIN__CONTENTS__POP_UP__MODIFY} element={<AdminContentsPopUpWriter mode={CODE.MODE_MODIFY} />} />
|
||||
<Route path={URL.ADMIN__CONTENTS__POP_UP__CREATE} element={<AdminContentsPopUpEditor mode={CODE.MODE_CREATE} />} />
|
||||
<Route path={URL.ADMIN__CONTENTS__POP_UP__MODIFY} element={<AdminContentsPopUpEditor mode={CODE.MODE_MODIFY} />} />
|
||||
<Route path={URL.ADMIN__CONTENTS__STANDARDS_RESEARCH} element={<AdminContentsStandardResearch />} />
|
||||
<Route path={URL.ADMIN__CONTENTS__STANDARDS_RESEARCH__CREATE} element={<AdminContentsStandardResearchEditor mode={CODE.MODE_CREATE} />} />
|
||||
<Route path={URL.ADMIN__CONTENTS__STANDARDS_RESEARCH__MODIFY} element={<AdminContentsStandardResearchEditor mode={CODE.MODE_MODIFY} />} />
|
||||
<Route path={URL.ADMIN__CONTENTS__TEXT_MESSAGES} element={<AdminContentsTextMessages />} />
|
||||
|
||||
{/* 관리자 - 위원회 관리 */}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,240 @@
|
|||
package com.dbnt.kcscbackend.admin.standardResearch;
|
||||
|
||||
|
||||
import com.dbnt.kcscbackend.admin.contents.popUp.model.CreatePopupVO;
|
||||
import com.dbnt.kcscbackend.admin.contents.popUp.model.UpdatePopupVO;
|
||||
import com.dbnt.kcscbackend.admin.contents.popUp.utils.EgovFileMngUtil;
|
||||
import com.dbnt.kcscbackend.admin.standardResearch.model.CreateStandardResearchVO;
|
||||
import com.dbnt.kcscbackend.admin.standardResearch.model.UpdateStandardResearchVO;
|
||||
import com.dbnt.kcscbackend.admin.standardResearch.service.AdminStandardResearchService;
|
||||
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
||||
import com.dbnt.kcscbackend.config.common.ResponseCode;
|
||||
import com.dbnt.kcscbackend.config.common.ResultVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
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 org.springframework.data.domain.Pageable;
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
|
||||
@Api("AdminStandardResearchController")
|
||||
@RestController
|
||||
@Tag(name="AdminStandardResearchController",description = "건설기준연구 관리")
|
||||
public class AdminStandardResearchController {
|
||||
|
||||
@Resource(name = "adminStandardResearchService")
|
||||
private AdminStandardResearchService adminStandardResearchService;
|
||||
|
||||
@Resource(name = "EgovFileMngUtil")
|
||||
private EgovFileMngUtil fileUtil;
|
||||
|
||||
@Operation(
|
||||
summary = "'건설기준연구 관리' 페이지에서 목록 불러오는 API",
|
||||
description = "관리자 단에서 '컨텐츠 관리' > '건설기준연구 관리' 페이지에서 목록 불러오는 API",
|
||||
tags = {"AdminStandardResearchController"}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "조회 성공"),
|
||||
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||
})
|
||||
@GetMapping(value = "/contents/standard-research/list")
|
||||
public ResultVO contentsStandardResearchList(
|
||||
@AuthenticationPrincipal LoginVO user,
|
||||
HttpServletRequest request,
|
||||
Pageable pageable) throws Exception {
|
||||
|
||||
ResultVO resultVO = new ResultVO();
|
||||
|
||||
try {
|
||||
resultVO = adminStandardResearchService.contentsStandardResearchList(resultVO, request, user, pageable);
|
||||
} catch (Exception e) {
|
||||
resultVO.setResultCode(ResponseCode.FAILED.getCode());
|
||||
resultVO.setResultMessage(e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
System.out.println(
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
request.getRequestURI() + " OUT:" +
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
"resultVO.toString():" + "\n" +
|
||||
resultVO.toString() + "\n" +
|
||||
"\n--------------------------------------------------------------\n"
|
||||
);
|
||||
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Operation(
|
||||
summary = "추가 API",
|
||||
description = "관리자 단에서 '컨텐츠 관리' > '건설기준연구 관리' 페이지에서 항목을 추가하는 API",
|
||||
tags = {"AdminStandardResearchController"}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "등록 성공"),
|
||||
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님"),
|
||||
@ApiResponse(responseCode = "900", description = "입력값 무결성 오류")
|
||||
})
|
||||
@PostMapping(value = "/contents/standard-research")
|
||||
public ResultVO contentsStandardResearchCreate(
|
||||
HttpServletRequest request,
|
||||
@AuthenticationPrincipal LoginVO loginVO,
|
||||
final MultipartHttpServletRequest multiRequest,
|
||||
CreateStandardResearchVO createStandardResearchVO
|
||||
) throws Exception {
|
||||
|
||||
ResultVO resultVO = new ResultVO();
|
||||
|
||||
try {
|
||||
resultVO = adminStandardResearchService.contentsStandardResearchCreate(resultVO, request, loginVO, multiRequest, createStandardResearchVO);
|
||||
} catch (Exception e) {
|
||||
resultVO.setResultCode(ResponseCode.FAILED.getCode());
|
||||
resultVO.setResultMessage(e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
System.out.println(
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
request.getRequestURI() + " OUT:" +
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
"resultVO.toString():" + "\n" +
|
||||
resultVO.toString() + "\n" +
|
||||
"\n--------------------------------------------------------------\n"
|
||||
);
|
||||
|
||||
return resultVO;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Operation(
|
||||
summary = "수정 API",
|
||||
description = "관리자 단에서 '컨텐츠 관리' > '건설기준연구 관리' 페이지에서 항목을 수정하는 API",
|
||||
tags = {"AdminStandardResearchController"}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "등록 성공"),
|
||||
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님"),
|
||||
})
|
||||
@PutMapping(value = "/contents/standard-research/{rsId}")
|
||||
public ResultVO contentsStandardResearchUpdate(
|
||||
HttpServletRequest request,
|
||||
@AuthenticationPrincipal LoginVO loginVO,
|
||||
UpdateStandardResearchVO updateStandardResearchVO,
|
||||
@PathVariable("rsId") Long rsId
|
||||
) throws Exception {
|
||||
|
||||
ResultVO resultVO = new ResultVO();
|
||||
|
||||
try {
|
||||
resultVO = adminStandardResearchService.contentsStandardResearchUpdate(resultVO, request, loginVO, updateStandardResearchVO, rsId);
|
||||
} catch (Exception e) {
|
||||
resultVO.setResultCode(ResponseCode.FAILED.getCode());
|
||||
resultVO.setResultMessage(e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
System.out.println(
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
request.getRequestURI() + " OUT:" +
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
"resultVO.toString():" + "\n" +
|
||||
resultVO.toString() + "\n" +
|
||||
"\n--------------------------------------------------------------\n"
|
||||
);
|
||||
|
||||
return resultVO;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Operation(
|
||||
summary = "삭제 API",
|
||||
description = "관리자 단에서 '컨텐츠 관리' > '건설기준연구 관리' 페이지에서 항목을 삭제하는 API",
|
||||
tags = {"AdminStandardResearchController"}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "등록 성공"),
|
||||
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님"),
|
||||
})
|
||||
@DeleteMapping(value = "/contents/standard-research/{rsId}")
|
||||
public ResultVO contentsStandardResearchDelete
|
||||
(
|
||||
@AuthenticationPrincipal LoginVO user,
|
||||
HttpServletRequest request,
|
||||
@PathVariable("rsId") String strRsId
|
||||
) throws Exception {
|
||||
|
||||
ResultVO resultVO = new ResultVO();
|
||||
Long rsId = Long.valueOf(strRsId);
|
||||
try {
|
||||
resultVO = adminStandardResearchService.contentsStandardResearchDelete(resultVO, request, user, rsId);
|
||||
} catch (Exception e) {
|
||||
resultVO.setResultCode(ResponseCode.FAILED.getCode());
|
||||
resultVO.setResultMessage(e.getMessage());
|
||||
}
|
||||
|
||||
System.out.println(
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
request.getRequestURI() + " OUT:" +
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
"resultVO.toString():" + "\n" +
|
||||
resultVO.toString() + "\n" +
|
||||
"\n--------------------------------------------------------------\n"
|
||||
);
|
||||
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
|
||||
@Operation(
|
||||
summary = "내용 불러오기 API",
|
||||
description = "관리자 단에서 '컨텐츠 관리' > '건설기준연구 관리' 페이지에서 저장된 항목을 불러오는 API",
|
||||
tags = {"AdminStandardResearchController"}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "조회 성공")
|
||||
})
|
||||
@GetMapping(value = "/contents/standard-research/{rsId}")
|
||||
public ResultVO contentsStandardResearchRead(
|
||||
HttpServletRequest request,
|
||||
@AuthenticationPrincipal LoginVO loginVO,
|
||||
@PathVariable("rsId") Long rsId
|
||||
) throws Exception {
|
||||
|
||||
ResultVO resultVO = new ResultVO();
|
||||
|
||||
try {
|
||||
resultVO = adminStandardResearchService.contentsStandardResearchRead(resultVO, request, loginVO, rsId);
|
||||
} catch (Exception e) {
|
||||
resultVO.setResultCode(ResponseCode.FAILED.getCode());
|
||||
resultVO.setResultMessage(e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
System.out.println(
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
request.getRequestURI() + " OUT:" +
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
"resultVO.toString():" + "\n" +
|
||||
resultVO.toString() + "\n" +
|
||||
"\n--------------------------------------------------------------\n"
|
||||
);
|
||||
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package com.dbnt.kcscbackend.admin.standardResearch.model;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ApiModel(value = "CreateStandardResearchVO", description =
|
||||
"관리자 단에서 '컨텐츠 관리' > '건설기준연구 관리' 페이지에서 글 작성하는 API에 사용된다." + ""
|
||||
)
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class CreateStandardResearchVO implements Serializable {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 2635889608799075362L;
|
||||
|
||||
@ApiModelProperty(value = "title")
|
||||
private String title;
|
||||
@ApiModelProperty(value = "researchStartDate")
|
||||
private String researchStartDate;
|
||||
@ApiModelProperty(value = "researchEndDate")
|
||||
private String researchEndDate;
|
||||
@ApiModelProperty(value = "director")
|
||||
private String director;
|
||||
@ApiModelProperty(value = "purpose")
|
||||
private String purpose;
|
||||
@ApiModelProperty(value = "content")
|
||||
private String content;
|
||||
@ApiModelProperty(value = "effectContent")
|
||||
private String effectContent;
|
||||
/*
|
||||
files: (binary)
|
||||
files: (binary)
|
||||
files: (binary)
|
||||
*/
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
package com.dbnt.kcscbackend.admin.standardResearch.model;
|
||||
|
||||
import lombok.*;
|
||||
import org.hibernate.annotations.DynamicInsert;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@NoArgsConstructor
|
||||
@DynamicInsert
|
||||
@DynamicUpdate
|
||||
@Table(name = "tn_research")
|
||||
public class TnResearchLightweight {
|
||||
|
||||
@Id
|
||||
@Column(name = "rs_seq")
|
||||
private Long rsSeq;
|
||||
|
||||
@Column(name = "rs_title")
|
||||
private String rsTitle;
|
||||
|
||||
@Column(name = "rs_start_date")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime rsStartDate;
|
||||
|
||||
@Column(name = "rs_end_date")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime rsEndDate;
|
||||
|
||||
@Column(name = "rs_director")
|
||||
private String rsDirector;
|
||||
|
||||
@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;
|
||||
|
||||
|
||||
@Embeddable
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class TnResearchId implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 9042992093269088042L;
|
||||
|
||||
private String rsSeq;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package com.dbnt.kcscbackend.admin.standardResearch.model;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ApiModel(value = "UpdateStandardResearchVO", description =
|
||||
"관리자 단에서 '컨텐츠 관리' > '건설기준연구 관리' 페이지에서 글 수정하는 API에 사용된다." + ""
|
||||
)
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class UpdateStandardResearchVO implements Serializable {
|
||||
|
||||
|
||||
private static final long serialVersionUID = -2518477576804111511L;
|
||||
|
||||
@ApiModelProperty(value = "id")
|
||||
private String id;
|
||||
@ApiModelProperty(value = "title")
|
||||
private String title;
|
||||
@ApiModelProperty(value = "researchStartDate")
|
||||
private String researchStartDate;
|
||||
@ApiModelProperty(value = "researchEndDate")
|
||||
private String researchEndDate;
|
||||
@ApiModelProperty(value = "director")
|
||||
private String director;
|
||||
@ApiModelProperty(value = "purpose")
|
||||
private String purpose;
|
||||
@ApiModelProperty(value = "content")
|
||||
private String content;
|
||||
@ApiModelProperty(value = "effectContent")
|
||||
private String effectContent;
|
||||
/*
|
||||
files: (binary)
|
||||
files: (binary)
|
||||
files: (binary)
|
||||
*/
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.dbnt.kcscbackend.admin.standardResearch.repository;
|
||||
|
||||
import com.dbnt.kcscbackend.admin.standardResearch.model.TnResearchLightweight;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface TnResearchRepositoryLightweight extends JpaRepository<TnResearchLightweight, Long> {
|
||||
@Query(value = "SELECT COUNT(1) FROM tn_research tr WHERE tr.use_yn = :use_yn", nativeQuery = true)
|
||||
Long countByUseYn(@Param("use_yn") String useYn);
|
||||
|
||||
List<TnResearchLightweight> findByUseYn( String useYn, Pageable pageable);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.dbnt.kcscbackend.admin.standardResearch.service;
|
||||
|
||||
import com.dbnt.kcscbackend.admin.contents.popUp.model.CreatePopupVO;
|
||||
import com.dbnt.kcscbackend.admin.contents.popUp.model.UpdatePopupVO;
|
||||
import com.dbnt.kcscbackend.admin.standardResearch.model.CreateStandardResearchVO;
|
||||
import com.dbnt.kcscbackend.admin.standardResearch.model.UpdateStandardResearchVO;
|
||||
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
||||
import com.dbnt.kcscbackend.config.common.ResultVO;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
public interface AdminStandardResearchService {
|
||||
public ResultVO contentsStandardResearchList(ResultVO resultVO, HttpServletRequest request, LoginVO user, Pageable pageable) throws Exception;
|
||||
public ResultVO contentsStandardResearchCreate(ResultVO resultVO, HttpServletRequest request, LoginVO user, final MultipartHttpServletRequest multiRequest, CreateStandardResearchVO createStandardResearchVO) throws Exception;
|
||||
public ResultVO contentsStandardResearchRead(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long popupId) throws Exception;
|
||||
public ResultVO contentsStandardResearchUpdate(ResultVO resultVO, HttpServletRequest request, LoginVO user, UpdateStandardResearchVO updateStandardResearchVO, Long popupId) throws Exception;
|
||||
public ResultVO contentsStandardResearchDelete(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long popupId) throws Exception;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,253 @@
|
|||
package com.dbnt.kcscbackend.admin.standardResearch.service.impl;
|
||||
|
||||
|
||||
import com.dbnt.kcscbackend.admin.contents.popUp.model.CreatePopupVO;
|
||||
import com.dbnt.kcscbackend.admin.contents.popUp.model.FileVO;
|
||||
import com.dbnt.kcscbackend.admin.contents.popUp.model.UpdatePopupVO;
|
||||
import com.dbnt.kcscbackend.admin.contents.popUp.repository.TnPopupMngRepositoryWithoutPopupContents;
|
||||
import com.dbnt.kcscbackend.admin.contents.popUp.service.PopUpApiService;
|
||||
import com.dbnt.kcscbackend.admin.standardResearch.model.CreateStandardResearchVO;
|
||||
import com.dbnt.kcscbackend.admin.standardResearch.model.UpdateStandardResearchVO;
|
||||
import com.dbnt.kcscbackend.admin.standardResearch.repository.TnResearchRepositoryLightweight;
|
||||
import com.dbnt.kcscbackend.admin.standardResearch.service.AdminStandardResearchService;
|
||||
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
||||
import com.dbnt.kcscbackend.commonCode.entity.TnPopupMng;
|
||||
import com.dbnt.kcscbackend.commonCode.entity.TnResearch;
|
||||
import com.dbnt.kcscbackend.commonCode.repository.TnPopupMngRepository;
|
||||
import com.dbnt.kcscbackend.commonCode.repository.TnResearchRepository;
|
||||
import com.dbnt.kcscbackend.config.common.ResponseCode;
|
||||
import com.dbnt.kcscbackend.config.common.ResultVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
|
||||
import org.egovframe.rte.ptl.mvc.tags.ui.pagination.PaginationInfo;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service("adminStandardResearchService")
|
||||
@RequiredArgsConstructor
|
||||
public class AdminStandardResearchServiceImpl extends EgovAbstractServiceImpl implements AdminStandardResearchService {
|
||||
|
||||
private final TnResearchRepository tnResearchRepository;
|
||||
private final TnResearchRepositoryLightweight tnResearchRepositoryLightweight;
|
||||
|
||||
|
||||
@Override
|
||||
public ResultVO contentsStandardResearchList(ResultVO resultVO, HttpServletRequest request, LoginVO user, Pageable pageable) throws Exception {
|
||||
|
||||
System.out.println(
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
request.getRequestURI() + " IN:" +
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
"user.getEmail():" + "\n" +
|
||||
user.getEmail() + "\n" +
|
||||
"\n--------------------------------------------------------------\n"
|
||||
);
|
||||
|
||||
|
||||
long totalRecordCount = tnResearchRepositoryLightweight.countByUseYn("Y");
|
||||
List<Map<String, Object>> list = tnResearchRepositoryLightweight.findByUseYn("Y", pageable)
|
||||
.stream()
|
||||
.map(item -> {
|
||||
Map<String, Object> codeMap = new HashMap<>();
|
||||
codeMap.put("id", item.getRsSeq());
|
||||
codeMap.put("title", item.getRsTitle());
|
||||
codeMap.put("researchStartDate", item.getRsStartDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
||||
codeMap.put("researchEndDate", item.getRsEndDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
||||
codeMap.put("director", item.getRsDirector());
|
||||
//codeMap.put("createDate", item.getFrstCrtDt());
|
||||
//codeMap.put("createUserId", item.getFrstCrtId());
|
||||
//codeMap.put("updateDate", item.getLastChgDt());
|
||||
//codeMap.put("updateUserId", item.getLastChgId());
|
||||
//codeMap.put("useYn", item.getUseYn());
|
||||
return codeMap;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
PaginationInfo paginationInfo = new PaginationInfo();
|
||||
paginationInfo.setCurrentPageNo(pageable.getPageNumber()+1);
|
||||
paginationInfo.setRecordCountPerPage(pageable.getPageSize());
|
||||
paginationInfo.setPageSize(5);//hard coded
|
||||
paginationInfo.setTotalRecordCount((int) totalRecordCount);
|
||||
|
||||
Map<String, Object> dto = new HashMap<String, Object>();
|
||||
dto.put("list", list);
|
||||
dto.put("paginationInfo", paginationInfo);
|
||||
resultVO.setResult(dto);
|
||||
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||
resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage());
|
||||
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ResultVO contentsStandardResearchCreate(ResultVO resultVO, HttpServletRequest request, LoginVO user, final MultipartHttpServletRequest multiRequest, CreateStandardResearchVO createStandardResearchVO) throws Exception {
|
||||
|
||||
System.out.println(
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
request.getRequestURI() + " IN:" +
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
"user.getEmail():" + "\n" +
|
||||
user.getEmail() + "\n" +
|
||||
"\n--------------------------------------------------------------\n"
|
||||
);
|
||||
|
||||
|
||||
Map<String, Object> response = tnResearchRepository.spAddTnResearch(
|
||||
createStandardResearchVO.getTitle(),
|
||||
createStandardResearchVO.getResearchStartDate(),
|
||||
createStandardResearchVO.getResearchEndDate(),
|
||||
createStandardResearchVO.getDirector(),
|
||||
createStandardResearchVO.getPurpose(),
|
||||
createStandardResearchVO.getContent(),
|
||||
createStandardResearchVO.getEffectContent(),
|
||||
"kcsc_admin",
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
||||
|
||||
Map<String, Object> dto = new HashMap<String, Object>();
|
||||
|
||||
resultVO.setResult(dto);
|
||||
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||
resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage());
|
||||
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResultVO contentsStandardResearchRead(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long rsId) throws Exception {
|
||||
|
||||
System.out.println(
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
request.getRequestURI() + " IN:" +
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
"user.getEmail():" + "\n" +
|
||||
user.getEmail() + "\n" +
|
||||
"rsId:" + "\n" +
|
||||
rsId + "\n" +
|
||||
"\n--------------------------------------------------------------\n"
|
||||
);
|
||||
|
||||
|
||||
TnResearch tnResearch = tnResearchRepository.findByRsSeq(rsId);
|
||||
|
||||
|
||||
Map<String, Object> dto = new HashMap<String, Object>();
|
||||
dto.put("content", tnResearch.getRsContents());
|
||||
dto.put("createDate", tnResearch.getFrstCrtDt().plusHours(9).format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); // 날짜/시간의 시작 일시 - yyyyMMddHHmmss
|
||||
dto.put("createUserId", tnResearch.getFrstCrtId());
|
||||
dto.put("director", tnResearch.getRsDirector());
|
||||
dto.put("effectContent", tnResearch.getRsEffect());
|
||||
dto.put("id", tnResearch.getRsSeq());
|
||||
dto.put("purpose", tnResearch.getRsPurpose());
|
||||
dto.put("researchEndDate", tnResearch.getRsEndDate().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); // 날짜/시간의 시작 일시 - yyyyMMddHHmmss
|
||||
dto.put("researchStartDate", tnResearch.getRsStartDate().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); // 날짜/시간의 종료 일시 - yyyyMMddHHmmss
|
||||
dto.put("title", tnResearch.getRsTitle());
|
||||
dto.put("updateDate", tnResearch.getLastChgDt()); // 날짜/시간의 종료 일시 - yyyyMMddHHmmss
|
||||
dto.put("updateUserId", tnResearch.getLastChgId());
|
||||
dto.put("useYn", tnResearch.getUseYn());
|
||||
|
||||
resultVO.setResult(dto);
|
||||
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||
resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage());
|
||||
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultVO contentsStandardResearchUpdate(ResultVO resultVO, HttpServletRequest request, LoginVO user, UpdateStandardResearchVO updateStandardResearchVO, Long rsId) throws Exception {
|
||||
System.out.println(
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
request.getRequestURI() + " IN:" +
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
"updateStandardResearchVO:" + "\n" +
|
||||
updateStandardResearchVO.toString() + "\n" +
|
||||
"rsId:" + "\n" +
|
||||
rsId + "\n" +
|
||||
"\n--------------------------------------------------------------\n"
|
||||
);
|
||||
|
||||
if( Long.parseLong(updateStandardResearchVO.getResearchStartDate()) > Long.parseLong(updateStandardResearchVO.getResearchEndDate()) ) {
|
||||
throw new Exception("종료일시는 시작일시보다 앞 설 수 없습니다.");
|
||||
}
|
||||
|
||||
Map<String, Object> response = tnResearchRepository.spUpdateTnResearch(
|
||||
rsId.intValue(),
|
||||
updateStandardResearchVO.getResearchStartDate(),
|
||||
updateStandardResearchVO.getResearchEndDate(),
|
||||
updateStandardResearchVO.getDirector(),
|
||||
updateStandardResearchVO.getPurpose(),
|
||||
updateStandardResearchVO.getContent(),
|
||||
updateStandardResearchVO.getEffectContent(),
|
||||
"kcsc_admin",
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
||||
|
||||
Map<String, Object> dto = new HashMap<String, Object>();
|
||||
dto.put("errorMessage", response.get("_error_message") );
|
||||
dto.put("rsId", rsId);
|
||||
|
||||
resultVO.setResult(dto);
|
||||
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||
resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage());
|
||||
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResultVO contentsStandardResearchDelete(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long rsId) throws Exception {
|
||||
|
||||
System.out.println(
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
request.getRequestURI() + " IN:" +
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
"rsId:" + "\n" +
|
||||
rsId + "\n" +
|
||||
"\n--------------------------------------------------------------\n"
|
||||
);
|
||||
|
||||
Map<String, Object> dto = new HashMap<String, Object>();
|
||||
|
||||
Map<String, Object> response = tnResearchRepository.spDeleteTnResearch(
|
||||
rsId.intValue(),
|
||||
"admin",
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
dto.put("errorMessage", response.get("_error_message") );
|
||||
|
||||
|
||||
dto.put("rsId", rsId );
|
||||
|
||||
resultVO.setResult(dto);
|
||||
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||
resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage());
|
||||
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
package com.dbnt.kcscbackend.admin.standards;
|
||||
|
||||
import com.dbnt.kcscbackend.admin.standards.entity.TnApiKey;
|
||||
import com.dbnt.kcscbackend.admin.standards.service.AdminApiService;
|
||||
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
||||
import com.dbnt.kcscbackend.config.common.BaseController;
|
||||
import com.dbnt.kcscbackend.config.common.ResponseCode;
|
||||
import com.dbnt.kcscbackend.config.common.ResultVO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
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.springframework.http.MediaType;
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/admin/standards")
|
||||
@Tag(name="AdminStandardsController", description = "사이트관리 건설기준관리 메뉴 컨트롤러")
|
||||
public class AdminStandardsController extends BaseController {
|
||||
|
||||
private final AdminApiService adminApiService;
|
||||
|
||||
@Operation(
|
||||
summary = "건설기준관리 - API 관리",
|
||||
description = "API 관리",
|
||||
tags = {"AdminStandardsController"}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "조회 성공"),
|
||||
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||
})
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/apikey", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResultVO selectApiList(@RequestBody TnApiKey tnApiKey, @AuthenticationPrincipal LoginVO user)
|
||||
throws Exception {
|
||||
|
||||
ResultVO resultVO = new ResultVO();
|
||||
tnApiKey.setQueryInfo();
|
||||
Map<String, Object> resultMap = adminApiService.selectApiList();
|
||||
int totCnt = Integer.parseInt((String)resultMap.get("resultCnt"));
|
||||
tnApiKey.setContentCnt(totCnt);
|
||||
tnApiKey.setPaginationInfo();
|
||||
resultMap.put("paginationInfo", tnApiKey);
|
||||
|
||||
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||
resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage());
|
||||
resultVO.setResult(resultMap);
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "API key 관리",
|
||||
description = "API key 승인여부 수정",
|
||||
tags = {"AdminStandardsController"}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "수정 성공"),
|
||||
@ApiResponse(responseCode = "303", description = "만료된 토큰"),
|
||||
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||
})
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/apiupdate", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResultVO modifyApi(@RequestBody TnApiKey tnApiKey, @AuthenticationPrincipal LoginVO user) throws Exception{
|
||||
ResultVO resultVO = new ResultVO();
|
||||
|
||||
TnApiKey existingApiKey = adminApiService.getApiKeyById(tnApiKey.getUserId());
|
||||
if (existingApiKey != null) {
|
||||
existingApiKey.setIdntyYn(existingApiKey.getIdntyYn().equals("Y") ? "N" : "Y");
|
||||
adminApiService.modifyApi(existingApiKey);
|
||||
|
||||
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||
} else {
|
||||
resultVO.setResultCode(ResponseCode.SAVE_ERROR.getCode()); // 존재하지 않는 user_id에 대한 처리
|
||||
}
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "API key Chart",
|
||||
description = "API key 클릭시 차트",
|
||||
tags = {"AdminStandardsController"}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "수정 성공"),
|
||||
@ApiResponse(responseCode = "303", description = "만료된 토큰"),
|
||||
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||
})
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/apiDailyChart", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResultVO ApiChart(@RequestBody Map<String, String> dateRange, @AuthenticationPrincipal LoginVO user) throws Exception{
|
||||
ResultVO resultVO = new ResultVO();
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
|
||||
String UserId = dateRange.get("userId");
|
||||
|
||||
resultMap.put("resultList", adminApiService.selectApiDailyCount(UserId));
|
||||
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||
resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage());
|
||||
resultVO.setResult(resultMap);
|
||||
return resultVO;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.dbnt.kcscbackend.admin.standards.entity;
|
||||
|
||||
import com.dbnt.kcscbackend.config.common.BoardParams;
|
||||
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;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Accessors(chain = true)
|
||||
@Entity
|
||||
@NoArgsConstructor
|
||||
@DynamicInsert
|
||||
@DynamicUpdate
|
||||
@Table(name = "tn_api_key")
|
||||
public class TnApiKey extends BoardParams {
|
||||
@Id
|
||||
@Column(name = "user_id")
|
||||
private String userId;
|
||||
|
||||
@Column(name = "api_key")
|
||||
private String apiKey;
|
||||
|
||||
@Column(name = "idnty_yn")
|
||||
private String idntyYn;
|
||||
|
||||
@Column(name = "start_dt")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate startDt;
|
||||
|
||||
@Column(name = "end_dt")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate endDt;
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.dbnt.kcscbackend.admin.standards.repository;
|
||||
|
||||
import com.dbnt.kcscbackend.admin.standards.entity.TnApiKey;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ApiKeyRepository extends JpaRepository<TnApiKey, String> {
|
||||
List<TnApiKey> findAllByOrderByEndDtDesc();
|
||||
|
||||
@Query(value = "SELECT TO_CHAR(access_dt, 'YYYY-MM-DD') as log_dt, count(1) as log_cnt "
|
||||
+ "FROM th_api_log "
|
||||
+ "WHERE access_id = :UserId "
|
||||
+ "GROUP BY TO_CHAR(access_dt, 'YYYY-MM-DD') "
|
||||
+ "ORDER BY log_dt asc", nativeQuery = true)
|
||||
List<Object[]> selectCountApiDaily(@Param("UserId") String UserId);
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package com.dbnt.kcscbackend.admin.standards.service;
|
||||
|
||||
import com.dbnt.kcscbackend.admin.standards.entity.TnApiKey;
|
||||
import com.dbnt.kcscbackend.admin.standards.repository.ApiKeyRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AdminApiService extends EgovAbstractServiceImpl {
|
||||
private final ApiKeyRepository apiKeyRepository;
|
||||
|
||||
public Map<String, Object> selectApiList() {
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
|
||||
long totalRecordCount = apiKeyRepository.count(); // 전체 레코드 수 가져오기
|
||||
List<TnApiKey> apiList = apiKeyRepository.findAllByOrderByEndDtDesc(); // 개인 정보 로그 리스트 가져오기
|
||||
|
||||
resultMap.put("resultCnt", String.valueOf(totalRecordCount)); // 개수를 resultMap에 추가
|
||||
resultMap.put("resultList", apiList); // 결과를 resultMap에 추가
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
public TnApiKey getApiKeyById(String userId) { return apiKeyRepository.findById(userId).orElse(null); }
|
||||
|
||||
@Transactional
|
||||
public String modifyApi(TnApiKey tnApiKey) {
|
||||
try {
|
||||
apiKeyRepository.save(tnApiKey);
|
||||
return "API key updated successfully";
|
||||
} catch (Exception e) {
|
||||
return "Failed to update API key";
|
||||
}
|
||||
}
|
||||
|
||||
public List<Object[]> selectApiDailyCount(String UserId) {
|
||||
return apiKeyRepository.selectCountApiDaily(UserId);
|
||||
} // 일자별 API 요청횟수
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
package com.dbnt.kcscbackend.commonCode.entity;
|
||||
|
||||
import lombok.*;
|
||||
import org.hibernate.annotations.DynamicInsert;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@NoArgsConstructor
|
||||
@DynamicInsert
|
||||
@DynamicUpdate
|
||||
@Table(name = "tn_research")
|
||||
public class TnResearch {
|
||||
|
||||
@Id
|
||||
@Column(name = "rs_seq")
|
||||
private Long rsSeq;
|
||||
|
||||
@Column(name = "rs_title")
|
||||
private String rsTitle;
|
||||
|
||||
@Column(name = "rs_start_date")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime rsStartDate;
|
||||
|
||||
@Column(name = "rs_end_date")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime rsEndDate;
|
||||
|
||||
@Column(name = "rs_director")
|
||||
private String rsDirector;
|
||||
|
||||
@Column(name = "rs_purpose")
|
||||
private String rsPurpose;
|
||||
|
||||
@Column(name = "rs_contents")
|
||||
private String rsContents;
|
||||
|
||||
@Column(name = "rs_effect")
|
||||
private String rsEffect;
|
||||
|
||||
@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;
|
||||
|
||||
|
||||
@Embeddable
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class TnResearchId implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 9042992093269088042L;
|
||||
|
||||
private String rsSeq;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
package com.dbnt.kcscbackend.commonCode.repository;
|
||||
|
||||
import com.dbnt.kcscbackend.commonCode.entity.TnResearch;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.jpa.repository.query.Procedure;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public interface TnResearchRepository extends JpaRepository<TnResearch, Long> {
|
||||
|
||||
@Query(value = "CALL sp_add_tn_research (" +
|
||||
":_rs_title, " +
|
||||
"TO_DATE(" +
|
||||
" :_rs_start_date," +
|
||||
" 'YYYYMMDDHH24MISS'" +
|
||||
"), " +
|
||||
"TO_DATE(" +
|
||||
" :_rs_end_date," +
|
||||
" 'YYYYMMDDHH24MISS'" +
|
||||
"), " +
|
||||
":_rs_director, " +
|
||||
":_rs_purpose, " +
|
||||
":_rs_contents, " +
|
||||
":_rs_effect, " +
|
||||
":_modi_id, " +
|
||||
":_result_count, " +
|
||||
":_result_code, " +
|
||||
":_error_message)",
|
||||
nativeQuery = true)
|
||||
Map<String, Object> spAddTnResearch(
|
||||
@Param("_rs_title") String rsTitle,
|
||||
@Param("_rs_start_date") String rsStartDate,
|
||||
@Param("_rs_end_date") String rsEndDate,
|
||||
@Param("_rs_director") String rsDirector,
|
||||
@Param("_rs_purpose") String rsPurpose,
|
||||
@Param("_rs_contents") String rsContents,
|
||||
@Param("_rs_effect") String rsEffect,
|
||||
@Param("_modi_id") String modiId,
|
||||
@Param("_result_count") Integer resultCount,
|
||||
@Param("_result_code") String resultCode,
|
||||
@Param("_error_message") String errorMessage
|
||||
);
|
||||
|
||||
|
||||
@Query(value = "CALL sp_update_tn_research (" +
|
||||
":_rs_seq, " +
|
||||
"TO_DATE(" +
|
||||
" :_rs_start_date," +
|
||||
" 'YYYYMMDDHH24MISS'" +
|
||||
"), " +
|
||||
"TO_DATE(" +
|
||||
" :_rs_end_date," +
|
||||
" 'YYYYMMDDHH24MISS'" +
|
||||
"), " +
|
||||
":_rs_director, " +
|
||||
":_rs_purpose, " +
|
||||
":_rs_contents, " +
|
||||
":_rs_effect, " +
|
||||
":_modi_id, " +
|
||||
":_result_count, " +
|
||||
":_result_code, " +
|
||||
":_error_message)",
|
||||
nativeQuery = true)
|
||||
Map<String, Object> spUpdateTnResearch(
|
||||
@Param("_rs_seq") Integer rsSeq,
|
||||
@Param("_rs_start_date") String rsStartDate,
|
||||
@Param("_rs_end_date") String rsEndDate,
|
||||
@Param("_rs_director") String rsDirector,
|
||||
@Param("_rs_purpose") String rsPurpose,
|
||||
@Param("_rs_contents") String rsContents,
|
||||
@Param("_rs_effect") String rsEffect,
|
||||
@Param("_modi_id") String modiId,
|
||||
@Param("_result_count") Integer resultCount,
|
||||
@Param("_result_code") String resultCode,
|
||||
@Param("_error_message") String errorMessage
|
||||
);
|
||||
|
||||
|
||||
@Query(value = "CALL sp_delete_tn_research (" +
|
||||
":_rs_seq, " +
|
||||
":_modi_id, " +
|
||||
":_result_count, " +
|
||||
":_result_code, " +
|
||||
":_error_message)",
|
||||
nativeQuery = true)
|
||||
Map<String, Object> spDeleteTnResearch(
|
||||
@Param("_rs_seq") Integer rsSeq,
|
||||
@Param("_modi_id") String modiId,
|
||||
@Param("_result_count") Integer resultCount,
|
||||
@Param("_result_code") String resultCode,
|
||||
@Param("_error_message") String errorMessage
|
||||
);
|
||||
|
||||
|
||||
|
||||
TnResearch findByRsSeq(Long rsSeq);
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue