게시판관리 추가, 수정
parent
a63a47a7b8
commit
e825207231
|
|
@ -8,9 +8,10 @@ import CODE from 'constants/code';
|
||||||
|
|
||||||
import {default as EgovLeftNav} from 'components/leftmenu/EgovLeftNavAdmin';
|
import {default as EgovLeftNav} from 'components/leftmenu/EgovLeftNavAdmin';
|
||||||
import EgovRadioButtonGroup from 'components/EgovRadioButtonGroup';
|
import EgovRadioButtonGroup from 'components/EgovRadioButtonGroup';
|
||||||
|
import {Form} from "react-bootstrap";
|
||||||
|
|
||||||
|
|
||||||
function EgovAdminBoardEdit(props) {
|
function EgovAdminBoardEdit({props, reloadFunction}) {
|
||||||
console.group("EgovAdminBoardEdit");
|
console.group("EgovAdminBoardEdit");
|
||||||
console.log("[Start] EgovAdminBoardEdit ------------------------------");
|
console.log("[Start] EgovAdminBoardEdit ------------------------------");
|
||||||
console.log("EgovAdminBoardEdit [props] : ", props);
|
console.log("EgovAdminBoardEdit [props] : ", props);
|
||||||
|
|
@ -21,193 +22,58 @@ function EgovAdminBoardEdit(props) {
|
||||||
|
|
||||||
console.log("EgovAdminBoardEdit [location] : ", location);
|
console.log("EgovAdminBoardEdit [location] : ", location);
|
||||||
|
|
||||||
const replyPosblAtRadioGroup = [{value: "Y", label: "가능"}, {value: "N", label: "불가능"}];
|
|
||||||
const fileAtchPosblAtRadioGroup = [{value: "Y", label: "가능"}, {value: "N", label: "불가능"}];
|
|
||||||
const bbsTyCodeOptions = [{value: "", label: "선택"}, {value: "BBST01", label: "일반게시판"}, {value: "BBST03", label: "공지게시판"}];
|
|
||||||
const bbsAttrbCodeOptions = [{value: "", label: "선택"}, {value: "BBSA02", label: "갤러리"}, {value: "BBSA03", label: "일반게시판"}];
|
|
||||||
const posblAtchFileNumberOptions = [{value: 0, label: "선택하세요"}, {value: 1, label: "1개"}, {value: 2, label: "2개"}, {value: 3, label: "3개"}];
|
|
||||||
|
|
||||||
let item = null;
|
let item = null;
|
||||||
item = props.props;
|
item = props;
|
||||||
console.log("@@@ item : " + JSON.stringify(item));
|
console.log("@@@ item : " + JSON.stringify(item));
|
||||||
|
|
||||||
|
const [modeInfo, setModeInfo] = useState(item != null ? {mode: props.mode} : {mode: CODE.MODE_CREATE});
|
||||||
|
|
||||||
const [modeInfo, setModeInfo] = useState(item != null ? {mode: props.props.mode} : {mode: CODE.MODE_CREATE});
|
|
||||||
const [boardDetail, setBoardDetail] = useState({});
|
const [boardDetail, setBoardDetail] = useState({});
|
||||||
console.log("@@@ mode : " + modeInfo.mode);
|
console.log("@@@ mode : " + modeInfo.mode);
|
||||||
|
|
||||||
const initMode = () => {
|
|
||||||
retrieveDetail();
|
|
||||||
}
|
|
||||||
|
|
||||||
const retrieveDetail = () => {
|
|
||||||
if (modeInfo.mode === CODE.MODE_CREATE) {// 조회/등록이면 조회 안함
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const retrieveDetailURL = '/admin/boards/board';
|
|
||||||
|
|
||||||
const requestOptions = {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
'Content-type': 'application/json',
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EgovNet.requestFetch(retrieveDetailURL,
|
|
||||||
requestOptions,
|
|
||||||
function (resp) {
|
|
||||||
// 수정모드일 경우 조회값 세팅
|
|
||||||
if (modeInfo.mode === CODE.MODE_MODIFY) {
|
|
||||||
setBoardDetail(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const formValidator = (formData) => {
|
|
||||||
if (formData.get('bbsTitle') === null || formData.get('bbsTitle') === "") {
|
|
||||||
alert("게시판명은 필수 값입니다.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (formData.get('bbsDesc') === null || formData.get('bbsDesc') === "") {
|
|
||||||
alert("게시판 소개는 필수 값입니다.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (formData.get('bbsTyCode') === null || formData.get('bbsTyCode') === "") {
|
|
||||||
alert("게시판 유형은 필수 값입니다.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (formData.get('bbsAttrbCode') === null || formData.get('bbsAttrbCode') === "") {
|
|
||||||
alert("게시판 속성은 필수 값입니다.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (formData.get('posblAtchFileNumber') === null || formData.get('posblAtchFileNumber') === "") {
|
|
||||||
alert("첨부파일 가능 숫자는 필수 값입니다.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
const formObjValidator = (checkRef) => {
|
|
||||||
if (checkRef.current[0].value === "") {
|
|
||||||
alert("게시판명은 필수 값입니다.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (checkRef.current[1].value === "") {
|
|
||||||
alert("게시판 소개는 필수 값입니다.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (checkRef.current[2].value === "0") {
|
|
||||||
alert("첨부파일 가능 숫자는 필수 값입니다.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
const updateBoard = () => {
|
|
||||||
|
|
||||||
let modeStr = modeInfo.mode === CODE.MODE_CREATE ? "POST" : "PUT";
|
|
||||||
|
|
||||||
let requestOptions = {};
|
|
||||||
|
|
||||||
if (modeStr === "POST") {
|
|
||||||
|
|
||||||
const formData = new FormData();
|
|
||||||
|
|
||||||
for (let key in boardDetail) {
|
|
||||||
formData.append(key, boardDetail[key]);
|
|
||||||
//console.log("boardDetail [%s] ", key, boardDetail[key]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (formValidator(formData)) {
|
|
||||||
|
|
||||||
requestOptions = {
|
|
||||||
method: modeStr,
|
|
||||||
headers: {},
|
|
||||||
body: formData
|
|
||||||
}
|
|
||||||
|
|
||||||
EgovNet.requestFetch(modeInfo.editURL,
|
|
||||||
requestOptions,
|
|
||||||
(resp) => {
|
|
||||||
if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) {
|
|
||||||
navigate({pathname: URL.ADMIN_BOARD});
|
|
||||||
} else {
|
|
||||||
navigate({pathname: URL.ERROR}, {state: {msg: resp.resultMessage}});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if (formObjValidator(checkRef)) {
|
|
||||||
|
|
||||||
requestOptions = {
|
|
||||||
method: modeStr,
|
|
||||||
headers: {
|
|
||||||
'Content-type': 'application/json',
|
|
||||||
|
|
||||||
},
|
|
||||||
body: JSON.stringify({...boardDetail})
|
|
||||||
}
|
|
||||||
|
|
||||||
EgovNet.requestFetch(modeInfo.editURL,
|
|
||||||
requestOptions,
|
|
||||||
(resp) => {
|
|
||||||
if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) {
|
|
||||||
navigate({pathname: URL.ADMIN_BOARD});
|
|
||||||
} else {
|
|
||||||
navigate({pathname: URL.ERROR}, {state: {msg: resp.resultMessage}});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const deleteBoardArticle = (bbsId) => {
|
|
||||||
const deleteBoardURL = `/cop/bbs/deleteBBSMasterInfAPI/${bbsId}.do`;
|
|
||||||
|
|
||||||
const requestOptions = {
|
|
||||||
method: "PUT",
|
|
||||||
headers: {
|
|
||||||
'Content-type': 'application/json',
|
|
||||||
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
bbsId: bbsId
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
EgovNet.requestFetch(deleteBoardURL,
|
|
||||||
requestOptions,
|
|
||||||
(resp) => {
|
|
||||||
console.log("====>>> board delete= ", resp);
|
|
||||||
if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) {
|
|
||||||
alert("게시글이 삭제되었습니다.")
|
|
||||||
navigate(URL.ADMIN_BOARD, {replace: true});
|
|
||||||
} else {
|
|
||||||
alert("ERR : " + resp.resultMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const getSelectedLabel = (objArray, findLabel = "") => {
|
|
||||||
let foundValueLabelObj = objArray.find(o => o['value'] === findLabel);
|
|
||||||
return foundValueLabelObj['label'];
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
initMode();
|
initMode();
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const initMode = () => {
|
||||||
|
if (modeInfo.mode === CODE.MODE_MODIFY) {
|
||||||
|
setBoardDetail(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function editBoard(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
const form = e.target;
|
||||||
|
const info = {
|
||||||
|
bbsId: form.bbsId.value,
|
||||||
|
bbsTitle: form.bbsTitle.value,
|
||||||
|
bbsDesc: form.bbsDesc.value
|
||||||
|
}
|
||||||
|
if (modeInfo.mode === CODE.MODE_MODIFY) {
|
||||||
|
info.bbsSeq = props.bbsSeq;
|
||||||
|
}
|
||||||
|
EgovNet.requestFetch(
|
||||||
|
'/admin/boards/board-mgt',
|
||||||
|
{
|
||||||
|
method: "PUT",
|
||||||
|
headers: {
|
||||||
|
'Content-type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify(info)
|
||||||
|
},
|
||||||
|
(resp) => {
|
||||||
|
if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) {
|
||||||
|
alert("저장되었습니다.")
|
||||||
|
} 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");
|
||||||
|
|
||||||
|
|
@ -223,55 +89,45 @@ function EgovAdminBoardEdit(props) {
|
||||||
|
|
||||||
<Modal.Body>
|
<Modal.Body>
|
||||||
<div className="board_view2">
|
<div className="board_view2">
|
||||||
<dl>
|
<Form onSubmit={(e) => {editBoard(e)}} noValidate>
|
||||||
<dt><label htmlFor="bbsId">게시판ID</label><span className="req">필수</span></dt>
|
<dl>
|
||||||
<dd>
|
<dt><label htmlFor="bbsId">게시판 ID</label><span className="req">필수</span></dt>
|
||||||
<input className="f_input2 w_full" type="text" name="bbsId" title="" id="bbsId" placeholder=""
|
<dd>
|
||||||
defaultValue={boardDetail?.bbsId}
|
<Form.Control className="f_input2 w_full" type="text" name="bbsId" placeholder="게시판 ID" required
|
||||||
onChange={e => setBoardDetail({...boardDetail, bbsId: e.target.value})}
|
defaultValue={props?.bbsId} readOnly={props!==undefined}/>
|
||||||
ref={el => (checkRef.current[0] = el)}
|
</dd>
|
||||||
/>
|
</dl>
|
||||||
</dd>
|
<dl>
|
||||||
</dl>
|
<dt><label htmlFor="bbsTitle">게시판명</label><span className="req">필수</span></dt>
|
||||||
<dl>
|
<dd>
|
||||||
<dt><label htmlFor="bbsTitle">게시판명</label><span className="req">필수</span></dt>
|
<Form.Control className="f_input2 w_full" type="text" name="bbsTitle" placeholder="게시판명" required
|
||||||
<dd>
|
defaultValue={props?.bbsTitle}/>
|
||||||
<input className="f_input2 w_full" type="text" name="bbsTitle" title="" id="bbsTitle" placeholder=""
|
</dd>
|
||||||
defaultValue={boardDetail?.bbsTitle}
|
</dl>
|
||||||
onChange={e => setBoardDetail({...boardDetail, bbsTitle: e.target.value})}
|
<dl>
|
||||||
ref={el => (checkRef.current[0] = el)}
|
<dt><label htmlFor="bbsDesc">게시판 소개</label><span className="req">필수</span></dt>
|
||||||
/>
|
<dd>
|
||||||
</dd>
|
<Form.Control className="f_txtar w_full h_100" as="textarea" name="bbsDesc" placeholder="게시판 소개" required
|
||||||
</dl>
|
defaultValue={props?.bbsDesc}/>
|
||||||
<dl>
|
</dd>
|
||||||
<dt><label htmlFor="bbsDesc">게시판 소개</label><span className="req">필수</span></dt>
|
</dl>
|
||||||
<dd>
|
|
||||||
<textarea className="f_txtar w_full h_100" name="bbsDesc" id="bbsDesc" cols="30" rows="10" placeholder=""
|
|
||||||
defaultValue={boardDetail?.bbsDesc}
|
|
||||||
onChange={e => setBoardDetail({...boardDetail, bbsDesc: e.target.value})}
|
|
||||||
ref={el => (checkRef.current[1] = el)}
|
|
||||||
></textarea>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
{/* <!-- 버튼영역 --> */}
|
{/* <!-- 버튼영역 --> */}
|
||||||
<div className="board_btn_area">
|
<div className="board_btn_area">
|
||||||
<div className="left_col btn1">
|
<div className="left_col btn1">
|
||||||
<button className="btn btn_skyblue_h46 w_100"
|
<button type="submit" className="btn btn_skyblue_h46 w_100">저장
|
||||||
onClick={() => updateBoard()}>저장
|
</button>
|
||||||
</button>
|
{modeInfo.mode === CODE.MODE_MODIFY &&
|
||||||
{modeInfo.mode === CODE.MODE_MODIFY &&
|
<button className="btn btn_skyblue_h46 w_100">삭제</button>
|
||||||
<button className="btn btn_skyblue_h46 w_100" onClick={() => {
|
}
|
||||||
deleteBoardArticle(boardDetail?.bbsId);
|
</div>
|
||||||
}}>삭제</button>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="right_col btn1">
|
<div className="right_col btn1">
|
||||||
<Link to={URL.ADMIN_BOARD} className="btn btn_blue_h46 w_100">목록</Link>
|
<Link to={URL.ADMIN_BOARD} className="btn btn_blue_h46 w_100">목록</Link>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{/* <!--// 버튼영역 --> */}
|
||||||
{/* <!--// 버튼영역 --> */}
|
</Form>
|
||||||
</div>
|
</div>
|
||||||
</Modal.Body>
|
</Modal.Body>
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ function EgovAdminBoardList(props) {
|
||||||
if(item != undefined) {
|
if(item != undefined) {
|
||||||
item.mode = CODE.MODE_MODIFY;
|
item.mode = CODE.MODE_MODIFY;
|
||||||
}
|
}
|
||||||
setModalBody(<EgovAdminBoardEdit props={item}/>)
|
setModalBody(<EgovAdminBoardEdit props={item} reloadFunction={retrieveList}/>)
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("------------------------------EgovAdminBoardList [End]");
|
console.log("------------------------------EgovAdminBoardList [End]");
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,10 @@ package com.dbnt.kcscbackend.admin.boards;
|
||||||
|
|
||||||
import com.dbnt.kcscbackend.admin.boards.entity.TnBbs;
|
import com.dbnt.kcscbackend.admin.boards.entity.TnBbs;
|
||||||
import com.dbnt.kcscbackend.admin.boards.service.AdminBoardsService;
|
import com.dbnt.kcscbackend.admin.boards.service.AdminBoardsService;
|
||||||
|
import com.dbnt.kcscbackend.admin.config.entity.TcMenu;
|
||||||
|
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
||||||
import com.dbnt.kcscbackend.config.common.BaseController;
|
import com.dbnt.kcscbackend.config.common.BaseController;
|
||||||
|
import com.dbnt.kcscbackend.config.common.ResponseCode;
|
||||||
import com.dbnt.kcscbackend.config.common.ResultVO;
|
import com.dbnt.kcscbackend.config.common.ResultVO;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
|
|
@ -10,17 +13,22 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||||
|
import org.springframework.validation.Errors;
|
||||||
|
import org.springframework.validation.FieldError;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RequestMapping("/admin/boards")
|
@RequestMapping("/admin/boards")
|
||||||
@Tag(name="AdminBoardsController", description = "사이트관리 게시판현황")
|
@Tag(name = "AdminBoardsController", description = "사이트관리 게시판현황")
|
||||||
public class AdminBoardsController extends BaseController {
|
public class AdminBoardsController extends BaseController {
|
||||||
|
|
||||||
private final AdminBoardsService adminBoardsService;
|
private final AdminBoardsService adminBoardsService;
|
||||||
|
|
@ -45,23 +53,34 @@ public class AdminBoardsController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "게시판 단건 조회",
|
summary = "게시판 저장",
|
||||||
description = "게시판 단건 조회",
|
description = "게시판 저장",
|
||||||
tags = {"AdminBoardsController"}
|
tags = {"AdminConfigController"}
|
||||||
)
|
)
|
||||||
@ApiResponses(value = {
|
@ApiResponses(value = {
|
||||||
@ApiResponse(responseCode = "200", description = "조회 성공"),
|
@ApiResponse(responseCode = "200", description = "저장 성공"),
|
||||||
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||||
})
|
})
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "/board", consumes = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(method = RequestMethod.PUT, value = "/board-mgt")
|
||||||
public ResultVO getBoard(TnBbs tnBbs) throws Exception {
|
public ResultVO saveBoardMgt(@RequestBody @Valid TnBbs bbs, Errors errors, @AuthenticationPrincipal LoginVO user) {
|
||||||
ResultVO resultVO = new ResultVO();
|
ResultVO resultVO = new ResultVO();
|
||||||
Map<String, Object> resultMap = new HashMap<>();
|
if (user == null) {
|
||||||
|
resultVO.setResultCode(ResponseCode.TOKEN_EXPIRED.getCode());
|
||||||
System.out.println("@@@ : " + tnBbs.getBbsSeq());
|
} else {
|
||||||
|
if (errors.hasErrors()) {
|
||||||
resultMap.put("board", adminBoardsService.selectBoard(tnBbs.getBbsSeq()));
|
StringBuilder msg = new StringBuilder();
|
||||||
resultVO.setResult(resultMap);
|
for (FieldError error : errors.getFieldErrors()) {
|
||||||
|
msg.append(error.getDefaultMessage());
|
||||||
|
msg.append("\n");
|
||||||
|
}
|
||||||
|
resultVO.setResultCode(ResponseCode.INPUT_CHECK_ERROR.getCode());
|
||||||
|
resultVO.setResultMessage(msg.toString());
|
||||||
|
} else {
|
||||||
|
System.out.println("@@@ bbs.getBbsSeq() : " + bbs.getBbsSeq());
|
||||||
|
adminBoardsService.saveBoard(bbs, user.getId());
|
||||||
|
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
return resultVO;
|
return resultVO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@ import org.hibernate.annotations.DynamicInsert;
|
||||||
import org.hibernate.annotations.DynamicUpdate;
|
import org.hibernate.annotations.DynamicUpdate;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import java.time.LocalDate;
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
|
|
@ -22,22 +23,25 @@ public class TnBbs {
|
||||||
private Long bbsSeq;
|
private Long bbsSeq;
|
||||||
|
|
||||||
@Column(name = "bbs_id", nullable = false)
|
@Column(name = "bbs_id", nullable = false)
|
||||||
|
@NotBlank(message = "게시판 ID를 입력해주세요.")
|
||||||
private String bbsId;
|
private String bbsId;
|
||||||
|
|
||||||
@Column(name = "bbs_title", nullable = false)
|
@Column(name = "bbs_title", nullable = false)
|
||||||
|
@NotBlank(message = "게시판 이름을 입력해주세요.")
|
||||||
private String bbsTitle;
|
private String bbsTitle;
|
||||||
|
|
||||||
@Column(name = "bbs_desc")
|
@Column(name = "bbs_desc")
|
||||||
|
@NotBlank(message = "게시판 설명을 입력해주세요.")
|
||||||
private String bbsDesc;
|
private String bbsDesc;
|
||||||
|
|
||||||
@Column(name = "bbs_type")
|
@Column(name = "bbs_type")
|
||||||
private String bbsType;
|
private String bbsType;
|
||||||
|
|
||||||
@Column(name = "bbs_ans_yn", nullable = false)
|
@Column(name = "bbs_ans_yn", nullable = false)
|
||||||
private char bbsAnsYn;
|
private String bbsAnsYn;
|
||||||
|
|
||||||
@Column(name = "bbs_repl_yn", nullable = false)
|
@Column(name = "bbs_repl_yn", nullable = false)
|
||||||
private char bbsReplYn;
|
private String bbsReplYn;
|
||||||
|
|
||||||
@Column(name = "read_role_grp_id")
|
@Column(name = "read_role_grp_id")
|
||||||
private String readRoleGrpId;
|
private String readRoleGrpId;
|
||||||
|
|
@ -52,16 +56,16 @@ public class TnBbs {
|
||||||
private String frstCrtId;
|
private String frstCrtId;
|
||||||
|
|
||||||
@Column(name = "frst_crt_dt", nullable = false)
|
@Column(name = "frst_crt_dt", nullable = false)
|
||||||
private LocalDate frstCrtDt;
|
private LocalDateTime frstCrtDt;
|
||||||
|
|
||||||
@Column(name = "last_chg_id")
|
@Column(name = "last_chg_id")
|
||||||
private String lastChgId;
|
private String lastChgId;
|
||||||
|
|
||||||
@Column(name = "last_chg_dt")
|
@Column(name = "last_chg_dt")
|
||||||
private LocalDate lastChgDt;
|
private LocalDateTime lastChgDt;
|
||||||
|
|
||||||
@Column(name = "use_yn", nullable = false)
|
@Column(name = "use_yn", nullable = false)
|
||||||
private char useYn;
|
private String useYn;
|
||||||
|
|
||||||
@Column(name = "oldd_seq")
|
@Column(name = "oldd_seq")
|
||||||
private Long olddSeq;
|
private Long olddSeq;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,10 @@ 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 java.util.List;
|
||||||
|
|
||||||
public interface TnBbsRepository extends JpaRepository<TnBbs, Long> {
|
public interface TnBbsRepository extends JpaRepository<TnBbs, Long> {
|
||||||
|
|
||||||
|
List<TnBbs> findAllByOrderByBbsSeqDesc();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,9 @@ import com.dbnt.kcscbackend.admin.boards.repository.TnBbsRepository;
|
||||||
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;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
|
@ -15,8 +17,30 @@ public class AdminBoardsService extends EgovAbstractServiceImpl {
|
||||||
|
|
||||||
private final TnBbsRepository tnBbsRepository;
|
private final TnBbsRepository tnBbsRepository;
|
||||||
|
|
||||||
public List<TnBbs> selectBoardList() { return tnBbsRepository.findAll(); }
|
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
|
||||||
|
public void saveBoard(TnBbs bbs, String userId) {
|
||||||
|
|
||||||
|
if (bbs.getBbsSeq() == null) {
|
||||||
|
bbs.setFrstCrtDt(LocalDateTime.now());
|
||||||
|
bbs.setFrstCrtId(userId);
|
||||||
|
bbs.setBbsAnsYn("N");
|
||||||
|
bbs.setBbsReplYn("N");
|
||||||
|
bbs.setUseYn("Y");
|
||||||
|
tnBbsRepository.save(bbs);
|
||||||
|
} else {
|
||||||
|
TnBbs savedBoard = tnBbsRepository.findById(bbs.getBbsSeq()).orElse(null);
|
||||||
|
savedBoard.setBbsId(bbs.getBbsId());
|
||||||
|
savedBoard.setBbsTitle(bbs.getBbsTitle());
|
||||||
|
savedBoard.setBbsDesc(bbs.getBbsDesc());
|
||||||
|
//savedBoard.setUseYn("Y");
|
||||||
|
savedBoard.setLastChgId(userId);
|
||||||
|
savedBoard.setLastChgDt(LocalDateTime.now());
|
||||||
|
tnBbsRepository.save(savedBoard);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue