From df115a3b873eaa05437ade9d59ee1f3c66afa532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EC=84=9D=20=EC=B5=9C?= Date: Fri, 21 Apr 2023 16:53:15 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B3=B5=EC=9A=A9=EA=B2=8C=EC=8B=9C=ED=8C=90?= =?UTF-8?q?=20=EA=B2=8C=EC=8B=9C=EB=AC=BC=20=EC=82=AD=EC=A0=9C=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../publicBoard/PublicBoardController.java | 8 +++++- .../main/publicBoard/model/PublicBoard.java | 6 +++-- .../repository/PublicBoardRepository.java | 5 ++++ .../service/PublicBoardService.java | 5 ++++ .../mybatisMapper/PublicBoardMapper.xml | 5 ++-- .../static/js/publicBoard/publicBoard.js | 25 ++++++++++++++++++- .../static/js/publicBoard/reference.js | 2 +- .../resources/templates/fragments/header.html | 2 +- .../resources/templates/login/dashboard.html | 2 +- .../publicBoard/board/boardViewModal.html | 3 +++ .../publicBoard/notice/noticePage.html | 18 ++++++++----- .../publicBoard/notice/noticeViewModal.html | 3 +++ .../publicBoard/qna/qnaViewModal.html | 3 +++ .../reference/referenceEditModal.html | 15 +++-------- .../publicBoard/reference/referencePage.html | 6 ++--- .../reference/referenceViewModal.html | 25 +++++++++++-------- 16 files changed, 92 insertions(+), 41 deletions(-) diff --git a/src/main/java/com/dbnt/faisp/main/publicBoard/PublicBoardController.java b/src/main/java/com/dbnt/faisp/main/publicBoard/PublicBoardController.java index cc500ffd..d378cc16 100644 --- a/src/main/java/com/dbnt/faisp/main/publicBoard/PublicBoardController.java +++ b/src/main/java/com/dbnt/faisp/main/publicBoard/PublicBoardController.java @@ -71,7 +71,6 @@ public class PublicBoardController { mav.addObject("referenceList", publicBoardService.selectContentList(publicBoard)); publicBoard.setContentCnt(publicBoardService.selectContentListCnt(publicBoard)); publicBoard.setPaginationInfo(); - mav.addObject("tabStatusList", codeMgtService.selectCodeMgtList("RPC")); mav.addObject("searchParams", publicBoard); return mav; } @@ -142,6 +141,7 @@ public class PublicBoardController { } publicBoard = publicBoardService.selectPublicBoard(publicBoard.getPublicKey()); mav.addObject("userSeq", loginUser.getUserSeq()); + mav.addObject("userRole", loginUser.getUserRole()); mav.addObject("info", publicBoard); return mav; } @@ -173,4 +173,10 @@ public class PublicBoardController { public void deleteComment (@RequestBody PublicComment comment){ publicBoardService.deleteComment(comment.getPublicKey(), comment.getCommentKey()); } + + @PostMapping("/deletePublicBoard") + @ResponseBody + public void deletePublicBoard (@RequestBody PublicBoard board){ + publicBoardService.deletePublicBoard(board.getPublicKey()); + } } diff --git a/src/main/java/com/dbnt/faisp/main/publicBoard/model/PublicBoard.java b/src/main/java/com/dbnt/faisp/main/publicBoard/model/PublicBoard.java index 49ed7f8f..153a305c 100644 --- a/src/main/java/com/dbnt/faisp/main/publicBoard/model/PublicBoard.java +++ b/src/main/java/com/dbnt/faisp/main/publicBoard/model/PublicBoard.java @@ -46,8 +46,10 @@ public class PublicBoard extends BaseModel { private LocalDateTime wrtDt; @Column(name = "organ_chk") private String organChk; - @Column(name = "tab_status") - private String tabStatus; + @Column(name = "selected_tab") + private String selectedTab; + @Column(name = "status") + private String status; @Transient private Integer fileCnt; diff --git a/src/main/java/com/dbnt/faisp/main/publicBoard/repository/PublicBoardRepository.java b/src/main/java/com/dbnt/faisp/main/publicBoard/repository/PublicBoardRepository.java index a6c53d2c..c476e363 100644 --- a/src/main/java/com/dbnt/faisp/main/publicBoard/repository/PublicBoardRepository.java +++ b/src/main/java/com/dbnt/faisp/main/publicBoard/repository/PublicBoardRepository.java @@ -2,8 +2,13 @@ package com.dbnt.faisp.main.publicBoard.repository; import com.dbnt.faisp.main.publicBoard.model.PublicBoard; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; public interface PublicBoardRepository extends JpaRepository { + @Modifying(clearAutomatically = true) + @Query("update PublicBoard set status = :status where publicKey = :publicKey") + void bulkModifyingByPublicKeyToStatus(Integer publicKey, String status); } diff --git a/src/main/java/com/dbnt/faisp/main/publicBoard/service/PublicBoardService.java b/src/main/java/com/dbnt/faisp/main/publicBoard/service/PublicBoardService.java index a3f010d2..19753f97 100644 --- a/src/main/java/com/dbnt/faisp/main/publicBoard/service/PublicBoardService.java +++ b/src/main/java/com/dbnt/faisp/main/publicBoard/service/PublicBoardService.java @@ -104,6 +104,11 @@ public class PublicBoardService extends BaseService { publicCommentRepository.deleteById(new PublicComment.PublicCommentId(publicKey, commentKey)); } + @Transactional + public void deletePublicBoard(Integer publicKey) { + publicBoardRepository.bulkModifyingByPublicKeyToStatus(publicKey, "DST008"); + } + public FileInfo selectPublicFile(Integer publicKey, Integer fileSeq){ return publicFileRepository.findById(new PublicFile.PublicFileId(publicKey, fileSeq)).orElse(null); } diff --git a/src/main/resources/mybatisMapper/PublicBoardMapper.xml b/src/main/resources/mybatisMapper/PublicBoardMapper.xml index 73c630a0..c3a29d32 100644 --- a/src/main/resources/mybatisMapper/PublicBoardMapper.xml +++ b/src/main/resources/mybatisMapper/PublicBoardMapper.xml @@ -6,6 +6,7 @@ + status <> 'DST008' and a.public_type = #{publicType} @@ -24,8 +25,8 @@ and a.wrt_dt <= #{endDate}::date+1 - - and a.tab_status = #{tabStatus} + + and a.selected_tab = #{selectedTab} and a.public_key in ( diff --git a/src/main/resources/static/js/publicBoard/publicBoard.js b/src/main/resources/static/js/publicBoard/publicBoard.js index 9c406e87..87ef4ef1 100644 --- a/src/main/resources/static/js/publicBoard/publicBoard.js +++ b/src/main/resources/static/js/publicBoard/publicBoard.js @@ -79,6 +79,29 @@ $(document).on('click', '.deleteCommentBtn', function (){ }) }) +$(document).on('click', '#deleteBtn', function (){ + if(confirm("삭제하시겠습니까?\n되돌릴 수 없습니다.")){ + contentFade("in"); + $.ajax({ + type : 'POST', + data : JSON.stringify({publicKey: $("#viewModalPublicKey").val()}), + url : "/publicBoard/deletePublicBoard", + contentType: 'application/json', + beforeSend: function (xhr){ + xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); + }, + success : function(result) { + alert("삭제되었습니다."); + location.reload(); + }, + error : function(xhr, status) { + alert("삭제를 실패하였습니다.") + contentFade("out"); + } + }) + } +}) + function getEditModal(publicKey, publicType){ $.ajax({ url: '/publicBoard/editModal', @@ -156,7 +179,7 @@ function contentCheck(formId){ flag = false; } if($("#publicType").val()==="PLB003"){ - if(!$("#tabStatus").val()){ + if(!$("#selectedTab").val()){ alert("분류를 선택해주세요.") flag = false; } diff --git a/src/main/resources/static/js/publicBoard/reference.js b/src/main/resources/static/js/publicBoard/reference.js index e80e14b9..41ac0fa2 100644 --- a/src/main/resources/static/js/publicBoard/reference.js +++ b/src/main/resources/static/js/publicBoard/reference.js @@ -1,6 +1,6 @@ $(document).on('click', '.referenceTab', function (){ - location.href = "/publicBoard/referencePage?tabStatus="+$(this).attr('data-tabcd') + location.href = "/publicBoard/referencePage?selectedTab="+$(this).attr('data-tabcd') }) $(document).on('click', '#addReferenceBtn', function (){ diff --git a/src/main/resources/templates/fragments/header.html b/src/main/resources/templates/fragments/header.html index 479c1502..e389f4b6 100644 --- a/src/main/resources/templates/fragments/header.html +++ b/src/main/resources/templates/fragments/header.html @@ -39,7 +39,7 @@ 게시판