게시판관리 조회, 삭제, 날짜포맷 수정
parent
cbfb9b2ca3
commit
1fd7ba0fb1
|
|
@ -74,6 +74,31 @@ function EgovAdminBoardEdit({props, reloadFunction}) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deleteBoard(bbs){
|
||||||
|
if(window.confirm("삭제하시겠습니까?")) {
|
||||||
|
EgovNet.requestFetch(
|
||||||
|
'/admin/boards/board-mgt',
|
||||||
|
{
|
||||||
|
method: "DELETE",
|
||||||
|
headers: {
|
||||||
|
'Content-type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify(bbs)
|
||||||
|
},
|
||||||
|
(resp) => {
|
||||||
|
if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) {
|
||||||
|
alert("삭제되었습니다.")
|
||||||
|
reloadFunction();
|
||||||
|
} else if (Number(resp.resultCode) === Number(CODE.RCV_ERROR_AUTH)) {
|
||||||
|
console.log("토큰 갱신중.")
|
||||||
|
} else {
|
||||||
|
alert(resp.result.resultMessage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
console.log("------------------------------EgovAdminBoardEdit [End]");
|
console.log("------------------------------EgovAdminBoardEdit [End]");
|
||||||
console.groupEnd("EgovAdminBoardEdit");
|
console.groupEnd("EgovAdminBoardEdit");
|
||||||
|
|
||||||
|
|
@ -118,7 +143,7 @@ function EgovAdminBoardEdit({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 className="btn btn_skyblue_h46 w_100">삭제</button>
|
<button type={"button"} className="btn btn_skyblue_h46 w_100" onClick={()=>{deleteBoard(props)}}>삭제</button>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,9 @@ import URL from 'constants/url';
|
||||||
import CODE from 'constants/code';
|
import CODE from 'constants/code';
|
||||||
|
|
||||||
import { default as EgovLeftNav } from 'components/leftmenu/EgovLeftNavAdmin';
|
import { default as EgovLeftNav } from 'components/leftmenu/EgovLeftNavAdmin';
|
||||||
import EgovPaging from 'components/EgovPaging';
|
|
||||||
|
|
||||||
import { itemIdxByPage } from 'utils/calc';
|
|
||||||
import MenuModal from "../config/menuMgt/MenuModal";
|
|
||||||
import Modal from "react-bootstrap/Modal";
|
import Modal from "react-bootstrap/Modal";
|
||||||
import EgovAdminBoardEdit from "../board/EgovAdminBoardEdit";
|
import EgovAdminBoardEdit from "../board/EgovAdminBoardEdit";
|
||||||
|
import {format} from "date-fns";
|
||||||
|
|
||||||
function EgovAdminBoardList(props) {
|
function EgovAdminBoardList(props) {
|
||||||
console.group("EgovAdminBoardList");
|
console.group("EgovAdminBoardList");
|
||||||
|
|
@ -63,8 +60,8 @@ function EgovAdminBoardList(props) {
|
||||||
<div>{item.bbsId}</div>
|
<div>{item.bbsId}</div>
|
||||||
<div>{item.bbsTitle}</div>
|
<div>{item.bbsTitle}</div>
|
||||||
<div>{item.frstCrtId}</div>
|
<div>{item.frstCrtId}</div>
|
||||||
<div>{item.frstCrtDt}</div>
|
<div>{item.frstCrtDt ? format(item.frstCrtDt, "yyyy-MM-dd HH:mm") : ""}</div>
|
||||||
<div>{item.lastChgDt}</div>
|
<div>{item.lastChgDt ? format(item.lastChgDt, "yyyy-MM-dd HH:mm") : ""}</div>
|
||||||
<div><button className={"btn btn_blue_h31 px-1"} onClick={()=>{editBoard(item)}}>수정</button></div>
|
<div><button className={"btn btn_blue_h31 px-1"} onClick={()=>{editBoard(item)}}>수정</button></div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ public class AdminBoardsController extends BaseController {
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "게시판 저장",
|
summary = "게시판 저장",
|
||||||
description = "게시판 저장",
|
description = "게시판 저장",
|
||||||
tags = {"AdminConfigController"}
|
tags = {"AdminBoardsController"}
|
||||||
)
|
)
|
||||||
@ApiResponses(value = {
|
@ApiResponses(value = {
|
||||||
@ApiResponse(responseCode = "200", description = "저장 성공"),
|
@ApiResponse(responseCode = "200", description = "저장 성공"),
|
||||||
|
|
@ -83,4 +83,30 @@ 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.DELETE, value = "/board-mgt")
|
||||||
|
public ResultVO removeBoardMgt(@RequestBody TnBbs bbs, @AuthenticationPrincipal LoginVO user) {
|
||||||
|
ResultVO resultVO = new ResultVO();
|
||||||
|
if (user == null) {
|
||||||
|
resultVO.setResultCode(ResponseCode.TOKEN_EXPIRED.getCode());
|
||||||
|
} else {
|
||||||
|
String result = adminBoardsService.deleteBoard(bbs, 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,13 @@ 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 WHERE use_yn = 'Y' ORDER BY bbs_seq DESC", nativeQuery = true)
|
||||||
List<TnBbs> findAllByOrderByBbsSeqDesc();
|
List<TnBbs> findAllByOrderByBbsSeqDesc();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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.repository.TnBbsRepository;
|
import com.dbnt.kcscbackend.admin.boards.repository.TnBbsRepository;
|
||||||
|
import com.dbnt.kcscbackend.admin.config.entity.TcMenu;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
|
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -17,13 +18,16 @@ public class AdminBoardsService extends EgovAbstractServiceImpl {
|
||||||
|
|
||||||
private final TnBbsRepository tnBbsRepository;
|
private final TnBbsRepository tnBbsRepository;
|
||||||
|
|
||||||
public List<TnBbs> selectBoardList() { return tnBbsRepository.findAllByOrderByBbsSeqDesc(); }
|
public List<TnBbs> selectBoardList() {
|
||||||
|
return tnBbsRepository.findAllByOrderByBbsSeqDesc();
|
||||||
|
}
|
||||||
|
|
||||||
public Optional<TnBbs> selectBoard(Long bbsSeq) { return tnBbsRepository.findById(bbsSeq); }
|
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) {
|
||||||
bbs.setFrstCrtDt(LocalDateTime.now());
|
bbs.setFrstCrtDt(LocalDateTime.now());
|
||||||
bbs.setFrstCrtId(userId);
|
bbs.setFrstCrtId(userId);
|
||||||
|
|
@ -43,4 +47,18 @@ public class AdminBoardsService extends EgovAbstractServiceImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public String deleteBoard(TnBbs bbs, String userId) {
|
||||||
|
TnBbs savedBoard = tnBbsRepository.findById(bbs.getBbsSeq()).orElse(null);
|
||||||
|
if (savedBoard == null) {
|
||||||
|
return "notFind";
|
||||||
|
} else {
|
||||||
|
savedBoard.setUseYn("N");
|
||||||
|
savedBoard.setLastChgDt(LocalDateTime.now());
|
||||||
|
savedBoard.setLastChgId(userId);
|
||||||
|
tnBbsRepository.save(savedBoard);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue