게시판 작업중

thkim
유민형 2024-06-24 17:59:36 +09:00
parent 1406047290
commit a8e435876b
3 changed files with 105 additions and 13 deletions

View File

@ -1,5 +1,5 @@
import React, { useState } from 'react'; import React, {useCallback, useEffect, useState} from 'react';
import {Link, useNavigate} from 'react-router-dom'; import {Link, useLocation, useNavigate, useParams} from 'react-router-dom';
import * as EgovNet from 'api/egovFetch'; import * as EgovNet from 'api/egovFetch';
import URL from 'constants/url'; import URL from 'constants/url';
@ -7,6 +7,8 @@ import URL from 'constants/url';
import Row from 'react-bootstrap/Row'; import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col'; import Col from 'react-bootstrap/Col';
import Button from 'react-bootstrap/Button'; import Button from 'react-bootstrap/Button';
import {format} from "date-fns";
import EgovPaging from "../../components/EgovPaging";
function List(){ function List(){
const navigate = useNavigate(); const navigate = useNavigate();
@ -14,6 +16,89 @@ function List(){
const goToCreate = () => { const goToCreate = () => {
navigate('/support/create/KCSC-QA'); navigate('/support/create/KCSC-QA');
}; };
const location = useLocation();
const {BbsCode} = useParams();
const [searchCondition, setSearchCondition] = useState(location.state?.searchCondition || { pageIndex: 1, searchCnd: '0', searchKeyword: '', bbsId:BbsCode });// ||
const [paginationInfo, setPaginationInfo] = useState({});
const [listTag, setListTag] = useState([]);
const [categoryList, setCategoryList] = useState([]);
const [show, setShow] = useState(false);
const [modalBody, setModalBody] = useState();
const handleClose = () => setShow(false);
const handleShow = () => setShow(true);
console.log("@@@ BbsCode : " + BbsCode);
const retrieveList = useCallback((searchCondition) => {
handleClose();
const params = EgovNet.convParams(searchCondition);
console.groupCollapsed("EgovAdminPostList.retrieveList()");
const retrieveListURL = '/admin/boards/posts/post-list' + params;
const requestOptions = {
method: "GET",
headers: {
'Content-type': 'application/json',
}
}
EgovNet.requestFetch(retrieveListURL,
requestOptions,
(resp) => {
setPaginationInfo(resp.result.paginationInfo);
setCategoryList(resp.result.categoryList);
console.log("@@@ resultCnt : " + resp.result.resultCnt);
let mutListTag = [];
setListTag([]);
resp.result.fixedList.forEach(function (item) {
const finalModifiedDate = item?.lastChgDt ? item?.lastChgDt : item?.frstCrtDt;
const formattedDate = finalModifiedDate ? format(finalModifiedDate, "yyyy-MM-dd") : "";
mutListTag.push(
<div className="list_item">
<div>공지</div>
<div className="al">{item?.bbsContTitle}</div>
<div>{item?.frstCrtId}</div>
<div>{item?.bbsReadCnt}</div>
<div>{formattedDate}</div>
<div>{item?.fileGrpId && <img src="/assets/images/file.png" />}</div>
</div>
);
});
resp.result.postList.forEach(function (item, index) {
const finalModifiedDate = item?.lastChgDt ? item?.lastChgDt : item?.frstCrtDt;
const formattedDate = finalModifiedDate ? format(finalModifiedDate, "yyyy-MM-dd") : "";
mutListTag.push(
<div className="list_item">
<div>{resp.result.resultCnt - (resp.result.paginationInfo.pageIndex -1) * resp.result.paginationInfo.rowCnt - index}</div>
<div className="al">{item?.bbsContTitle}</div>
<div>{item?.frstCrtId}</div>
<div>{item?.bbsReadCnt}</div>
<div>{formattedDate}</div>
<div>{item?.fileGrpId && <img src="/assets/images/file.png" />}</div>
</div>
);
});
if(!mutListTag.length) mutListTag.push(<p className="no_data" key="0">검색된 결과가 없습니다.</p>); //
setListTag(mutListTag);
},
function (resp) {
console.log("err response : ", resp);
}
);
console.groupEnd("EgovAdminPostList.retrieveList()");
},[listTag]);
useEffect(() => {
retrieveList(searchCondition);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [searchCondition]);
return ( return (
@ -72,7 +157,8 @@ function List(){
{/* <p className="no_data" key="0">검색된 결과가 없습니다.</p> */} {/* <p className="no_data" key="0">검색된 결과가 없습니다.</p> */}
{/* <!-- case : 데이터 있을때 --> */} {/* <!-- case : 데이터 있을때 --> */}
<Link to={URL.SUPPORT_DETAIL_NOCODE+'/KCSC-NTC'} className="list_item"> {listTag}
{/*<Link to={URL.SUPPORT_DETAIL_NOCODE+'/KCSC-NTC'} className="list_item">
<div>3</div> <div>3</div>
<div className="al">[공지] 공통컴포넌트 모니터링 관련 서비스 실행시 오류가 발생합니다 [15] <img src="/assets/images/lock.png" className="pt-1" /> <img src="/assets/images/new.png" className="pt-1" /></div> <div className="al">[공지] 공통컴포넌트 모니터링 관련 서비스 실행시 오류가 발생합니다 [15] <img src="/assets/images/lock.png" className="pt-1" /> <img src="/assets/images/new.png" className="pt-1" /></div>
<div>관리자</div> <div>관리자</div>
@ -91,16 +177,16 @@ function List(){
<Link to={URL.SUPPORT_DETAIL_NOCODE+'/KCSC-NTC'} className="list_item"> <Link to={URL.SUPPORT_DETAIL_NOCODE+'/KCSC-NTC'} className="list_item">
<div>1</div> <div>1</div>
<div className="al d-flex align-items-center"> <div className="al d-flex align-items-center">
{/*미답변시 아이콘*/} 미답변시 아이콘
<img src="/assets/images/icon_answer0.png" className="pt-1 h_30 pb-1" /> &nbsp; <img src="/assets/images/icon_answer0.png" className="pt-1 h_30 pb-1" /> &nbsp;
{/*답변완료시 아이콘*/} 답변완료시 아이콘
{/*<img src="/assets/images/icon_answer.png" className="pt-1 h_30 pb-1" /> &nbsp;*/} <img src="/assets/images/icon_answer.png" className="pt-1 h_30 pb-1" /> &nbsp;
공통컴포넌트 모니터링 관련 서비스 실행시 오류가 발생합니다.</div> 공통컴포넌트 모니터링 관련 서비스 실행시 오류가 발생합니다.</div>
<div>홍길동</div> <div>홍길동</div>
<div>3</div> <div>3</div>
<div>2021-7-24</div> <div>2021-7-24</div>
<div></div> <div></div>
</Link> </Link>*/}
</div> </div>
</div> </div>
{/* <!--// 게시판목록 --> */} {/* <!--// 게시판목록 --> */}
@ -108,6 +194,9 @@ function List(){
<Row className="board_bot justify-content-between"> <Row className="board_bot justify-content-between">
<Col xs={3} className=""></Col> <Col xs={3} className=""></Col>
{/* <!-- Paging --> */} {/* <!-- Paging --> */}
<EgovPaging pagination={paginationInfo} moveToPage={passedPage => {
retrieveList({ ...searchCondition, pageIndex: passedPage}) //, searchCnd: cndRef.current.value, searchKeyword: wrdRef.current.value
}} />
<Col xs={6} className="paging"> <Col xs={6} className="paging">
<ul> <ul>
<li className="btn"><button to="" className="first">처음</button></li> <li className="btn"><button to="" className="first">처음</button></li>

View File

@ -171,15 +171,15 @@ public class AdminBoardsController extends BaseController {
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님") @ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
}) })
@RequestMapping(method = RequestMethod.GET, value = "/posts/post-list", consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(method = RequestMethod.GET, value = "/posts/post-list", consumes = MediaType.APPLICATION_JSON_VALUE)
public ResultVO getPostList(TnBbsContents params) throws Exception { public ResultVO getPostList(TnBbsContents tnBbsContents) throws Exception {
ResultVO resultVO = new ResultVO(); ResultVO resultVO = new ResultVO();
params.setQueryInfo(); tnBbsContents.setQueryInfo();
Map<String, Object> resultMap = adminBoardsService.selectPostList(params); Map<String, Object> resultMap = adminBoardsService.selectPostList(tnBbsContents);
resultMap.put("categoryList", adminBoardsService.selectBoardList()); resultMap.put("categoryList", adminBoardsService.selectBoardList());
int totCnt = Integer.parseInt((String)resultMap.get("resultCnt")); int totCnt = Integer.parseInt((String)resultMap.get("resultCnt"));
params.setContentCnt(totCnt); tnBbsContents.setContentCnt(totCnt);
params.setPaginationInfo(); tnBbsContents.setPaginationInfo();
resultMap.put("paginationInfo", params); resultMap.put("paginationInfo", tnBbsContents);
resultVO.setResult(resultMap); resultVO.setResult(resultMap);
return resultVO; return resultVO;
} }

View File

@ -52,6 +52,9 @@
<if test='searchKeyword != null and searchKeyword != ""'> <if test='searchKeyword != null and searchKeyword != ""'>
and bbs_cont_title like '%'||#{searchKeyword}||'%' and bbs_cont_title like '%'||#{searchKeyword}||'%'
</if> </if>
<if test='bbsId != null and bbsId != ""'>
and bbs_id = #{bbsId}
</if>
</where> </where>
</sql> </sql>
</mapper> </mapper>