From a8e435876b0445c1bfc88edfa2caefc0186cc87e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9C=A0=EB=AF=BC=ED=98=95?= Date: Mon, 24 Jun 2024 17:59:36 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B2=8C=EC=8B=9C=ED=8C=90=20=EC=9E=91?= =?UTF-8?q?=EC=97=85=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/support/List.jsx | 103 ++++++++++++++++-- .../admin/boards/AdminBoardsController.java | 12 +- .../mybatisMapper/AdminBoardsMapper.xml | 3 + 3 files changed, 105 insertions(+), 13 deletions(-) diff --git a/egovframe-template-simple-react-contribution/src/pages/support/List.jsx b/egovframe-template-simple-react-contribution/src/pages/support/List.jsx index 95668b1..99a6a88 100644 --- a/egovframe-template-simple-react-contribution/src/pages/support/List.jsx +++ b/egovframe-template-simple-react-contribution/src/pages/support/List.jsx @@ -1,5 +1,5 @@ -import React, { useState } from 'react'; -import {Link, useNavigate} from 'react-router-dom'; +import React, {useCallback, useEffect, useState} from 'react'; +import {Link, useLocation, useNavigate, useParams} from 'react-router-dom'; import * as EgovNet from 'api/egovFetch'; import URL from 'constants/url'; @@ -7,6 +7,8 @@ import URL from 'constants/url'; import Row from 'react-bootstrap/Row'; import Col from 'react-bootstrap/Col'; import Button from 'react-bootstrap/Button'; +import {format} from "date-fns"; +import EgovPaging from "../../components/EgovPaging"; function List(){ const navigate = useNavigate(); @@ -14,6 +16,89 @@ function List(){ const goToCreate = () => { 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( +
+
공지
+
{item?.bbsContTitle}
+
{item?.frstCrtId}
+
{item?.bbsReadCnt}
+
{formattedDate}
+
{item?.fileGrpId && }
+
+ ); + }); + + 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( +
+
{resp.result.resultCnt - (resp.result.paginationInfo.pageIndex -1) * resp.result.paginationInfo.rowCnt - index}
+
{item?.bbsContTitle}
+
{item?.frstCrtId}
+
{item?.bbsReadCnt}
+
{formattedDate}
+
{item?.fileGrpId && }
+
+ ); + }); + if(!mutListTag.length) mutListTag.push(

검색된 결과가 없습니다.

); // 게시판 목록 초기값 + 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 ( @@ -72,7 +157,8 @@ function List(){ {/*

검색된 결과가 없습니다.

*/} {/* */} - + {listTag} + {/*
3
[공지] 공통컴포넌트 중 모니터링 관련 서비스 실행시 오류가 발생합니다 [15]
관리자
@@ -91,16 +177,16 @@ function List(){
1
- {/*미답변시 아이콘*/} + 미답변시 아이콘   - {/*답변완료시 아이콘*/} - {/*  */} + 답변완료시 아이콘 +   공통컴포넌트 중 모니터링 관련 서비스 실행시 오류가 발생합니다.
홍길동
3
2021-7-24
- + */} {/* */} @@ -108,6 +194,9 @@ function List(){ {/* */} + { + retrieveList({ ...searchCondition, pageIndex: passedPage}) //, searchCnd: cndRef.current.value, searchKeyword: wrdRef.current.value + }} />
  • diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/boards/AdminBoardsController.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/boards/AdminBoardsController.java index b851ff6..cf27d3d 100644 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/boards/AdminBoardsController.java +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/boards/AdminBoardsController.java @@ -171,15 +171,15 @@ public class AdminBoardsController extends BaseController { @ApiResponse(responseCode = "403", description = "인가된 사용자가 아님") }) @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(); - params.setQueryInfo(); - Map resultMap = adminBoardsService.selectPostList(params); + tnBbsContents.setQueryInfo(); + Map resultMap = adminBoardsService.selectPostList(tnBbsContents); resultMap.put("categoryList", adminBoardsService.selectBoardList()); int totCnt = Integer.parseInt((String)resultMap.get("resultCnt")); - params.setContentCnt(totCnt); - params.setPaginationInfo(); - resultMap.put("paginationInfo", params); + tnBbsContents.setContentCnt(totCnt); + tnBbsContents.setPaginationInfo(); + resultMap.put("paginationInfo", tnBbsContents); resultVO.setResult(resultMap); return resultVO; } diff --git a/kcsc-back-end/src/main/resources/mybatisMapper/AdminBoardsMapper.xml b/kcsc-back-end/src/main/resources/mybatisMapper/AdminBoardsMapper.xml index c61ac04..42694da 100644 --- a/kcsc-back-end/src/main/resources/mybatisMapper/AdminBoardsMapper.xml +++ b/kcsc-back-end/src/main/resources/mybatisMapper/AdminBoardsMapper.xml @@ -52,6 +52,9 @@ and bbs_cont_title like '%'||#{searchKeyword}||'%' + + and bbs_id = #{bbsId} + \ No newline at end of file