게시물 관리 등록, 수정
parent
92b2b44d6e
commit
8ee3517f6b
|
|
@ -1,4 +1,4 @@
|
||||||
import React, {useState, useEffect, useRef} from 'react';
|
import React, {useState, useEffect, useRef, useCallback} from 'react';
|
||||||
import {Link, useNavigate, useLocation, useParams} from 'react-router-dom';
|
import {Link, useNavigate, useLocation, useParams} from 'react-router-dom';
|
||||||
import Modal from "react-bootstrap/Modal";
|
import Modal from "react-bootstrap/Modal";
|
||||||
|
|
||||||
|
|
@ -9,6 +9,7 @@ import CODE from 'constants/code';
|
||||||
import {default as EgovLeftNav} from 'components/leftmenu/EgovLeftNavAdmin';
|
import {default as EgovLeftNav} from 'components/leftmenu/EgovLeftNavAdmin';
|
||||||
import EgovRadioButtonGroup from 'components/EgovRadioButtonGroup';
|
import EgovRadioButtonGroup from 'components/EgovRadioButtonGroup';
|
||||||
import {Form} from "react-bootstrap";
|
import {Form} from "react-bootstrap";
|
||||||
|
import RichTextEditor from "../../../components/editor/RichTextEditor";
|
||||||
|
|
||||||
|
|
||||||
function AdminPostMgtEdit({props, reloadFunction}) {
|
function AdminPostMgtEdit({props, reloadFunction}) {
|
||||||
|
|
@ -30,7 +31,33 @@ function AdminPostMgtEdit({props, reloadFunction}) {
|
||||||
const [boardDetail, setBoardDetail] = useState({});
|
const [boardDetail, setBoardDetail] = useState({});
|
||||||
console.log("@@@ mode : " + modeInfo.mode);
|
console.log("@@@ mode : " + modeInfo.mode);
|
||||||
|
|
||||||
|
const [categoryList, setCategoryList] = useState([]);
|
||||||
|
|
||||||
|
const retrieveList = useCallback(() => {
|
||||||
|
const retrieveListURL = '/admin/boards/get-category-list';
|
||||||
|
|
||||||
|
const requestOptions = {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
'Content-type': 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify()
|
||||||
|
}
|
||||||
|
|
||||||
|
EgovNet.requestFetch(retrieveListURL,
|
||||||
|
requestOptions,
|
||||||
|
(resp) => {
|
||||||
|
setCategoryList(resp.result.categoryList);
|
||||||
|
console.log("@@@ categoryList : " + JSON.stringify(resp.result.categoryList));
|
||||||
|
},
|
||||||
|
function (resp) {
|
||||||
|
console.log("err response : ", resp);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},[]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
retrieveList();
|
||||||
initMode();
|
initMode();
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
|
|
@ -41,22 +68,24 @@ function AdminPostMgtEdit({props, reloadFunction}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function editPartnerSite(e) {
|
function editPost(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const form = e.target;
|
const form = e.target;
|
||||||
const info = {
|
const info = {
|
||||||
siteTitle: form.siteTitle.value,
|
fixedYn: defaultFixedYn,
|
||||||
siteUrl: form.siteUrl.value,
|
secretYn: defaultSecretYn,
|
||||||
|
bbsId: form.bbsId.value,
|
||||||
|
bbsSeq: selectedBbsSeq,
|
||||||
|
bbsContTitle: form.bbsContTitle.value,
|
||||||
fileGrpId: form.fileGrpId.value,
|
fileGrpId: form.fileGrpId.value,
|
||||||
siteOrder: form.siteOrder.value,
|
bbsContents: text
|
||||||
useYn: form.useYn.value
|
|
||||||
}
|
}
|
||||||
if (modeInfo.mode === CODE.MODE_MODIFY) {
|
if (modeInfo.mode === CODE.MODE_MODIFY) {
|
||||||
info.siteSeq = props.siteSeq;
|
info.bbsContSeq = props.bbsContSeq;
|
||||||
}
|
}
|
||||||
EgovNet.requestFetch(
|
EgovNet.requestFetch(
|
||||||
'/admin/config/partner-site-mgt',
|
'/admin/boards/post-mgt',
|
||||||
{
|
{
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
headers: {
|
headers: {
|
||||||
|
|
@ -77,16 +106,16 @@ function AdminPostMgtEdit({props, reloadFunction}) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function deletePartnerSite(partnerSite){
|
function deletePost(post){
|
||||||
if(window.confirm("삭제하시겠습니까?")) {
|
if(window.confirm("삭제하시겠습니까?")) {
|
||||||
EgovNet.requestFetch(
|
EgovNet.requestFetch(
|
||||||
'/admin/config/partner-site-mgt',
|
'/admin/boards/post-mgt',
|
||||||
{
|
{
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers: {
|
headers: {
|
||||||
'Content-type': 'application/json'
|
'Content-type': 'application/json'
|
||||||
},
|
},
|
||||||
body: JSON.stringify(partnerSite)
|
body: JSON.stringify(post)
|
||||||
},
|
},
|
||||||
(resp) => {
|
(resp) => {
|
||||||
if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) {
|
if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) {
|
||||||
|
|
@ -106,9 +135,25 @@ function AdminPostMgtEdit({props, reloadFunction}) {
|
||||||
console.groupEnd("AdminPostMgtEdit");
|
console.groupEnd("AdminPostMgtEdit");
|
||||||
|
|
||||||
const [defaultFixedYn, setDefaultFixedYn] = useState(props?.fixedYn || "N");
|
const [defaultFixedYn, setDefaultFixedYn] = useState(props?.fixedYn || "N");
|
||||||
|
const [defaultSecretYn, setDefaultSecretYn] = useState(props?.secretYn || "N");
|
||||||
|
const [text, setText] = useState(props?.bbsContents);
|
||||||
|
const [selectedBbsSeq, setSelectedBbsSeq] = useState(null);
|
||||||
|
|
||||||
|
const handleSelectChange = (e) => {
|
||||||
|
const selectedBbsId = e.target.value;
|
||||||
|
const selectedOption = categoryList.find((item) => item.bbsId === selectedBbsId);
|
||||||
|
setSelectedBbsSeq(selectedOption.bbsSeq);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<style>
|
||||||
|
{`
|
||||||
|
.modal-dialog {
|
||||||
|
max-width: 50%;
|
||||||
|
}
|
||||||
|
`}
|
||||||
|
</style>
|
||||||
{/* <!-- 본문 --> */}
|
{/* <!-- 본문 --> */}
|
||||||
<Modal.Header closeButton>
|
<Modal.Header closeButton>
|
||||||
<Modal.Title>
|
<Modal.Title>
|
||||||
|
|
@ -119,13 +164,13 @@ function AdminPostMgtEdit({props, reloadFunction}) {
|
||||||
|
|
||||||
<Modal.Body>
|
<Modal.Body>
|
||||||
<div className="board_view2">
|
<div className="board_view2">
|
||||||
<Form onSubmit={(e) => {editPartnerSite(e)}} noValidate>
|
<Form onSubmit={(e) => {editPost(e)}} noValidate>
|
||||||
<dl>
|
<dl>
|
||||||
<dt><label htmlFor="siteTitle">상단고정</label><span className="req">필수</span></dt>
|
<dt><label htmlFor="siteTitle">상단고정</label><span className="req">필수</span></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<Form.Check
|
<Form.Check
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
id="siteTitleCheckbox"
|
id="fixedYnCheckbox"
|
||||||
label="상단고정"
|
label="상단고정"
|
||||||
checked={defaultFixedYn === 'Y'}
|
checked={defaultFixedYn === 'Y'}
|
||||||
onChange={(e) => setDefaultFixedYn(e.target.checked ? 'Y' : 'N')}
|
onChange={(e) => setDefaultFixedYn(e.target.checked ? 'Y' : 'N')}
|
||||||
|
|
@ -135,29 +180,44 @@ function AdminPostMgtEdit({props, reloadFunction}) {
|
||||||
<dl>
|
<dl>
|
||||||
<dt><label htmlFor="siteTitle">비밀글</label><span className="req">필수</span></dt>
|
<dt><label htmlFor="siteTitle">비밀글</label><span className="req">필수</span></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<Form.Control className="f_input2 w_full" type="text" name="siteTitle" placeholder="비밀글" required
|
<Form.Check
|
||||||
defaultValue={props?.siteTitle} readOnly={props!==undefined}/>
|
type="checkbox"
|
||||||
|
id="secretYnCheckbox"
|
||||||
|
label="비밀글"
|
||||||
|
checked={defaultSecretYn === 'Y'}
|
||||||
|
onChange={(e) => setDefaultSecretYn(e.target.checked ? 'Y' : 'N')}
|
||||||
|
/>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
<dl>
|
||||||
|
<dt><label htmlFor="siteTitle">카테고리</label><span className="req">필수</span></dt>
|
||||||
|
<dd>
|
||||||
|
<Form.Select id="select1" name="bbsId" onChange={handleSelectChange}>
|
||||||
|
<option value="">선택</option>
|
||||||
|
{categoryList.map((item) => (
|
||||||
|
<option key={item.bbsSeq} value={item.bbsId} selected={props?.bbsId === item.bbsId}>{item.bbsTitle}</option>
|
||||||
|
))}
|
||||||
|
</Form.Select>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<dl>
|
<dl>
|
||||||
<dt><label htmlFor="siteTitle">제목</label><span className="req">필수</span></dt>
|
<dt><label htmlFor="siteTitle">제목</label><span className="req">필수</span></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<Form.Control className="f_input2 w_full" type="text" name="siteTitle" placeholder="제목" required
|
<Form.Control className="f_input2 w_full" type="text" name="bbsContTitle" placeholder="제목" required
|
||||||
defaultValue={props?.siteTitle} readOnly={props!==undefined}/>
|
defaultValue={props?.bbsContTitle}/>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<dl>
|
<dl>
|
||||||
<dt><label htmlFor="siteUrl">파일</label><span className="req">필수</span></dt>
|
<dt><label htmlFor="siteUrl">파일</label><span className="req">필수</span></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<Form.Control className="f_input2 w_full" type="text" name="siteUrl" placeholder="파일" required
|
<Form.Control className="f_input2 w_full" type="text" name="fileGrpId" placeholder="파일" required
|
||||||
defaultValue={props?.siteUrl}/>
|
defaultValue={props?.fileGrpId}/>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<dl>
|
<dl>
|
||||||
<dt><label htmlFor="fileGrpId">내용</label><span className="req">필수</span></dt>
|
<dt><label htmlFor="fileGrpId">내용</label><span className="req">필수</span></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<Form.Control className="f_txtar w_full" type="text" name="fileGrpId" placeholder="내용" required
|
<RichTextEditor item={text} setText={setText}/>
|
||||||
defaultValue={props?.fileGrpId}/>
|
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
|
|
@ -167,7 +227,7 @@ function AdminPostMgtEdit({props, reloadFunction}) {
|
||||||
<button type="submit" className="btn btn_skyblue_h46 w_100">저장
|
<button type="submit" className="btn btn_skyblue_h46 w_100">저장
|
||||||
</button>
|
</button>
|
||||||
{modeInfo.mode === CODE.MODE_MODIFY &&
|
{modeInfo.mode === CODE.MODE_MODIFY &&
|
||||||
<button type={"button"} className="btn btn_skyblue_h46 w_100" onClick={()=>{deletePartnerSite(props)}}>삭제</button>
|
<button type={"button"} className="btn btn_skyblue_h46 w_100" onClick={()=>{deletePost(props)}}>삭제</button>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import CODE from "../../../constants/code";
|
||||||
import AboutSiteModal from "../config/aboutSiteMgt/AboutSiteModal";
|
import AboutSiteModal from "../config/aboutSiteMgt/AboutSiteModal";
|
||||||
import AdminPostMgtEdit from "./AdminPostMgtEdit";
|
import AdminPostMgtEdit from "./AdminPostMgtEdit";
|
||||||
import Modal from "react-bootstrap/Modal";
|
import Modal from "react-bootstrap/Modal";
|
||||||
|
import {format} from "date-fns";
|
||||||
|
|
||||||
function AdminPostMgtList(props) {
|
function AdminPostMgtList(props) {
|
||||||
console.group("EgovAdminPostList");
|
console.group("EgovAdminPostList");
|
||||||
|
|
@ -36,6 +37,7 @@ function AdminPostMgtList(props) {
|
||||||
const handleShow = () => setShow(true);
|
const handleShow = () => setShow(true);
|
||||||
|
|
||||||
const retrieveList = useCallback(() => {
|
const retrieveList = useCallback(() => {
|
||||||
|
handleClose();
|
||||||
console.groupCollapsed("EgovAdminPostList.retrieveList()");
|
console.groupCollapsed("EgovAdminPostList.retrieveList()");
|
||||||
|
|
||||||
const retrieveListURL = '/admin/boards/post-list';
|
const retrieveListURL = '/admin/boards/post-list';
|
||||||
|
|
@ -60,15 +62,18 @@ function AdminPostMgtList(props) {
|
||||||
// 리스트 항목 구성
|
// 리스트 항목 구성
|
||||||
resp.result.postList.forEach(function (item, index) {
|
resp.result.postList.forEach(function (item, index) {
|
||||||
if (index === 0) mutListTag = []; // 목록 초기화
|
if (index === 0) mutListTag = []; // 목록 초기화
|
||||||
|
const finalModifiedDate = item.lastChgDt ? item.lastChgDt : item.frstCrtDt;
|
||||||
|
const formattedDate = finalModifiedDate ? format(finalModifiedDate, "yyyy-MM-dd HH:mm") : "";
|
||||||
|
|
||||||
mutListTag.push(
|
mutListTag.push(
|
||||||
<div className="list_item">
|
<div className="list_item">
|
||||||
<div>{item.bbsContSeq}</div>
|
<div></div>
|
||||||
<div>{item.bbsSeq}</div>
|
|
||||||
<div>{item.bbsContTitle}</div>
|
<div>{item.bbsContTitle}</div>
|
||||||
<div>{item.bbsContents}</div>
|
<div>{item.frstCrtId}</div>
|
||||||
|
<div>{formattedDate}</div>
|
||||||
<div>{item.bbsReadCnt}</div>
|
<div>{item.bbsReadCnt}</div>
|
||||||
<div>{item.bbsContLevel}</div>
|
<div>{item.fileGrpId}</div>
|
||||||
|
<div><button className={"btn btn_blue_h31 px-1"} onClick={()=>{editPost(item)}}>수정</button></div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
@ -153,9 +158,6 @@ function AdminPostMgtList(props) {
|
||||||
}}>조회</button>
|
}}>조회</button>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
<Link to={URL.ADMIN_BOARD_CREATE} className="btn btn_blue_h46 pd35">등록</Link>
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
{/* <!--// 검색조건 --> */}
|
{/* <!--// 검색조건 --> */}
|
||||||
|
|
@ -166,7 +168,7 @@ function AdminPostMgtList(props) {
|
||||||
<span></span>
|
<span></span>
|
||||||
<span>제목</span>
|
<span>제목</span>
|
||||||
<span>작성자</span>
|
<span>작성자</span>
|
||||||
<span>작성일</span>
|
<span>최종수정일</span>
|
||||||
<span>조회수</span>
|
<span>조회수</span>
|
||||||
<span>파일</span>
|
<span>파일</span>
|
||||||
<span><button className={"btn btn_blue_h31 px-1"} onClick={()=>{editPost(undefined)}}>추가</button></span>
|
<span><button className={"btn btn_blue_h31 px-1"} onClick={()=>{editPost(undefined)}}>추가</button></span>
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,7 @@ function EgovAdminBoardEdit({props, reloadFunction}) {
|
||||||
<dd>
|
<dd>
|
||||||
<Form.Check
|
<Form.Check
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
id="siteTitleCheckbox"
|
id="bbsAnsYnCheckbox"
|
||||||
label="사용"
|
label="사용"
|
||||||
checked={bbsAnsYn === 'Y'}
|
checked={bbsAnsYn === 'Y'}
|
||||||
onChange={(e) => setBbsAnsYn(e.target.checked ? 'Y' : 'N')}
|
onChange={(e) => setBbsAnsYn(e.target.checked ? 'Y' : 'N')}
|
||||||
|
|
@ -203,7 +203,7 @@ function EgovAdminBoardEdit({props, reloadFunction}) {
|
||||||
<dd>
|
<dd>
|
||||||
<Form.Check
|
<Form.Check
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
id="siteTitleCheckbox"
|
id="bbsReplYnCheckbox"
|
||||||
label="사용"
|
label="사용"
|
||||||
checked={bbsReplYn === 'Y'}
|
checked={bbsReplYn === 'Y'}
|
||||||
onChange={(e) => setBbsReplYn(e.target.checked ? 'Y' : 'N')}
|
onChange={(e) => setBbsReplYn(e.target.checked ? 'Y' : 'N')}
|
||||||
|
|
@ -215,7 +215,7 @@ function EgovAdminBoardEdit({props, reloadFunction}) {
|
||||||
<dd>
|
<dd>
|
||||||
<Form.Check
|
<Form.Check
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
id="siteTitleCheckbox"
|
id="useYnCheckbox"
|
||||||
label="사용"
|
label="사용"
|
||||||
checked={useYn === 'Y'}
|
checked={useYn === 'Y'}
|
||||||
onChange={(e) => setUseYn(e.target.checked ? 'Y' : 'N')}
|
onChange={(e) => setUseYn(e.target.checked ? 'Y' : 'N')}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.dbnt.kcscbackend.admin.boards;
|
package com.dbnt.kcscbackend.admin.boards;
|
||||||
|
|
||||||
import com.dbnt.kcscbackend.admin.boards.entity.TnBbs;
|
import com.dbnt.kcscbackend.admin.boards.entity.TnBbs;
|
||||||
|
import com.dbnt.kcscbackend.admin.boards.entity.TnBbsContents;
|
||||||
import com.dbnt.kcscbackend.admin.boards.service.AdminBoardsService;
|
import com.dbnt.kcscbackend.admin.boards.service.AdminBoardsService;
|
||||||
import com.dbnt.kcscbackend.admin.config.entity.TcMenu;
|
import com.dbnt.kcscbackend.admin.config.entity.TcMenu;
|
||||||
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
||||||
|
|
@ -9,6 +10,7 @@ import com.dbnt.kcscbackend.commonCode.service.CommonCodeService;
|
||||||
import com.dbnt.kcscbackend.config.common.BaseController;
|
import com.dbnt.kcscbackend.config.common.BaseController;
|
||||||
import com.dbnt.kcscbackend.config.common.ResponseCode;
|
import com.dbnt.kcscbackend.config.common.ResponseCode;
|
||||||
import com.dbnt.kcscbackend.config.common.ResultVO;
|
import com.dbnt.kcscbackend.config.common.ResultVO;
|
||||||
|
import com.dbnt.kcscbackend.config.util.ClientUtils;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||||
|
|
@ -23,6 +25,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -118,7 +122,7 @@ public class AdminBoardsController extends BaseController {
|
||||||
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||||
})
|
})
|
||||||
@RequestMapping(method = RequestMethod.DELETE, value = "/board-mgt")
|
@RequestMapping(method = RequestMethod.DELETE, value = "/board-mgt")
|
||||||
public ResultVO removeBoardMgt(@RequestBody TnBbs bbs, @AuthenticationPrincipal LoginVO user) {
|
public ResultVO deleteBoardMgt(@RequestBody TnBbs bbs, @AuthenticationPrincipal LoginVO user) {
|
||||||
ResultVO resultVO = new ResultVO();
|
ResultVO resultVO = new ResultVO();
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
resultVO.setResultCode(ResponseCode.TOKEN_EXPIRED.getCode());
|
resultVO.setResultCode(ResponseCode.TOKEN_EXPIRED.getCode());
|
||||||
|
|
@ -154,4 +158,83 @@ public class AdminBoardsController extends BaseController {
|
||||||
return resultVO;
|
return resultVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "게시물 카테고리 셀렉트박스 옵션 조회",
|
||||||
|
description = "게시물 카테고리 셀렉트박스 옵션 조회",
|
||||||
|
tags = {"AdminBoardsController"}
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(responseCode = "200", description = "조회 성공"),
|
||||||
|
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||||
|
})
|
||||||
|
@RequestMapping(method = RequestMethod.GET, value = "/get-category-list", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
public ResultVO getCategoryList() throws Exception {
|
||||||
|
ResultVO resultVO = new ResultVO();
|
||||||
|
Map<String, Object> resultMap = new HashMap<>();
|
||||||
|
|
||||||
|
resultMap.put("categoryList", adminBoardsService.selectBoardList());
|
||||||
|
resultVO.setResult(resultMap);
|
||||||
|
return resultVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "게시물 저장",
|
||||||
|
description = "게시물 저장",
|
||||||
|
tags = {"AdminBoardsController"}
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(responseCode = "200", description = "저장 성공"),
|
||||||
|
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||||
|
})
|
||||||
|
@RequestMapping(method = RequestMethod.PUT, value = "/post-mgt")
|
||||||
|
public ResultVO savePostMgt(@RequestBody @Valid TnBbsContents contents, HttpServletRequest request, 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("@@@ contents.getBbsSeq() : " + contents.getBbsContSeq());
|
||||||
|
contents.setIpAddress(ClientUtils.getRemoteIP(request));
|
||||||
|
adminBoardsService.savePost(contents, user.getId());
|
||||||
|
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "게시판 삭제",
|
||||||
|
description = "게시판 삭제",
|
||||||
|
tags = {"AdminBoardsController"}
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(responseCode = "200", description = "삭제 성공"),
|
||||||
|
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||||
|
})
|
||||||
|
@RequestMapping(method = RequestMethod.DELETE, value = "/post-mgt")
|
||||||
|
public ResultVO deletePostMgt(@RequestBody TnBbsContents contents, HttpServletRequest request, @AuthenticationPrincipal LoginVO user) {
|
||||||
|
ResultVO resultVO = new ResultVO();
|
||||||
|
if (user == null) {
|
||||||
|
resultVO.setResultCode(ResponseCode.TOKEN_EXPIRED.getCode());
|
||||||
|
} else {
|
||||||
|
contents.setIpAddress(ClientUtils.getRemoteIP(request));
|
||||||
|
String result = adminBoardsService.deletePost(contents, 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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,10 @@ public class TnBbsContents {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "bbs_cont_seq")
|
@Column(name = "bbs_cont_seq")
|
||||||
private Integer bbsContSeq;
|
private Long bbsContSeq;
|
||||||
|
|
||||||
@Column(name = "bbs_seq", nullable = false)
|
@Column(name = "bbs_seq", nullable = false)
|
||||||
private Integer bbsSeq;
|
private Long bbsSeq;
|
||||||
|
|
||||||
@Column(name = "bbs_cont_title")
|
@Column(name = "bbs_cont_title")
|
||||||
private String bbsContTitle;
|
private String bbsContTitle;
|
||||||
|
|
@ -31,22 +31,22 @@ public class TnBbsContents {
|
||||||
private String bbsContents;
|
private String bbsContents;
|
||||||
|
|
||||||
@Column(name = "bbs_cont_seq_group")
|
@Column(name = "bbs_cont_seq_group")
|
||||||
private Integer bbsContSeqGroup;
|
private Long bbsContSeqGroup;
|
||||||
|
|
||||||
@Column(name = "bbs_cont_seq_parent")
|
@Column(name = "bbs_cont_seq_parent")
|
||||||
private Integer bbsContSeqParent;
|
private Long bbsContSeqParent;
|
||||||
|
|
||||||
@Column(name = "bbs_cont_level", nullable = false)
|
@Column(name = "bbs_cont_level", nullable = false)
|
||||||
private Integer bbsContLevel;
|
private Long bbsContLevel;
|
||||||
|
|
||||||
@Column(name = "bbs_cont_sort")
|
@Column(name = "bbs_cont_sort")
|
||||||
private Integer bbsContSort;
|
private Long bbsContSort;
|
||||||
|
|
||||||
@Column(name = "file_grp_id")
|
@Column(name = "file_grp_id")
|
||||||
private String fileGrpId;
|
private String fileGrpId;
|
||||||
|
|
||||||
@Column(name = "bbs_read_cnt", nullable = false)
|
@Column(name = "bbs_read_cnt", nullable = false)
|
||||||
private Integer bbsReadCnt;
|
private Long bbsReadCnt;
|
||||||
|
|
||||||
@Column(name = "fixed_yn", nullable = false)
|
@Column(name = "fixed_yn", nullable = false)
|
||||||
private String fixedYn;
|
private String fixedYn;
|
||||||
|
|
@ -58,7 +58,7 @@ public class TnBbsContents {
|
||||||
private String secretPwd;
|
private String secretPwd;
|
||||||
|
|
||||||
@Column(name = "doc_info_seq")
|
@Column(name = "doc_info_seq")
|
||||||
private Integer docInfoSeq;
|
private Long docInfoSeq;
|
||||||
|
|
||||||
@Column(name = "ip_address", nullable = false)
|
@Column(name = "ip_address", nullable = false)
|
||||||
private String ipAddress;
|
private String ipAddress;
|
||||||
|
|
@ -79,5 +79,8 @@ public class TnBbsContents {
|
||||||
private String useYn;
|
private String useYn;
|
||||||
|
|
||||||
@Column(name = "old_seq")
|
@Column(name = "old_seq")
|
||||||
private Integer oldSeq;
|
private Long oldSeq;
|
||||||
|
|
||||||
|
@Column(name = "bbs_id")
|
||||||
|
private String bbsId;
|
||||||
}
|
}
|
||||||
|
|
@ -2,7 +2,17 @@ package com.dbnt.kcscbackend.admin.boards.repository;
|
||||||
|
|
||||||
import com.dbnt.kcscbackend.admin.boards.entity.TnBbsContents;
|
import com.dbnt.kcscbackend.admin.boards.entity.TnBbsContents;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
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 TnBbsContentsRepository extends JpaRepository<TnBbsContents, Long> {
|
public interface TnBbsContentsRepository extends JpaRepository<TnBbsContents, Long> {
|
||||||
|
|
||||||
|
@Query(value = "SELECT entity FROM TnBbsContents entity " +
|
||||||
|
"WHERE entity.useYn = 'Y' " +
|
||||||
|
"AND entity.bbsId = :bbsId " +
|
||||||
|
"ORDER BY entity.bbsContSeq DESC")
|
||||||
|
List<TnBbsContents> findByBbsId(@Param("bbsId") String bbsId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,11 @@ package com.dbnt.kcscbackend.admin.boards.repository;
|
||||||
|
|
||||||
import com.dbnt.kcscbackend.admin.boards.entity.TnBbs;
|
import com.dbnt.kcscbackend.admin.boards.entity.TnBbs;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface TnBbsRepository extends JpaRepository<TnBbs, Long> {
|
public interface TnBbsRepository extends JpaRepository<TnBbs, Long> {
|
||||||
|
|
||||||
@Query(value = "SELECT * FROM tn_bbs ORDER BY bbs_seq DESC", nativeQuery = true)
|
|
||||||
List<TnBbs> findAllByOrderByBbsSeqDesc();
|
List<TnBbs> findAllByOrderByBbsSeqDesc();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,6 @@ public class AdminBoardsService extends EgovAbstractServiceImpl {
|
||||||
return tnBbsRepository.findAllByOrderByBbsSeqDesc();
|
return tnBbsRepository.findAllByOrderByBbsSeqDesc();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<TnBbs> selectBoard(Long bbsSeq) {
|
|
||||||
return tnBbsRepository.findById(bbsSeq);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void saveBoard(TnBbs bbs, String userId) {
|
public void saveBoard(TnBbs bbs, String userId) {
|
||||||
if (bbs.getBbsSeq() == null) {
|
if (bbs.getBbsSeq() == null) {
|
||||||
|
|
@ -70,4 +66,45 @@ public class AdminBoardsService extends EgovAbstractServiceImpl {
|
||||||
return tnBbsContentsRepository.findAll();
|
return tnBbsContentsRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void savePost(TnBbsContents contents, String userId) {
|
||||||
|
if (contents.getBbsContSeq() == null) {
|
||||||
|
// TODO 하드코딩
|
||||||
|
contents.setBbsContLevel(1L);
|
||||||
|
contents.setBbsReadCnt(0L);
|
||||||
|
contents.setUseYn("Y");
|
||||||
|
contents.setFrstCrtDt(LocalDateTime.now());
|
||||||
|
contents.setFrstCrtId(userId);
|
||||||
|
tnBbsContentsRepository.save(contents);
|
||||||
|
} else {
|
||||||
|
TnBbsContents savedPost = tnBbsContentsRepository.findById(contents.getBbsContSeq()).orElse(null);
|
||||||
|
savedPost.setFixedYn(contents.getFixedYn());
|
||||||
|
savedPost.setSecretYn(contents.getSecretYn());
|
||||||
|
savedPost.setBbsId(contents.getBbsId());
|
||||||
|
savedPost.setBbsContTitle(contents.getBbsContTitle());
|
||||||
|
savedPost.setFileGrpId(contents.getFileGrpId());
|
||||||
|
savedPost.setBbsContents(contents.getBbsContents());
|
||||||
|
savedPost.setIpAddress(contents.getIpAddress());
|
||||||
|
savedPost.setUseYn("Y");
|
||||||
|
savedPost.setLastChgId(userId);
|
||||||
|
savedPost.setLastChgDt(LocalDateTime.now());
|
||||||
|
tnBbsContentsRepository.save(savedPost);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public String deletePost(TnBbsContents contents, String userId) {
|
||||||
|
TnBbsContents savedPost = tnBbsContentsRepository.findById(contents.getBbsContSeq()).orElse(null);
|
||||||
|
if (savedPost == null) {
|
||||||
|
return "notFind";
|
||||||
|
} else {
|
||||||
|
savedPost.setIpAddress(contents.getIpAddress());
|
||||||
|
savedPost.setUseYn("N");
|
||||||
|
savedPost.setLastChgDt(LocalDateTime.now());
|
||||||
|
savedPost.setLastChgId(userId);
|
||||||
|
tnBbsContentsRepository.save(savedPost);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue