게시물관리 게시판유형, 검색어, 페이지
parent
d0f17a8086
commit
b4d0596992
|
|
@ -24,7 +24,7 @@ function AdminPostMgtList(props) {
|
||||||
console.log("EgovAdminPostList [location] : ", location);
|
console.log("EgovAdminPostList [location] : ", location);
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
const [searchCondition, setSearchCondition] = useState(location.state?.searchCondition || { pageIndex: 1, searchCnd: '0', searchWrd: '' });// 기존 조회에서 접근 했을 시 || 신규로 접근 했을 시
|
const [searchCondition, setSearchCondition] = useState(location.state?.searchCondition || { pageIndex: 1, searchCnd: '0', searchKeyword: '', bbsSeq:8 });// 기존 조회에서 접근 했을 시 || 신규로 접근 했을 시
|
||||||
const [paginationInfo, setPaginationInfo] = useState({});
|
const [paginationInfo, setPaginationInfo] = useState({});
|
||||||
|
|
||||||
const cndRef = useRef();
|
const cndRef = useRef();
|
||||||
|
|
@ -38,19 +38,19 @@ function AdminPostMgtList(props) {
|
||||||
const handleClose = () => setShow(false);
|
const handleClose = () => setShow(false);
|
||||||
const handleShow = () => setShow(true);
|
const handleShow = () => setShow(true);
|
||||||
|
|
||||||
const retrieveList = useCallback(() => {
|
const retrieveList = useCallback((searchCondition) => {
|
||||||
handleClose();
|
handleClose();
|
||||||
|
const params = EgovNet.convParams(searchCondition);
|
||||||
console.groupCollapsed("EgovAdminPostList.retrieveList()");
|
console.groupCollapsed("EgovAdminPostList.retrieveList()");
|
||||||
|
|
||||||
const retrieveListURL = '/admin/boards/post-list';
|
const retrieveListURL = '/admin/boards/post-list' + params;
|
||||||
|
|
||||||
const requestOptions = {
|
const requestOptions = {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
'Content-type': 'application/json',
|
'Content-type': 'application/json',
|
||||||
|
|
||||||
},
|
}
|
||||||
body: JSON.stringify()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EgovNet.requestFetch(retrieveListURL,
|
EgovNet.requestFetch(retrieveListURL,
|
||||||
|
|
@ -60,27 +60,24 @@ function AdminPostMgtList(props) {
|
||||||
setCategoryList(resp.result.categoryList);
|
setCategoryList(resp.result.categoryList);
|
||||||
|
|
||||||
let mutListTag = [];
|
let mutListTag = [];
|
||||||
listTag.push(<p className="no_data" key="0">검색된 결과가 없습니다.</p>); // 게시판 목록 초기값
|
setListTag([]);
|
||||||
|
|
||||||
// 리스트 항목 구성
|
|
||||||
resp.result.postList.forEach(function (item, index) {
|
resp.result.postList.forEach(function (item, index) {
|
||||||
if (index === 0) mutListTag = []; // 목록 초기화
|
const finalModifiedDate = item?.lastChgDt ? item?.lastChgDt : item?.frstCrtDt;
|
||||||
const finalModifiedDate = item.lastChgDt ? item.lastChgDt : item.frstCrtDt;
|
|
||||||
const formattedDate = finalModifiedDate ? format(finalModifiedDate, "yyyy-MM-dd HH:mm") : "";
|
const formattedDate = finalModifiedDate ? format(finalModifiedDate, "yyyy-MM-dd HH:mm") : "";
|
||||||
|
|
||||||
mutListTag.push(
|
mutListTag.push(
|
||||||
<div className="list_item">
|
<div className="list_item">
|
||||||
<div></div>
|
<div>{item?.bbsContSeq}</div>
|
||||||
<div>{item.bbsContTitle}</div>
|
<div>{item?.bbsContTitle}</div>
|
||||||
<div>{item.frstCrtId}</div>
|
<div>{item?.frstCrtId}</div>
|
||||||
<div>{formattedDate}</div>
|
<div>{formattedDate}</div>
|
||||||
<div>{item.bbsReadCnt}</div>
|
<div>{item?.bbsReadCnt}</div>
|
||||||
<div>{item.fileGrpId}</div>
|
<div>{item?.fileGrpId}</div>
|
||||||
<div><button className={"btn btn_blue_h31 px-1"} onClick={()=>{editPost(item)}}>수정</button></div>
|
<div><button className={"btn btn_blue_h31 px-1"} onClick={()=>{editPost(item)}}>수정</button></div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
if(!mutListTag.length) mutListTag.push(<p className="no_data" key="0">검색된 결과가 없습니다.</p>); // 게시판 목록 초기값
|
||||||
setListTag(mutListTag);
|
setListTag(mutListTag);
|
||||||
},
|
},
|
||||||
function (resp) {
|
function (resp) {
|
||||||
|
|
@ -88,15 +85,15 @@ function AdminPostMgtList(props) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
console.groupEnd("EgovAdminPostList.retrieveList()");
|
console.groupEnd("EgovAdminPostList.retrieveList()");
|
||||||
},[listTag, searchCondition]);
|
},[listTag]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
retrieveList(searchCondition);
|
retrieveList(searchCondition);
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, [searchCondition]);
|
||||||
|
|
||||||
const handleSelectChange = (e) => {
|
const handleSelectChange = (e) => {
|
||||||
|
setSearchCondition({...searchCondition, bbsSeq: e.target.value})
|
||||||
}
|
}
|
||||||
|
|
||||||
function editPost(item){
|
function editPost(item){
|
||||||
|
|
@ -104,7 +101,7 @@ function AdminPostMgtList(props) {
|
||||||
if(item != undefined) {
|
if(item != undefined) {
|
||||||
item.mode = CODE.MODE_MODIFY;
|
item.mode = CODE.MODE_MODIFY;
|
||||||
}
|
}
|
||||||
setModalBody(<AdminPostMgtEdit props={item} reloadFunction={retrieveList}/>)
|
setModalBody(<AdminPostMgtEdit props={item} reloadFunction={(searchCondition) => retrieveList(searchCondition)}/>)
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("------------------------------EgovAdminPostList [End]");
|
console.log("------------------------------EgovAdminPostList [End]");
|
||||||
|
|
@ -139,12 +136,12 @@ function AdminPostMgtList(props) {
|
||||||
<div className="condition">
|
<div className="condition">
|
||||||
<ul>
|
<ul>
|
||||||
<li className="third_1 L">
|
<li className="third_1 L">
|
||||||
<span className="lb">검색유형선택</span>
|
<span className="lb">게시판선택</span>
|
||||||
<label className="f_select" htmlFor="searchCnd">
|
<label className="f_select" htmlFor="searchCnd">
|
||||||
<Form.Select id="select1" name="bbsId" onChange={handleSelectChange}>
|
<Form.Select id="select1" name="bbsSeq" value={searchCondition.bbsSeq} onChange={handleSelectChange}>
|
||||||
<option value="">선택</option>
|
<option value="">선택</option>
|
||||||
{categoryList.map((item) => (
|
{categoryList.map((item) => (
|
||||||
<option key={item.bbsSeq} value={item.bbsId} selected={props?.bbsId === item.bbsId}>{item.bbsTitle}</option>
|
<option key={item.bbsSeq} value={item.bbsSeq}>{item.bbsTitle}</option>
|
||||||
))}
|
))}
|
||||||
</Form.Select>
|
</Form.Select>
|
||||||
</label>
|
</label>
|
||||||
|
|
@ -152,15 +149,9 @@ function AdminPostMgtList(props) {
|
||||||
<li className="third_2 R">
|
<li className="third_2 R">
|
||||||
<span className="lb">검색어</span>
|
<span className="lb">검색어</span>
|
||||||
<span className="f_search w_400">
|
<span className="f_search w_400">
|
||||||
<input type="text" name="" defaultValue={searchCondition && searchCondition.searchWrd} placeholder="" ref={wrdRef}
|
<input type="text" name="" defaultValue={searchCondition.searchKeyword} placeholder=""
|
||||||
onChange={e => {
|
onChange={(e) => {setSearchCondition({...searchCondition, searchKeyword: e.target.value})}}/>
|
||||||
wrdRef.current.value = e.target.value;
|
<button type="button" onClick={() => {retrieveList(searchCondition)}}>조회</button>
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<button type="button"
|
|
||||||
onClick={() => {
|
|
||||||
retrieveList({ ...searchCondition, pageIndex: 1, searchCnd: cndRef.current.value, searchWrd: wrdRef.current.value });
|
|
||||||
}}>조회</button>
|
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
@ -170,7 +161,7 @@ function AdminPostMgtList(props) {
|
||||||
{/* <!-- 게시판목록 --> */}
|
{/* <!-- 게시판목록 --> */}
|
||||||
<div className="board_list BRD006">
|
<div className="board_list BRD006">
|
||||||
<div className="head">
|
<div className="head">
|
||||||
<span></span>
|
<span>번호</span>
|
||||||
<span>제목</span>
|
<span>제목</span>
|
||||||
<span>작성자</span>
|
<span>작성자</span>
|
||||||
<span>최종수정일</span>
|
<span>최종수정일</span>
|
||||||
|
|
@ -187,7 +178,7 @@ function AdminPostMgtList(props) {
|
||||||
<div className="board_bot">
|
<div className="board_bot">
|
||||||
{/* <!-- Paging --> */}
|
{/* <!-- Paging --> */}
|
||||||
<EgovPaging pagination={paginationInfo} moveToPage={passedPage => {
|
<EgovPaging pagination={paginationInfo} moveToPage={passedPage => {
|
||||||
retrieveList({ ...searchCondition, pageIndex: passedPage, searchCnd: cndRef.current.value, searchWrd: wrdRef.current.value })
|
retrieveList({ ...searchCondition, pageIndex: passedPage}) //, searchCnd: cndRef.current.value, searchKeyword: wrdRef.current.value
|
||||||
}} />
|
}} />
|
||||||
{/* <!--/ Paging --> */}
|
{/* <!--/ Paging --> */}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -152,11 +152,15 @@ public class AdminBoardsController extends BaseController {
|
||||||
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||||
})
|
})
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "/post-list", consumes = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(method = RequestMethod.GET, value = "/post-list", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||||
public ResultVO getPostList() throws Exception {
|
public ResultVO getPostList(TnBbsContents params) throws Exception {
|
||||||
ResultVO resultVO = new ResultVO();
|
ResultVO resultVO = new ResultVO();
|
||||||
Map<String, Object> resultMap = new HashMap<>();
|
params.setQueryInfo();
|
||||||
|
Map<String, Object> resultMap = adminBoardsService.selectPostList(params);
|
||||||
resultMap.put("categoryList", adminBoardsService.selectBoardList());
|
resultMap.put("categoryList", adminBoardsService.selectBoardList());
|
||||||
resultMap.put("postList", adminBoardsService.selectPostList());
|
int totCnt = Integer.parseInt((String)resultMap.get("resultCnt"));
|
||||||
|
params.setContentCnt(totCnt);
|
||||||
|
params.setPaginationInfo();
|
||||||
|
resultMap.put("paginationInfo", params);
|
||||||
resultVO.setResult(resultMap);
|
resultVO.setResult(resultMap);
|
||||||
return resultVO;
|
return resultVO;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
package com.dbnt.kcscbackend.admin.boards.entity;
|
package com.dbnt.kcscbackend.admin.boards.entity;
|
||||||
|
import com.dbnt.kcscbackend.config.common.BoardParams;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
@ -15,7 +16,7 @@ import java.time.LocalDateTime;
|
||||||
@DynamicInsert
|
@DynamicInsert
|
||||||
@DynamicUpdate
|
@DynamicUpdate
|
||||||
@Table(name = "tn_bbs_contents")
|
@Table(name = "tn_bbs_contents")
|
||||||
public class TnBbsContents {
|
public class TnBbsContents extends BoardParams {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "bbs_cont_seq")
|
@Column(name = "bbs_cont_seq")
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.dbnt.kcscbackend.admin.boards.mapper;
|
||||||
|
|
||||||
|
import com.dbnt.kcscbackend.admin.boards.entity.TnBbsContents;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface AdminBoardsMapper {
|
||||||
|
|
||||||
|
List<TnBbsContents> selectPostList(TnBbsContents params);
|
||||||
|
|
||||||
|
Integer selectPostListCnt(TnBbsContents params);
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@ package com.dbnt.kcscbackend.admin.boards.service;
|
||||||
|
|
||||||
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.entity.TnBbsContents;
|
||||||
|
import com.dbnt.kcscbackend.admin.boards.mapper.AdminBoardsMapper;
|
||||||
import com.dbnt.kcscbackend.admin.boards.repository.TnBbsContentsRepository;
|
import com.dbnt.kcscbackend.admin.boards.repository.TnBbsContentsRepository;
|
||||||
import com.dbnt.kcscbackend.admin.boards.repository.TnBbsRepository;
|
import com.dbnt.kcscbackend.admin.boards.repository.TnBbsRepository;
|
||||||
import com.dbnt.kcscbackend.admin.config.entity.TcMenu;
|
import com.dbnt.kcscbackend.admin.config.entity.TcMenu;
|
||||||
|
|
@ -17,9 +18,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
|
@ -27,6 +26,7 @@ public class AdminBoardsService extends EgovAbstractServiceImpl {
|
||||||
|
|
||||||
private final TnBbsRepository tnBbsRepository;
|
private final TnBbsRepository tnBbsRepository;
|
||||||
private final TnBbsContentsRepository tnBbsContentsRepository;
|
private final TnBbsContentsRepository tnBbsContentsRepository;
|
||||||
|
private final AdminBoardsMapper adminBoardsMapper;
|
||||||
private final FileService fileService;
|
private final FileService fileService;
|
||||||
|
|
||||||
public List<TnBbs> selectBoardList() {
|
public List<TnBbs> selectBoardList() {
|
||||||
|
|
@ -70,8 +70,11 @@ public class AdminBoardsService extends EgovAbstractServiceImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TnBbsContents> selectPostList() {
|
public Map<String, Object> selectPostList(TnBbsContents params) {
|
||||||
return tnBbsContentsRepository.findAll();
|
Map<String, Object> resultMap = new HashMap<>();
|
||||||
|
resultMap.put("resultCnt", String.valueOf(adminBoardsMapper.selectPostListCnt(params)));
|
||||||
|
resultMap.put("postList", adminBoardsMapper.selectPostList(params));
|
||||||
|
return resultMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.dbnt.kcscbackend.admin.boards.mapper.AdminBoardsMapper">
|
||||||
|
|
||||||
|
<select id="selectPostList" parameterType="TnBbsContents" resultType="TnBbsContents">
|
||||||
|
select
|
||||||
|
bbs_cont_seq,
|
||||||
|
bbs_seq,
|
||||||
|
bbs_cont_title,
|
||||||
|
bbs_contents,
|
||||||
|
bbs_cont_seq_group,
|
||||||
|
bbs_cont_seq_parent,
|
||||||
|
bbs_cont_level,
|
||||||
|
bbs_cont_sort,
|
||||||
|
file_grp_id,
|
||||||
|
bbs_read_cnt,
|
||||||
|
fixed_yn,
|
||||||
|
secret_yn,
|
||||||
|
secret_pwd,
|
||||||
|
doc_info_seq,
|
||||||
|
ip_address,
|
||||||
|
frst_crt_id,
|
||||||
|
frst_crt_dt,
|
||||||
|
last_chg_id,
|
||||||
|
last_chg_dt,
|
||||||
|
use_yn,
|
||||||
|
old_seq,
|
||||||
|
bbs_id
|
||||||
|
from tn_bbs_contents
|
||||||
|
<include refid="selectPostListWhere"></include>
|
||||||
|
order by bbs_cont_seq desc
|
||||||
|
limit #{rowCnt} offset #{firstIndex}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectPostListCnt" parameterType="TnBbsContents" resultType="int">
|
||||||
|
select count(*)
|
||||||
|
from tn_bbs_contents
|
||||||
|
<include refid="selectPostListWhere"></include>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<sql id="selectPostListWhere">
|
||||||
|
<where>
|
||||||
|
<if test='bbsSeq != null and bbsSeq != ""'>
|
||||||
|
and bbs_seq = #{bbsSeq}
|
||||||
|
</if>
|
||||||
|
<if test='searchKeyword != null and searchKeyword != ""'>
|
||||||
|
and bbs_cont_title like '%'||#{searchKeyword}||'%'
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</sql>
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue