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 6f00a20b..cc500ffd 100644 --- a/src/main/java/com/dbnt/faisp/main/publicBoard/PublicBoardController.java +++ b/src/main/java/com/dbnt/faisp/main/publicBoard/PublicBoardController.java @@ -49,10 +49,8 @@ public class PublicBoardController { 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.setDownOrganCdList(loginUser.getDownOrganCdList()); + mav.addObject("mgtOrganList", loginUser.getDownOrganCdList()); publicBoard.setUpOrganCdList(loginUser.getUpOrganCdList()); mav.addObject("boardList", publicBoardService.selectContentList(publicBoard)); publicBoard.setContentCnt(publicBoardService.selectContentListCnt(publicBoard)); @@ -67,10 +65,8 @@ public class PublicBoardController { 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.setDownOrganCdList(loginUser.getDownOrganCdList()); + mav.addObject("mgtOrganList", loginUser.getDownOrganCdList()); publicBoard.setUpOrganCdList(loginUser.getUpOrganCdList()); mav.addObject("referenceList", publicBoardService.selectContentList(publicBoard)); publicBoard.setContentCnt(publicBoardService.selectContentListCnt(publicBoard)); @@ -86,10 +82,8 @@ public class PublicBoardController { 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.setDownOrganCdList(loginUser.getDownOrganCdList()); + mav.addObject("mgtOrganList", loginUser.getDownOrganCdList()); mav.addObject("qnaList", publicBoardService.selectContentList(publicBoard)); publicBoard.setContentCnt(publicBoardService.selectContentListCnt(publicBoard)); publicBoard.setPaginationInfo(); @@ -104,91 +98,79 @@ public class PublicBoardController { switch (publicBoard.getPublicType()) { case "PLB001": // 공지사항 mav = new ModelAndView("publicBoard/notice/noticeEditModal"); - 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 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.setWrtUserGrd(loginUser.getTitleCd()); - publicBoard.setWrtUserNm(loginUser.getUserNm()); - publicBoard.setWrtDt(LocalDateTime.now()); - } - 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": // 공용게시판 - 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; - } + if (publicBoard.getPublicKey() != null) { 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 < 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.setWrtUserGrd(loginUser.getTitleCd()); - 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()); + }else{ + publicBoard.setWrtOrgan(loginUser.getOgCd()); + publicBoard.setWrtPart(loginUser.getOfcCd()); + publicBoard.setWrtUserSeq(loginUser.getUserSeq()); + publicBoard.setWrtUserGrd(loginUser.getTitleCd()); + publicBoard.setWrtUserNm(loginUser.getUserNm()); + publicBoard.setWrtDt(LocalDateTime.now()); } + 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": // 공용게시판 + 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; + } + + @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.setWrtUserGrd(loginUser.getTitleCd()); + 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()); + } +} diff --git a/src/main/resources/templates/fragments/header.html b/src/main/resources/templates/fragments/header.html index 1149165c..4b0b5faa 100644 --- a/src/main/resources/templates/fragments/header.html +++ b/src/main/resources/templates/fragments/header.html @@ -2,7 +2,7 @@ -
+