From 3eb76f75df70fce2a381254ef2a764b52483063b Mon Sep 17 00:00:00 2001 From: Hyung Geun Date: Fri, 23 Sep 2022 16:48:55 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B3=B5=ED=86=B5=EA=B2=8C=EC=8B=9C=ED=8C=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/dbnt/faisp/config/FileInfo.java | 6 +- .../publicBoard/PublicBoardController.java | 184 +++++++++----- .../service/PublicBoardService.java | 4 +- .../resources/templates/fragments/header.html | 8 +- .../templates/publicBoard/qna/qnaPage.html | 237 ++++++++++++++---- 5 files changed, 325 insertions(+), 114 deletions(-) diff --git a/src/main/java/com/dbnt/faisp/config/FileInfo.java b/src/main/java/com/dbnt/faisp/config/FileInfo.java index 43fc9b12..ffb2120e 100644 --- a/src/main/java/com/dbnt/faisp/config/FileInfo.java +++ b/src/main/java/com/dbnt/faisp/config/FileInfo.java @@ -4,10 +4,6 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; -import javax.persistence.Column; -import javax.persistence.Transient; -import java.util.List; - @Getter @Setter @NoArgsConstructor @@ -22,4 +18,4 @@ public class FileInfo { public String getFullName(){ return getOrigNm()+"."+getFileExtn(); } -} +} \ No newline at end of file diff --git a/src/main/java/com/dbnt/faisp/publicBoard/PublicBoardController.java b/src/main/java/com/dbnt/faisp/publicBoard/PublicBoardController.java index 3b4f0d7f..ebf22e57 100644 --- a/src/main/java/com/dbnt/faisp/publicBoard/PublicBoardController.java +++ b/src/main/java/com/dbnt/faisp/publicBoard/PublicBoardController.java @@ -26,7 +26,7 @@ public class PublicBoardController { ModelAndView mav = new ModelAndView("publicBoard/notice/noticePage"); publicBoard.setQueryInfo(); publicBoard.setPublicType("PLB001"); - if(loginUser.getUserRole().contains(Role.SUB_ADMIN.getValue())){ + if (loginUser.getUserRole().contains(Role.SUB_ADMIN.getValue())) { publicBoard.setDownOrganCdList(loginUser.getDownOrganCdList()); mav.addObject("mgtOrganList", loginUser.getDownOrganCdList()); } @@ -38,79 +38,149 @@ public class PublicBoardController { return mav; } + @GetMapping("/boardPage") + public ModelAndView boardPage(@AuthenticationPrincipal UserInfo loginUser, PublicBoard publicBoard) { + ModelAndView mav = new ModelAndView("publicBoard/board/boardPage"); + publicBoard.setQueryInfo(); + publicBoard.setPublicType("PLB002"); + if (loginUser.getUserRole().contains(Role.SUB_ADMIN.getValue())) { + publicBoard.setDownOrganCdList(loginUser.getDownOrganCdList()); + mav.addObject("mgtOrganList", loginUser.getDownOrganCdList()); + } + publicBoard.setUpOrganCdList(loginUser.getUpOrganCdList()); + mav.addObject("boardList", publicBoardService.selectContentList(publicBoard)); + publicBoard.setContentCnt(publicBoardService.selectContentListCnt(publicBoard)); + publicBoard.setPaginationInfo(); + mav.addObject("searchParams", publicBoard); + return mav; + } + + + @GetMapping("/referencePage") + public ModelAndView referencePage(@AuthenticationPrincipal UserInfo loginUser, PublicBoard publicBoard) { + ModelAndView mav = new ModelAndView("publicBoard/reference/referencePage"); + publicBoard.setQueryInfo(); + publicBoard.setPublicType("PLB003"); + if (loginUser.getUserRole().contains(Role.SUB_ADMIN.getValue())) { + publicBoard.setDownOrganCdList(loginUser.getDownOrganCdList()); + mav.addObject("mgtOrganList", loginUser.getDownOrganCdList()); + } + publicBoard.setUpOrganCdList(loginUser.getUpOrganCdList()); + mav.addObject("referenceList", publicBoardService.selectContentList(publicBoard)); + publicBoard.setContentCnt(publicBoardService.selectContentListCnt(publicBoard)); + publicBoard.setPaginationInfo(); + mav.addObject("searchParams", publicBoard); + return mav; + } + + + @GetMapping("/qnaPage") + public ModelAndView qnaPage(@AuthenticationPrincipal UserInfo loginUser, PublicBoard publicBoard) { + ModelAndView mav = new ModelAndView("publicBoard/qna/qnaPage"); + publicBoard.setQueryInfo(); + publicBoard.setPublicType("PLB004"); + if (loginUser.getUserRole().contains(Role.SUB_ADMIN.getValue())) { + publicBoard.setDownOrganCdList(loginUser.getDownOrganCdList()); + mav.addObject("mgtOrganList", loginUser.getDownOrganCdList()); + } + publicBoard.setUpOrganCdList(loginUser.getUpOrganCdList()); + mav.addObject("qnaList", publicBoardService.selectContentList(publicBoard)); + publicBoard.setContentCnt(publicBoardService.selectContentListCnt(publicBoard)); + publicBoard.setPaginationInfo(); + mav.addObject("searchParams", publicBoard); + return mav; + } + + @GetMapping("/editModal") - public ModelAndView editModal(@AuthenticationPrincipal UserInfo loginUser, PublicBoard publicBoard){ + public ModelAndView editModal(@AuthenticationPrincipal UserInfo loginUser, PublicBoard publicBoard) { ModelAndView mav = null; - switch (publicBoard.getPublicType()){ + switch (publicBoard.getPublicType()) { case "PLB001": // 공지사항 mav = new ModelAndView("publicBoard/notice/noticeEditModal"); - if(publicBoard.getPublicKey()!=null){ + if (publicBoard.getPublicKey() != null) { publicBoard = publicBoardService.selectPublicBoard(publicBoard.getPublicKey()); } break; case "PLB002": // 공용게시판 + mav = new ModelAndView("publicBoard/board/boardEditModal"); + if (publicBoard.getPublicKey() != null) { + publicBoard = publicBoardService.selectPublicBoard(publicBoard.getPublicKey()); + } break; case "PLB003": // 자료실 + mav = new ModelAndView("publicBoard/reference/referenceEditModal"); + if (publicBoard.getPublicKey() != null) { + publicBoard = publicBoardService.selectPublicBoard(publicBoard.getPublicKey()); + } break; case "PLB004": // Q&A - break; + mav = new ModelAndView("publicBoard/qna/qnaEditModal"); + if (publicBoard.getPublicKey() != null) { + publicBoard = publicBoardService.selectPublicBoard(publicBoard.getPublicKey()); + break; + } } - if(publicBoard.getPublicKey()==null){ - publicBoard.setWrtOrgan(loginUser.getOgCd()); - publicBoard.setWrtPart(loginUser.getOfcCd()); - publicBoard.setWrtUserSeq(loginUser.getUserSeq()); - publicBoard.setWrtUserNm(loginUser.getUserNm()); - publicBoard.setWrtDt(LocalDateTime.now()); + if (publicBoard.getPublicKey() == null) { + publicBoard.setWrtOrgan(loginUser.getOgCd()); + publicBoard.setWrtPart(loginUser.getOfcCd()); + publicBoard.setWrtUserSeq(loginUser.getUserSeq()); + publicBoard.setWrtUserNm(loginUser.getUserNm()); + publicBoard.setWrtDt(LocalDateTime.now()); + } + mav.addObject("info", publicBoard); + return mav; } - mav.addObject("info", publicBoard); - return mav; - } - @GetMapping("/viewModal") - public ModelAndView viewModal(@AuthenticationPrincipal UserInfo loginUser, PublicBoard publicBoard){ - ModelAndView mav = null; - switch (publicBoard.getPublicType()){ - case "PLB001": // 공지사항 - mav = new ModelAndView("publicBoard/notice/noticeViewModal"); - break; - case "PLB002": // 공용게시판 - break; - case "PLB003": // 자료실 - break; - case "PLB004": // Q&A - break; + + @GetMapping("/viewModal") + public ModelAndView viewModal (@AuthenticationPrincipal UserInfo loginUser, PublicBoard publicBoard){ + ModelAndView mav = null; + switch (publicBoard.getPublicType()) { + case "PLB001": // 공지사항 + mav = new ModelAndView("publicBoard/notice/noticeViewModal"); + break; + case "PLB002": // 공용게시판 + mav = new ModelAndView("publicBoard/board/boardViewModal"); + break; + case "PLB003": // 자료실 + mav = new ModelAndView("publicBoard/reference/referenceViewModal"); + break; + case "PLB004": // Q&A + mav = new ModelAndView("publicBoard/qna/qnaViewModal"); + break; + } + publicBoard = publicBoardService.selectPublicBoard(publicBoard.getPublicKey()); + mav.addObject("userSeq", loginUser.getUserSeq()); + mav.addObject("info", publicBoard); + return mav; } - publicBoard = publicBoardService.selectPublicBoard(publicBoard.getPublicKey()); - mav.addObject("userSeq", loginUser.getUserSeq()); - mav.addObject("info", publicBoard); - return mav; - } - @PostMapping("/saveContent") - public Integer saveContent(PublicBoard publicBoard, - MultipartHttpServletRequest request, - @RequestParam(value = "fileSeq", required = false) List deleteFileSeq){ - publicBoard.setMultipartFileList(request.getMultiFileMap().get("uploadFiles")); - return publicBoardService.saveContent(publicBoard, deleteFileSeq); - } - @PostMapping("/saveComment") - public ModelAndView saveComment(@AuthenticationPrincipal UserInfo loginUser, PublicComment comment){ - comment.setWrtOrgan(loginUser.getOgCd()); - comment.setWrtPart(loginUser.getOfcCd()); - comment.setWrtUserSeq(loginUser.getUserSeq()); - comment.setWrtUserNm(loginUser.getUserNm()); - comment.setWrtDt(LocalDateTime.now()); - publicBoardService.saveComment(comment); - ModelAndView mav = new ModelAndView("publicBoard/commentDiv"); - mav.addObject("comment", comment); - mav.addObject("userSeq", loginUser.getUserSeq()); - return mav; - } + @PostMapping("/saveContent") + public Integer saveContent (PublicBoard publicBoard, + MultipartHttpServletRequest request, + @RequestParam(value = "fileSeq", required = false) List < Integer > deleteFileSeq){ + publicBoard.setMultipartFileList(request.getMultiFileMap().get("uploadFiles")); + return publicBoardService.saveContent(publicBoard, deleteFileSeq); + } + @PostMapping("/saveComment") + public ModelAndView saveComment (@AuthenticationPrincipal UserInfo loginUser, PublicComment comment){ + comment.setWrtOrgan(loginUser.getOgCd()); + comment.setWrtPart(loginUser.getOfcCd()); + comment.setWrtUserSeq(loginUser.getUserSeq()); + comment.setWrtUserNm(loginUser.getUserNm()); + comment.setWrtDt(LocalDateTime.now()); + publicBoardService.saveComment(comment); + ModelAndView mav = new ModelAndView("publicBoard/commentDiv"); + mav.addObject("comment", comment); + mav.addObject("userSeq", loginUser.getUserSeq()); + return mav; + } - @PostMapping("/deleteComment") - @ResponseBody - public void deleteComment(@RequestBody PublicComment comment){ - publicBoardService.deleteComment(comment.getPublicKey(), comment.getCommentKey()); + @PostMapping("/deleteComment") + @ResponseBody + public void deleteComment (@RequestBody PublicComment comment){ + publicBoardService.deleteComment(comment.getPublicKey(), comment.getCommentKey()); + } } -} diff --git a/src/main/java/com/dbnt/faisp/publicBoard/service/PublicBoardService.java b/src/main/java/com/dbnt/faisp/publicBoard/service/PublicBoardService.java index 30b8e259..bc95bafd 100644 --- a/src/main/java/com/dbnt/faisp/publicBoard/service/PublicBoardService.java +++ b/src/main/java/com/dbnt/faisp/publicBoard/service/PublicBoardService.java @@ -6,8 +6,8 @@ import com.dbnt.faisp.publicBoard.mapper.PublicBoardMapper; import com.dbnt.faisp.publicBoard.model.PublicBoard; import com.dbnt.faisp.publicBoard.model.PublicComment; import com.dbnt.faisp.publicBoard.model.PublicFile; -import com.dbnt.faisp.publicBoard.repository.PublicCommentRepository; import com.dbnt.faisp.publicBoard.repository.PublicBoardRepository; +import com.dbnt.faisp.publicBoard.repository.PublicCommentRepository; import com.dbnt.faisp.publicBoard.repository.PublicFileRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -107,4 +107,4 @@ public class PublicBoardService extends BaseService { public FileInfo selectPublicFile(Integer publicKey, Integer fileSeq){ return publicFileRepository.findById(new PublicFile.PublicFileId(publicKey, fileSeq)).orElse(null); } -} +} \ No newline at end of file diff --git a/src/main/resources/templates/fragments/header.html b/src/main/resources/templates/fragments/header.html index 4f10c14d..1b506e60 100644 --- a/src/main/resources/templates/fragments/header.html +++ b/src/main/resources/templates/fragments/header.html @@ -28,10 +28,10 @@ diff --git a/src/main/resources/templates/publicBoard/qna/qnaPage.html b/src/main/resources/templates/publicBoard/qna/qnaPage.html index 6cf62110..593074ab 100644 --- a/src/main/resources/templates/publicBoard/qna/qnaPage.html +++ b/src/main/resources/templates/publicBoard/qna/qnaPage.html @@ -4,11 +4,12 @@ xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout/layout}"> - + +
-

Q&A

+

QnA

@@ -25,8 +26,8 @@
- +
@@ -76,37 +61,30 @@ 제목 - 시행일자 관서 부서 작성자 작성일시 첨부파일 - 상태 + 댓글 - + + + + + @@ -138,7 +116,7 @@
- +
@@ -150,19 +128,186 @@ -