게시물관리 게시판유형, 검색어, 페이지
parent
d0f17a8086
commit
b4d0596992
|
|
@ -24,7 +24,7 @@ function AdminPostMgtList(props) {
|
|||
console.log("EgovAdminPostList [location] : ", location);
|
||||
|
||||
// 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 cndRef = useRef();
|
||||
|
|
@ -38,19 +38,19 @@ function AdminPostMgtList(props) {
|
|||
const handleClose = () => setShow(false);
|
||||
const handleShow = () => setShow(true);
|
||||
|
||||
const retrieveList = useCallback(() => {
|
||||
const retrieveList = useCallback((searchCondition) => {
|
||||
handleClose();
|
||||
const params = EgovNet.convParams(searchCondition);
|
||||
console.groupCollapsed("EgovAdminPostList.retrieveList()");
|
||||
|
||||
const retrieveListURL = '/admin/boards/post-list';
|
||||
const retrieveListURL = '/admin/boards/post-list' + params;
|
||||
|
||||
const requestOptions = {
|
||||
method: "GET",
|
||||
headers: {
|
||||
'Content-type': 'application/json',
|
||||
|
||||
},
|
||||
body: JSON.stringify()
|
||||
}
|
||||
}
|
||||
|
||||
EgovNet.requestFetch(retrieveListURL,
|
||||
|
|
@ -60,27 +60,24 @@ function AdminPostMgtList(props) {
|
|||
setCategoryList(resp.result.categoryList);
|
||||
|
||||
let mutListTag = [];
|
||||
listTag.push(<p className="no_data" key="0">검색된 결과가 없습니다.</p>); // 게시판 목록 초기값
|
||||
setListTag([]);
|
||||
|
||||
// 리스트 항목 구성
|
||||
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") : "";
|
||||
|
||||
mutListTag.push(
|
||||
<div className="list_item">
|
||||
<div></div>
|
||||
<div>{item.bbsContTitle}</div>
|
||||
<div>{item.frstCrtId}</div>
|
||||
<div>{item?.bbsContSeq}</div>
|
||||
<div>{item?.bbsContTitle}</div>
|
||||
<div>{item?.frstCrtId}</div>
|
||||
<div>{formattedDate}</div>
|
||||
<div>{item.bbsReadCnt}</div>
|
||||
<div>{item.fileGrpId}</div>
|
||||
<div>{item?.bbsReadCnt}</div>
|
||||
<div>{item?.fileGrpId}</div>
|
||||
<div><button className={"btn btn_blue_h31 px-1"} onClick={()=>{editPost(item)}}>수정</button></div>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
if(!mutListTag.length) mutListTag.push(<p className="no_data" key="0">검색된 결과가 없습니다.</p>); // 게시판 목록 초기값
|
||||
setListTag(mutListTag);
|
||||
},
|
||||
function (resp) {
|
||||
|
|
@ -88,15 +85,15 @@ function AdminPostMgtList(props) {
|
|||
}
|
||||
);
|
||||
console.groupEnd("EgovAdminPostList.retrieveList()");
|
||||
},[listTag, searchCondition]);
|
||||
},[listTag]);
|
||||
|
||||
useEffect(() => {
|
||||
retrieveList(searchCondition);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
}, [searchCondition]);
|
||||
|
||||
const handleSelectChange = (e) => {
|
||||
|
||||
setSearchCondition({...searchCondition, bbsSeq: e.target.value})
|
||||
}
|
||||
|
||||
function editPost(item){
|
||||
|
|
@ -104,7 +101,7 @@ function AdminPostMgtList(props) {
|
|||
if(item != undefined) {
|
||||
item.mode = CODE.MODE_MODIFY;
|
||||
}
|
||||
setModalBody(<AdminPostMgtEdit props={item} reloadFunction={retrieveList}/>)
|
||||
setModalBody(<AdminPostMgtEdit props={item} reloadFunction={(searchCondition) => retrieveList(searchCondition)}/>)
|
||||
}
|
||||
|
||||
console.log("------------------------------EgovAdminPostList [End]");
|
||||
|
|
@ -139,12 +136,12 @@ function AdminPostMgtList(props) {
|
|||
<div className="condition">
|
||||
<ul>
|
||||
<li className="third_1 L">
|
||||
<span className="lb">검색유형선택</span>
|
||||
<span className="lb">게시판선택</span>
|
||||
<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>
|
||||
{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>
|
||||
</label>
|
||||
|
|
@ -152,15 +149,9 @@ function AdminPostMgtList(props) {
|
|||
<li className="third_2 R">
|
||||
<span className="lb">검색어</span>
|
||||
<span className="f_search w_400">
|
||||
<input type="text" name="" defaultValue={searchCondition && searchCondition.searchWrd} placeholder="" ref={wrdRef}
|
||||
onChange={e => {
|
||||
wrdRef.current.value = e.target.value;
|
||||
}}
|
||||
/>
|
||||
<button type="button"
|
||||
onClick={() => {
|
||||
retrieveList({ ...searchCondition, pageIndex: 1, searchCnd: cndRef.current.value, searchWrd: wrdRef.current.value });
|
||||
}}>조회</button>
|
||||
<input type="text" name="" defaultValue={searchCondition.searchKeyword} placeholder=""
|
||||
onChange={(e) => {setSearchCondition({...searchCondition, searchKeyword: e.target.value})}}/>
|
||||
<button type="button" onClick={() => {retrieveList(searchCondition)}}>조회</button>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
@ -170,7 +161,7 @@ function AdminPostMgtList(props) {
|
|||
{/* <!-- 게시판목록 --> */}
|
||||
<div className="board_list BRD006">
|
||||
<div className="head">
|
||||
<span></span>
|
||||
<span>번호</span>
|
||||
<span>제목</span>
|
||||
<span>작성자</span>
|
||||
<span>최종수정일</span>
|
||||
|
|
@ -187,7 +178,7 @@ function AdminPostMgtList(props) {
|
|||
<div className="board_bot">
|
||||
{/* <!-- Paging --> */}
|
||||
<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 --> */}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -152,11 +152,15 @@ public class AdminBoardsController extends BaseController {
|
|||
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||
})
|
||||
@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();
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
params.setQueryInfo();
|
||||
Map<String, Object> resultMap = adminBoardsService.selectPostList(params);
|
||||
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);
|
||||
return resultVO;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
package com.dbnt.kcscbackend.admin.boards.entity;
|
||||
import com.dbnt.kcscbackend.config.common.BoardParams;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
|
@ -15,7 +16,7 @@ import java.time.LocalDateTime;
|
|||
@DynamicInsert
|
||||
@DynamicUpdate
|
||||
@Table(name = "tn_bbs_contents")
|
||||
public class TnBbsContents {
|
||||
public class TnBbsContents extends BoardParams {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@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.TnBbsContents;
|
||||
import com.dbnt.kcscbackend.admin.boards.mapper.AdminBoardsMapper;
|
||||
import com.dbnt.kcscbackend.admin.boards.repository.TnBbsContentsRepository;
|
||||
import com.dbnt.kcscbackend.admin.boards.repository.TnBbsRepository;
|
||||
import com.dbnt.kcscbackend.admin.config.entity.TcMenu;
|
||||
|
|
@ -17,9 +18,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
|
|
@ -27,6 +26,7 @@ public class AdminBoardsService extends EgovAbstractServiceImpl {
|
|||
|
||||
private final TnBbsRepository tnBbsRepository;
|
||||
private final TnBbsContentsRepository tnBbsContentsRepository;
|
||||
private final AdminBoardsMapper adminBoardsMapper;
|
||||
private final FileService fileService;
|
||||
|
||||
public List<TnBbs> selectBoardList() {
|
||||
|
|
@ -70,8 +70,11 @@ public class AdminBoardsService extends EgovAbstractServiceImpl {
|
|||
}
|
||||
}
|
||||
|
||||
public List<TnBbsContents> selectPostList() {
|
||||
return tnBbsContentsRepository.findAll();
|
||||
public Map<String, Object> selectPostList(TnBbsContents params) {
|
||||
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