공지사항 페이지 작업중.

강석 최 2022-09-19 18:20:49 +09:00
parent 51c97c2905
commit fab8efdbfc
21 changed files with 782 additions and 107 deletions

View File

@ -3,8 +3,10 @@ package com.dbnt.faisp.config;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.File; import java.io.File;
import java.io.IOException;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@ -26,4 +28,23 @@ public class BaseService {
public void deleteStoredFile(File deleteFile){ public void deleteStoredFile(File deleteFile){
deleteFile.delete(); deleteFile.delete();
} }
public void saveFile(MultipartFile file, File saveFile){
if(file.getSize()!=0){ // 저장될 파일 확인
if(!saveFile.exists()){ // 저장될 경로 확인
if(saveFile.getParentFile().mkdirs()){
try{
saveFile.createNewFile();
}catch (IOException e){
e.printStackTrace();
}
}
}
try {
file.transferTo(saveFile);
}catch (IllegalStateException | IOException e){
e.printStackTrace();
}
}
}
} }

View File

@ -1,15 +0,0 @@
package com.dbnt.faisp.config;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
@Getter
public enum BoardType {
NOTICE("NOTICE"),
BOARD("BOARD"),
FILES("FILES"),
QNA("Q&A");
private String value;
}

View File

@ -9,5 +9,5 @@ import java.util.Optional;
public interface PlanFileRepository extends JpaRepository<PlanFile, PlanFile.PlanFileId> { public interface PlanFileRepository extends JpaRepository<PlanFile, PlanFile.PlanFileId> {
List<PlanFile> findByPlanKey(Integer planKey); List<PlanFile> findByPlanKey(Integer planKey);
Optional<PlanFile> findByPlanKeyOrderByFileSeqDesc(Integer planKey); Optional<PlanFile> findTopByPlanKeyOrderByFileSeqDesc(Integer planKey);
} }

View File

@ -76,29 +76,12 @@ public class MonthPlanService extends BaseService {
} }
private void saveUploadFiles(Integer planKey, List<MultipartFile> multipartFileList){ private void saveUploadFiles(Integer planKey, List<MultipartFile> multipartFileList){
PlanFile lastFileInfo = planFileRepository.findByPlanKeyOrderByFileSeqDesc(planKey).orElse(null); PlanFile lastFileInfo = planFileRepository.findTopByPlanKeyOrderByFileSeqDesc(planKey).orElse(null);
int fileSeq = lastFileInfo==null?1:(lastFileInfo.getFileSeq()+1); int fileSeq = lastFileInfo==null?1:(lastFileInfo.getFileSeq()+1);
for(MultipartFile file : multipartFileList){ for(MultipartFile file : multipartFileList){
String saveName = UUID.randomUUID().toString(); String saveName = UUID.randomUUID().toString();
String path = locationPath+File.separator+"monthPlan"+File.separator; String path = locationPath+File.separator+"monthPlan"+File.separator;
saveFile(file, new File(path+File.separator+saveName));
File saveFile = new File(path+File.separator+saveName);
if(file.getSize()!=0){ // 저장될 파일 확인
if(!saveFile.exists()){ // 저장될 경로 확인
if(saveFile.getParentFile().mkdirs()){
try{
saveFile.createNewFile();
}catch (IOException e){
e.printStackTrace();
}
}
}
try {
file.transferTo(saveFile);
}catch (IllegalStateException | IOException e){
e.printStackTrace();
}
}
String originalFilename = file.getOriginalFilename(); String originalFilename = file.getOriginalFilename();
int extnIdx = originalFilename.lastIndexOf("."); int extnIdx = originalFilename.lastIndexOf(".");

View File

@ -1,19 +1,18 @@
package com.dbnt.faisp.publicBoard; package com.dbnt.faisp.publicBoard;
import com.dbnt.faisp.config.BoardType;
import com.dbnt.faisp.config.Role; import com.dbnt.faisp.config.Role;
import com.dbnt.faisp.fpiMgt.monthPlan.model.PlanBoard;
import com.dbnt.faisp.publicBoard.model.PublicBoard; import com.dbnt.faisp.publicBoard.model.PublicBoard;
import com.dbnt.faisp.publicBoard.model.PublicComment;
import com.dbnt.faisp.publicBoard.service.PublicBoardService; import com.dbnt.faisp.publicBoard.service.PublicBoardService;
import com.dbnt.faisp.userInfo.model.UserInfo; import com.dbnt.faisp.userInfo.model.UserInfo;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.HashMap; import java.util.List;
import java.util.Map;
@RestController @RestController
@ -24,11 +23,12 @@ public class PublicBoardController {
@GetMapping("/noticePage") @GetMapping("/noticePage")
public ModelAndView organMgtPage(@AuthenticationPrincipal UserInfo loginUser, PublicBoard publicBoard) { public ModelAndView organMgtPage(@AuthenticationPrincipal UserInfo loginUser, PublicBoard publicBoard) {
ModelAndView mav = new ModelAndView("publicBoard/notice"); ModelAndView mav = new ModelAndView("publicBoard/notice/noticePage");
publicBoard.setQueryInfo(); publicBoard.setQueryInfo();
publicBoard.setPublicType(BoardType.NOTICE.getValue()); publicBoard.setPublicType("PLB001");
if(loginUser.getAuthorities().contains(Role.SUB_ADMIN)){ if(loginUser.getUserRole().contains(Role.SUB_ADMIN.getValue())){
publicBoard.setOrganCdList(loginUser.getOrganCdList()); publicBoard.setOrganCdList(loginUser.getOrganCdList());
mav.addObject("mgtOrganList", loginUser.getOrganCdList());
} }
mav.addObject("noticeList", publicBoardService.selectContentList(publicBoard)); mav.addObject("noticeList", publicBoardService.selectContentList(publicBoard));
publicBoard.setContentCnt(publicBoardService.selectContentListCnt(publicBoard)); publicBoard.setContentCnt(publicBoardService.selectContentListCnt(publicBoard));
@ -39,10 +39,23 @@ public class PublicBoardController {
@GetMapping("/editModal") @GetMapping("/editModal")
public ModelAndView editModal(@AuthenticationPrincipal UserInfo loginUser, PublicBoard publicBoard){ public ModelAndView editModal(@AuthenticationPrincipal UserInfo loginUser, PublicBoard publicBoard){
ModelAndView mav = new ModelAndView("publicBoard/editModal"); ModelAndView mav = null;
if(publicBoard.getPublicKey()!=null){ switch (publicBoard.getPublicType()){
publicBoard = publicBoardService.selectPublicBoard(publicBoard.getPublicKey()); case "PLB001": // 공지사항
}else{ mav = new ModelAndView("publicBoard/notice/noticeEditModal");
if(publicBoard.getPublicKey()!=null){
publicBoard = publicBoardService.selectPublicBoard(publicBoard.getPublicKey());
}
break;
case "PLB002": // 공용게시판
break;
case "PLB003": // 자료실
break;
case "PLB004": // Q&A
break;
}
if(publicBoard.getPublicKey()==null){
publicBoard.setWrtOrgan(loginUser.getOgCd()); publicBoard.setWrtOrgan(loginUser.getOgCd());
publicBoard.setWrtPart(loginUser.getOfcCd()); publicBoard.setWrtPart(loginUser.getOfcCd());
publicBoard.setWrtUserSeq(loginUser.getUserSeq()); publicBoard.setWrtUserSeq(loginUser.getUserSeq());
@ -53,12 +66,46 @@ public class PublicBoardController {
return mav; return mav;
} }
@GetMapping("/planViewModal") @GetMapping("/viewModal")
public ModelAndView planViewModal(@AuthenticationPrincipal UserInfo loginUser, PublicBoard publicBoard){ public ModelAndView viewModal(@AuthenticationPrincipal UserInfo loginUser, PublicBoard publicBoard){
ModelAndView mav = new ModelAndView("publicBoard/viewModal"); 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;
}
publicBoard = publicBoardService.selectPublicBoard(publicBoard.getPublicKey()); publicBoard = publicBoardService.selectPublicBoard(publicBoard.getPublicKey());
mav.addObject("userSeq", loginUser.getUserSeq());
mav.addObject("info", publicBoard); mav.addObject("info", publicBoard);
return mav; 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 Integer 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());
return publicBoardService.saveComment(comment);
}
@PostMapping("/deleteComment")
@ResponseBody
public void deleteComment(Integer publicKey, Integer commentKey){
publicBoardService.deleteComment(publicKey, commentKey);
}
} }

View File

@ -6,9 +6,12 @@ import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate; import org.hibernate.annotations.DynamicUpdate;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.multipart.MultipartFile;
import javax.persistence.*; import javax.persistence.*;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
@Getter @Getter
@Setter @Setter
@ -37,6 +40,19 @@ public class PublicBoard extends BaseModel {
@Column(name = "wrt_user_nm") @Column(name = "wrt_user_nm")
private String wrtUserNm; private String wrtUserNm;
@Column(name = "wrt_dt") @Column(name = "wrt_dt")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
private LocalDateTime wrtDt; private LocalDateTime wrtDt;
@Column(name = "organ_chk")
private String organChk;
@Transient
private Integer fileCnt;
@Transient
private Integer commentCnt;
@Transient
private List<PublicFile> fileList;
@Transient
private List<PublicComment> commentList;
@Transient
private List<MultipartFile> multipartFileList;
} }

View File

@ -7,6 +7,7 @@ import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
@Getter @Getter
@Setter @Setter
@ -14,25 +15,23 @@ import java.time.LocalDateTime;
@NoArgsConstructor @NoArgsConstructor
@DynamicInsert @DynamicInsert
@DynamicUpdate @DynamicUpdate
@Table(name = "public_board_comment") @Table(name = "public_comment")
@IdClass(PublicBoardComment.PublicBoardCommentId.class) @IdClass(PublicComment.PublicCommentId.class)
public class PublicBoardComment { public class PublicComment {
@Id @Id
@Column(name = "public_key") @Column(name = "public_key")
private Integer publicKey; private Integer publicKey;
@Id @Id
@Column(name = "comment_key") @Column(name = "comment_key")
private Integer commentKey; private Integer commentKey;
@Column(name = "public_type") @Column(name = "comment")
private String public_type; private String comment;
@Column(name = "content")
private String content;
@Column(name = "wrt_organ") @Column(name = "wrt_organ")
private String wrtOrgan; private String wrtOrgan;
@Column(name = "wrt_part") @Column(name = "wrt_part")
private String wrtPart; private String wrtPart;
@Column(name = "wrt_user_seq") @Column(name = "wrt_user_seq")
private String wrtUserSeq; private Integer wrtUserSeq;
@Column(name = "wrt_user_nm") @Column(name = "wrt_user_nm")
private String wrtUserNm; private String wrtUserNm;
@Column(name = "wrt_dt") @Column(name = "wrt_dt")
@ -40,11 +39,14 @@ public class PublicBoardComment {
@Column(name = "parent_comment") @Column(name = "parent_comment")
private Integer parentComment; private Integer parentComment;
@Transient
private List<PublicComment> childCommentList;
@Embeddable @Embeddable
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public static class PublicBoardCommentId implements Serializable { public static class PublicCommentId implements Serializable {
private Integer publicKey; private Integer publicKey;
private Integer commentKey; private Integer commentKey;
} }

View File

@ -14,7 +14,7 @@ import java.io.Serializable;
@NoArgsConstructor @NoArgsConstructor
@DynamicInsert @DynamicInsert
@DynamicUpdate @DynamicUpdate
@Table(name = "plan_file") @Table(name = "public_file")
@IdClass(PublicFile.PublicFileId.class) @IdClass(PublicFile.PublicFileId.class)
public class PublicFile extends FileInfo { public class PublicFile extends FileInfo {
@Id @Id

View File

@ -1,9 +0,0 @@
package com.dbnt.faisp.publicBoard.repository;
import com.dbnt.faisp.publicBoard.model.PublicBoardComment;
import org.springframework.data.jpa.repository.JpaRepository;
public interface PublicBoardCommentRepository extends JpaRepository<PublicBoardComment, PublicBoardComment.PublicBoardCommentId> {
}

View File

@ -0,0 +1,15 @@
package com.dbnt.faisp.publicBoard.repository;
import com.dbnt.faisp.publicBoard.model.PublicComment;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
import java.util.Optional;
public interface PublicCommentRepository extends JpaRepository<PublicComment, PublicComment.PublicCommentId> {
List<PublicComment> findByPublicKeyAndParentCommentOrderByCommentKeyAsc(Integer publicKey, Integer parentComment);
Optional<PublicComment> findTopByPublicKeyOrderByCommentKeyDesc(Integer publicKey);
}

View File

@ -3,7 +3,12 @@ package com.dbnt.faisp.publicBoard.repository;
import com.dbnt.faisp.publicBoard.model.PublicFile; import com.dbnt.faisp.publicBoard.model.PublicFile;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
import java.util.Optional;
public interface PublicFileRepository extends JpaRepository<PublicFile, PublicFile.PublicFileId> { public interface PublicFileRepository extends JpaRepository<PublicFile, PublicFile.PublicFileId> {
List<PublicFile> findByPublicKey(Integer publicKey);
Optional<PublicFile> findTopByPublicKeyOrderByFileSeq(Integer publicKey);
} }

View File

@ -1,21 +1,28 @@
package com.dbnt.faisp.publicBoard.service; package com.dbnt.faisp.publicBoard.service;
import com.dbnt.faisp.config.BaseService;
import com.dbnt.faisp.publicBoard.mapper.PublicBoardMapper; import com.dbnt.faisp.publicBoard.mapper.PublicBoardMapper;
import com.dbnt.faisp.publicBoard.model.PublicBoard; import com.dbnt.faisp.publicBoard.model.PublicBoard;
import com.dbnt.faisp.publicBoard.repository.PublicBoardCommentRepository; 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.PublicBoardRepository;
import com.dbnt.faisp.publicBoard.repository.PublicFileRepository; import com.dbnt.faisp.publicBoard.repository.PublicFileRepository;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.util.List; import java.util.List;
import java.util.UUID;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class PublicBoardService { public class PublicBoardService extends BaseService {
private final PublicBoardRepository publicBoardRepository; private final PublicBoardRepository publicBoardRepository;
private final PublicBoardCommentRepository publicBoardCommentRepository; private final PublicCommentRepository publicCommentRepository;
private final PublicFileRepository publicFileRepository; private final PublicFileRepository publicFileRepository;
private final PublicBoardMapper publicBoardMapper; private final PublicBoardMapper publicBoardMapper;
@ -28,6 +35,71 @@ public class PublicBoardService {
} }
public PublicBoard selectPublicBoard(Integer publicKey) { public PublicBoard selectPublicBoard(Integer publicKey) {
return publicBoardRepository.findById(publicKey).orElse(null); PublicBoard publicBoard = publicBoardRepository.findById(publicKey).orElse(null);
publicBoard.setFileList(publicFileRepository.findByPublicKey(publicKey));
List<PublicComment> commentList = publicCommentRepository.findByPublicKeyAndParentCommentOrderByCommentKeyAsc(publicKey, null);
for(PublicComment comment: commentList){
comment.setChildCommentList(publicCommentRepository.findByPublicKeyAndParentCommentOrderByCommentKeyAsc(publicKey, comment.getCommentKey()));
}
publicBoard.setCommentList(commentList);
return publicBoard;
}
@Transactional
public Integer saveContent(PublicBoard publicBoard, List<Integer> deleteFileSeq) {
Integer publicKey = publicBoardRepository.save(publicBoard).getPublicKey();
if(deleteFileSeq!=null && deleteFileSeq.size()>0){
deletePublicFile(publicKey, deleteFileSeq);
}
if(publicBoard.getMultipartFileList()!= null){
saveUploadFiles(publicKey, publicBoard.getMultipartFileList());
}
return publicKey;
}
private void saveUploadFiles(Integer publicKey, List<MultipartFile> multipartFileList) {
PublicFile lastFileInfo = publicFileRepository.findTopByPublicKeyOrderByFileSeq(publicKey).orElse(null);
int fileSeq = lastFileInfo==null?1:(lastFileInfo.getFileSeq()+1);
for(MultipartFile file : multipartFileList){
String saveName = UUID.randomUUID().toString();
String path = locationPath+File.separator+"publicFile"+File.separator;
saveFile(file, new File(path+File.separator+saveName));
String originalFilename = file.getOriginalFilename();
int extnIdx = originalFilename.lastIndexOf(".");
PublicFile fileInfo = new PublicFile();
fileInfo.setPublicKey(publicKey);
fileInfo.setFileSeq(fileSeq++);
fileInfo.setOrigNm(originalFilename.substring(0, extnIdx));
fileInfo.setFileExtn(originalFilename.substring(extnIdx+1));
fileInfo.setConvNm(saveName);
fileInfo.setFileSize(calculationSize(file.getSize()));
fileInfo.setSavePath(path);
publicFileRepository.save(fileInfo);
}
}
private void deletePublicFile(Integer publicKey, List<Integer> deleteFileSeq) {
List<PublicFile> publicFileList = publicFileRepository.findByPublicKey(publicKey);
for(PublicFile file: publicFileList){
if(deleteFileSeq.contains(file.getFileSeq())){
deleteStoredFile(new File(file.getSavePath(), file.getConvNm()));
publicFileRepository.delete(file);
}
}
}
public Integer saveComment(PublicComment comment) {
PublicComment lastComment = publicCommentRepository
.findTopByPublicKeyOrderByCommentKeyDesc(comment.getPublicKey()).orElse(null);
comment.setCommentKey(lastComment==null?1:(lastComment.getCommentKey()+1));
return publicCommentRepository.save(comment).getCommentKey();
}
@Transactional
public void deleteComment(Integer publicKey, Integer commentKey) {
List<PublicComment> childList = publicCommentRepository.findByPublicKeyAndParentCommentOrderByCommentKeyAsc(publicKey, commentKey);
publicCommentRepository.deleteAll(childList);
publicCommentRepository.deleteById(new PublicComment.PublicCommentId(publicKey, commentKey));
} }
} }

View File

@ -33,6 +33,7 @@
a.wrt_user_nm, a.wrt_user_nm,
a.wrt_user_seq, a.wrt_user_seq,
a.wrt_dt, a.wrt_dt,
a.organ_chk,
b.fileCnt, b.fileCnt,
c.commentCnt c.commentCnt
from public_board a from public_board a
@ -43,7 +44,7 @@
on a.public_key = b.public_key on a.public_key = b.public_key
left outer join (select public_key, left outer join (select public_key,
count(comment_key) as commentCnt count(comment_key) as commentCnt
from public_board_comment from public_comment
group by public_key) c group by public_key) c
on a.public_key = c.public_key on a.public_key = c.public_key
<include refid="selectContentListWhere"></include> <include refid="selectContentListWhere"></include>

View File

@ -88,4 +88,39 @@ $(document).on('click', '.fileDownLink', function (){
url += "&parentKey="+Number($("#viewModalPlanKey").val()); url += "&parentKey="+Number($("#viewModalPlanKey").val());
url += "&fileSeq="+$(this).attr("data-fileseq"); url += "&fileSeq="+$(this).attr("data-fileseq");
window.open(encodeURI(url)); window.open(encodeURI(url));
}) })
function setUploadDiv(){
files = [];
$("#uploadDiv").on("dragenter", function(e) {
// $(this).addClass('drag-over');
}).on("dragleave", function(e) {
// $(this).removeClass('drag-over');
}).on("dragover", function(e) {
e.stopPropagation();
e.preventDefault();
}).on('drop', function(e) {
e.preventDefault();
// $(this).removeClass('drag-over');
for(const file of e.originalEvent.dataTransfer.files){
setFileDiv(file, files.push(file));
}
}).on('click', function (e){
if(e.target.className.indexOf("ileDelete")<0){
$("#fileInputer").click();
}
});
}
function setFileDiv(file, idx){
const uploadDiv = $("#uploadDiv");
if($(".uploadedFileDelete").length===0 && $(".fileDelete").length === 0){
uploadDiv.empty();
}
let fileInfo = "<div class='row-col-6'>";
fileInfo += file.name+" "+byteCalculation(file.size)+" ";
fileInfo += "<a href='#' class='fileDelete text-danger text-decoration-none' data-fileidx='"+(idx-1)+"'>삭제</a>";
fileInfo += "</div>";
uploadDiv.append(fileInfo);
}

View File

@ -81,27 +81,6 @@ function getEditModal(planKey){
} }
}); });
} }
function setUploadDiv(){
files = [];
$("#uploadDiv").on("dragenter", function(e) {
// $(this).addClass('drag-over');
}).on("dragleave", function(e) {
// $(this).removeClass('drag-over');
}).on("dragover", function(e) {
e.stopPropagation();
e.preventDefault();
}).on('drop', function(e) {
e.preventDefault();
// $(this).removeClass('drag-over');
for(const file of e.originalEvent.dataTransfer.files){
setFileDiv(file, files.push(file));
}
}).on('click', function (e){
if(e.target.className.indexOf("ileDelete")<0){
$("#fileInputer").click();
}
});
}
function savePlan(planState){ function savePlan(planState){
if(contentCheck()){ if(contentCheck()){
if(confirm("저장하시겠습니까?")){ if(confirm("저장하시겠습니까?")){
@ -136,17 +115,6 @@ function savePlan(planState){
} }
} }
function setFileDiv(file, idx){
const uploadDiv = $("#uploadDiv");
if($(".uploadedFileDelete").length===0 && $(".fileDelete").length === 0){
uploadDiv.empty();
}
let fileInfo = "<div class='row-col-6'>";
fileInfo += file.name+" "+byteCalculation(file.size)+" ";
fileInfo += "<a href='#' class='fileDelete text-danger text-decoration-none' data-fileidx='"+(idx-1)+"'>삭제</a>";
fileInfo += "</div>";
uploadDiv.append(fileInfo);
}
function contentCheck(){ function contentCheck(){
let flag = true; let flag = true;

View File

@ -0,0 +1,15 @@
let files = [];
$(document).on('click', '#addNoticeBtn', function (){
getEditModal(null, "PLB001")
})
$(document).on('click', '.planTr', function (){
$(".trChkBox").prop("checked", false);
$(this).find(".trChkBox").prop("checked", true);
getViewModal(Number($(this).find(".planKey").val()), "PLB001");
})
$(document).on('click', '#saveBtn', function (){
savePublicBoard("noticeEditForm")
})

View File

@ -0,0 +1,167 @@
$(document).on('click', '#commentSaveBtn', function (){
if(!$("#comment").val()) {
alert("댓글을 입력해주세요.")
}else{
if (confirm("등록하시겠습니까?")) {
contentFade("in")
const formData = new FormData($("#commentForm")[0]);
$.ajax({
type : 'POST',
data : formData,
url : "/publicBoard/saveComment",
processData: false,
contentType: false,
beforeSend: function (xhr){
xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
},
success : function(result) {
alert("저장되었습니다.");
contentFade("out");
},
error : function(xhr, status) {
alert("저장에 실패하였습니다.")
contentFade("out");
}
})
}
}
})
$(document).on('click', '.childCommentBtn', function (){
const childCommentDiv = $(this).parents(".commentRow").find(".childCommentDiv")
childCommentDiv.show();
$("#parentComment").val($(this).parents(".commentRow").find(".commentKey").val());
childCommentDiv.empty().append($("#commentForm"))
})
$(document).on('click', '.deleteCommentBtn', function (){
const publicKey = $(this).parents(".commentRow").find(".publicKey");
const commentKey = $(this).parents(".commentRow").find(".commentKey");
$.ajax({
type : 'POST',
data : {publicKey: publicKey, commentKey: commentKey},
url : "/publicBoard/deleteComment",
beforeSend: function (xhr){
xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
},
success : function(result) {
alert("삭제되었습니다.");
contentFade("out");
},
error : function(xhr, status) {
alert("삭제를 실패하였습니다.")
contentFade("out");
}
})
})
function getEditModal(publicKey, publicType){
$.ajax({
url: '/publicBoard/editModal',
data: {publicKey: publicKey, publicType: publicType},
type: 'GET',
dataType:"html",
success: function(html){
$("#editContent").empty().append(html)
$("#content").summernote({
lang:'ko-KR',
height: 350,
disableDragAndDrop: true,
toolbar: [
['style', ['style']],
['font', ['bold', 'underline', 'clear']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['table', ['table']]
]
});
setUploadDiv();
$("#editModal").modal('show');
},
error:function(){
}
});
}
function getViewModal(publicKey, publicType){
$.ajax({
url: '/publicBoard/viewModal',
data: {publicKey: publicKey, publicType: publicType},
type: 'GET',
dataType:"html",
success: function(html){
$("#viewContent").empty().append(html)
$("#comment").summernote({
lang:'ko-KR',
height: 100,
disableDragAndDrop: true,
toolbar: [
['style', ['style']],
['font', ['bold', 'underline', 'clear']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['table', ['table']]
]
});
$("#viewModal").modal('show');
},
error:function(){
}
});
}
function savePublicBoard(formId){
if(contentCheck(formId)){
if(confirm("저장하시겠습니까?")){
contentFade("in");
const formData = new FormData($("#"+formId)[0]);
for(const file of files) {
if(!file.isDelete)
formData.append('uploadFiles', file, file.name);
}
$(".text-decoration-line-through").each(function (idx, el){
formData.append('fileSeq', $(el).attr("data-fileseq"));
})
$.ajax({
type : 'POST',
data : formData,
url : "/publicBoard/saveContent",
processData: false,
contentType: false,
success : function(result) {
alert("저장되었습니다.");
contentFade("out");
$("#editModal").modal('hide');
getViewModal(result);
},
error : function(xhr, status) {
alert("저장에 실패하였습니다.")
contentFade("out");
}
})
}
}
}
function contentCheck(formId){
let flag = true;
if(!$("#title").val()){
alert("제목을 입력해주세요.")
flag = false;
}
let totalSize = 0;
for(const file of files) {
if(!file.isDelete){
totalSize+=file.size;
if(file.size>209715200){
alert("파일당 사이즈는 200MB을 넘길 수 없습니다.")
flag = false;
}
}
}
if(totalSize>524288000){
alert("첨부파일의 용량 합은 500MB를 넘길 수 없습니다.")
flag = false;
}
return flag;
}

View File

@ -0,0 +1,64 @@
<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
<div class="modal-header">
<h5 class="modal-title" id="noticeEditModalLabel" th:text="${info.publicKey eq null?'공지사항 작성':'공지사항 수정'}"></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body" id="noticeEditBody">
<form action="#" method="post" id="noticeEditForm">
<input type="hidden" name="_csrf_header" th:value="${_csrf.headerName}"/>
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
<input type="hidden" name="publicKey" th:value="${info.publicKey}">
<input type="hidden" name="publicType" th:value="${info.publicType}">
<input type="hidden" name="wrtOrgan" th:value="${info.wrtOrgan}">
<input type="hidden" name="wrtPart" th:value="${info.wrtPart}">
<input type="hidden" name="wrtUserSeq" th:value="${info.wrtUserSeq}">
<div class="mb-3 row">
<label for="wrtUserNm" class="col-sm-2 col-form-label text-center">작성자</label>
<div class="col-sm-2">
<input type="text" class="form-control" id="wrtUserNm" name="wrtUserNm" th:value="${info.wrtUserNm}" readonly>
</div>
<label for="wrtDt" class="col-sm-2 col-form-label text-center">작성일시</label>
<div class="col-sm-2">
<input type="text" class="form-control" id="wrtDt" name="wrtDt" th:value="${#temporals.format(info.wrtDt, 'yyyy-MM-dd HH:mm')}" readonly>
</div>
<div class="col-sm-auto my-auto">
<input type="checkbox" id="organChk" name="organChk" value="T" th:checked="${info.organChk eq 'T'}">
</div>
<label for="organChk" class="col-sm-3 col-form-label text-left">소속관서에만 노출</label>
</div>
<div class="mb-3 row">
<label for="title" class="col-sm-2 col-form-label text-center">제목</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="title" name="title" th:value="${info.title}" autocomplete="off">
</div>
</div>
<div class="mb-3 row justify-content-center">
<label for="content" class="col-sm-2 col-form-label text-center">내용</label>
<div class="col-sm-10">
<textarea type='text' id="content" name='content' th:utext="${info.content}"></textarea>
</div>
</div>
<div class="row mb-3">
<label for="fileInputer" class="col-sm-2 col-form-label text-center">업로드 자료</label>
<div class="col-sm-10" style="min-height: 70px;">
<div class="w-100 h-100 border border-info rounded text-center" id="uploadDiv">
<th:block th:if="${#arrays.isEmpty(info.fileList)}">
<br>파일을 업로드 해주세요.
</th:block>
<th:block th:unless="${#arrays.isEmpty(info.fileList)}">
<div class='row-col-6' th:each="infoFile:${info.fileList}">
<span th:data-fileseq="${infoFile.fileSeq}" th:text="|${infoFile.origNm}.${infoFile.fileExtn} ${infoFile.fileSize}|"></span>
<a href='#' class='uploadedFileDelete text-danger text-decoration-none'>삭제</a>
</div>
</th:block>
</div>
</div>
<input type="file" class="d-none" id="fileInputer" multiple>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">닫기</button>
<button type="button" class="btn btn-primary" id="saveBtn">저장</button>
</div>

View File

@ -0,0 +1,146 @@
<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout/layout}">
<th:block layout:fragment="script">
<script type="text/javascript" th:src="@{/js/publicBoard/publicBoard.js}"></script>
<script type="text/javascript" th:src="@{/js/publicBoard/notice.js}"></script>
</th:block>
<div layout:fragment="content">
<main class="pt-3">
<h4>공지사항</h4>
<input type="hidden" name="_csrf_header" th:value="${_csrf.headerName}"/>
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
<div class="row mx-0">
<div class="col-12 card text-center">
<div class="card-body">
<form method="get" th:action="@{/fpiMgt/monthPlanPage}">
<input type="hidden" name="pageIndex" id="pageIndex" th:value="${searchParams.pageIndex}">
<div class="row justify-content-between pe-3 py-1">
<div class="col-auto">
<select class="form-select" name="rowCnt" id="rowCnt">
<th:block th:each="num : ${#numbers.sequence(1,5)}">
<option th:value="${num*10}" th:text="${num*10}" th:selected="${searchParams.rowCnt eq num*10}"></option>
</th:block>
</select>
</div>
<div class="col-auto">
<div class="row justify-content-end">
<div class="col-auto" sec:authorize="hasRole('ROLE_SUB_ADMIN')">
<select class="form-select form-select-sm" name="wrtOrgan">
<option value="">관서 선택</option>
<th:block th:each="commonCode:${session.commonCode.get('OG')}">
<th:block th:if="${#lists.contains(mgtOrganList, commonCode.itemCd)}">
<option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}" th:selected="${commonCode.itemCd eq searchParams.wrtOrgan}"></option>
</th:block>
</th:block>
</select>
</div>
<div class="col-auto">
<input type="text" class="form-control form-control-sm" placeholder="제목" name="contentTitle" th:value="${searchParams.title}">
</div>
<div class="col-4">
<div class="input-group w-auto input-daterange" id="dateSelectorDiv">
<input type="text" class="form-control form-control-sm" id="startDate" name="startDate" placeholder="시작일" autocomplete="off" readonly th:value="${searchParams.startDate}">
<input type="text" class="form-control form-control-sm" id="endDate" name="endDate" placeholder="종료일" autocomplete="off" readonly th:value="${searchParams.endDate}">
</div>
</div>
<input type="submit" class="btn btn-sm btn-primary col-auto" id="searchBtn" value="검색">
</div>
</div>
</div>
</form>
<div class="row justify-content-start">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="row">
<table class="table table-hover">
<thead>
<tr>
<th></th>
<th>제목</th>
<th>관서</th>
<th>부서</th>
<th>작성자</th>
<th>작성일시</th>
<th>첨부파일</th>
<th>댓글</th>
</tr>
</thead>
<tbody>
<tr class="planTr" th:each="notice:${noticeList}">
<input type="hidden" class="planKey" th:value="${notice.publicKey}">
<td><input type="checkbox" class="trChkBox"></td>
<td th:text="${notice.title}"></td>
<th:block th:each="commonCode:${session.commonCode.get('OG')}">
<td th:if="${notice.wrtOrgan eq commonCode.itemCd}" th:text="${commonCode.itemValue}"></td>
</th:block>
<th:block th:each="commonCode:${session.commonCode.get('OFC')}">
<td th:if="${notice.wrtPart eq commonCode.itemCd}" th:text="${commonCode.itemValue}"></td>
</th:block>
<td th:text="${notice.wrtUserNm}"></td>
<td th:text="${#temporals.format(notice.wrtDt, 'yyyy-MM-dd HH:mm')}"></td>
<td th:text="${notice.fileCnt eq null?'파일 없음':#strings.concat(notice.fileCnt,' 건')}"></td>
<td th:text="${notice.commentCnt eq null?'0':notice.commentCnt}"></td>
</tr>
</tbody>
</table>
</div>
<div class="row justify-content-between">
<div class="col-auto"></div>
<div class="col-auto">
<nav aria-label="Page navigation">
<ul class="pagination">
<th:block th:if="${searchParams.pageIndex>3}">
<li class="page-item" th:data-pageindex="${(searchParams.pageIndex)-3}">
<a class="page-link" href="#" aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
</th:block>
<th:block th:each="num : ${#numbers.sequence(searchParams.startNum, searchParams.endNum)}">
<li class="page-item" th:data-pageindex="${num}" th:classappend="${searchParams.pageIndex eq num?'active':''}">
<a class="page-link" href="#" th:text="${num}"></a>
</li>
</th:block>
<th:block th:if="${searchParams.maxNum>searchParams.endNum+2}">
<li class="page-item" th:data-pageindex="${(searchParams.pageIndex)+3}">
<a class="page-link" href="#" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
</th:block>
</ul>
</nav>
</div>
<div class="col-auto">
<input type="button" class="btn btn-success" value="등록" id="addNoticeBtn" sec:authorize="hasRole('ROLE_SUB_ADMIN')">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<div class="modal fade" id="editModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="editModalLabel" aria-hidden="true">
<div class="modal-dialog modal-xl modal-dialog-scrollable">
<div class="modal-content" id="editContent">
</div>
</div>
</div>
<div class="modal fade" id="viewModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="viewModalLabel" aria-hidden="true">
<div class="modal-dialog modal-xl modal-dialog-scrollable">
<div class="modal-content" id="viewContent">
</div>
</div>
</div>
</div>
</html>

View File

@ -0,0 +1,142 @@
<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
<div class="modal-header">
<h5 class="modal-title" id="publicViewModalLabel">공지사항 열람</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-12">
<input type="hidden" name="publicKeyKey" id="viewModalPublicKey" th:value="${info.publicKey}">
<div class="mb-3 row">
<label for="wrtUserNm" class="col-sm-1 col-form-label text-center">작성자</label>
<div class="col-sm-2">
<input type="text" class="form-control border-0" id="wrtUserNm" name="wrtUserNm" th:value="${info.wrtUserNm}" readonly>
</div>
<label for="wrtDt" class="col-sm-1 col-form-label text-center">작성일시</label>
<div class="col-sm-2">
<input type="text" class="form-control border-0" id="wrtDt" name="wrtDt" th:value="${#temporals.format(info.wrtDt, 'yyyy-MM-dd HH:mm')}" readonly>
</div>
<div class="col-sm-auto my-auto">
<input type="checkbox" id="organChk" name="organChk" th:checked="${info.organChk eq 'T'}" disabled>
</div>
<label for="organChk" class="col-sm-2 col-form-label text-left">소속관서에만 노출</label>
</div>
<hr>
<div class="row">
<div class="col-8">
<div class="mb-3 row">
<label for="title" class="col-sm-2 col-form-label text-center">제목</label>
<div class="col-sm-10">
<input type="text" class="form-control border-0" id="title" name="title" th:value="${info.title}" readonly>
</div>
</div>
<hr>
<div class="mb-3 row">
<label for="content" class="col-sm-2 col-form-label text-center">내용</label>
<div class="col-sm-10">
<div id="content" th:utext="${info.content}"></div>
</div>
</div>
</div>
<div class="col-4">
<table class="table">
<thead>
<tr>
<th>파일명</th>
<th>사이즈</th>
</tr>
</thead>
<tbody>
<th:block th:if="${#lists.isEmpty(info.fileList)}">
<tr>
<td colspan="2">파일이 없습니다.</td>
</tr>
</th:block>
<th:block th:unless="${#lists.isEmpty(info.fileList)}">
<th:block th:each="file:${info.fileList}">
<tr class="fileInfoTr">
<td><a href="#" class="fileDownLink" data-board="monthPlan" th:data-fileseq="${file.fileSeq}" th:text="|${file.origNm}.${file.fileExtn}|"></a></td>
<td th:text="${file.fileSize}"></td>
</tr>
</th:block>
</th:block>
</tbody>
</table>
</div>
</div>
</div>
<hr>
<div class="col-12">
<form action="#" method="post" id="commentForm">
<div class="row">
<div class="col-11">
<input type="hidden" name="publicKey" th:value="${info.publicKey}">
<input type="hidden" name="parentComment" id="parentComment">
<textarea id="comment" name="comment" placeholder="댓글작성"></textarea>
</div>
<div class="col-auto m-auto">
<input type="button" class="btn btn-primary px-3 py-5" id="commentSaveBtn" value="작성">
</div>
</div>
</form>
</div>
<div class="col-12 pt-3" th:unless="${#lists.isEmpty(info.commentList)}">
<th:block th:each="comment:${info.commentList}">
<div class="row justify-content-start commentRow">
<input type="hidden" class="publicKey" th:value="${comment.publicKey}">
<input type="hidden" class="commentKey" th:value="${comment.commentKey}">
<th:block th:each="commonCode:${session.commonCode.get('OG')}">
<div class="col-auto" th:if="${commonCode.itemCd eq comment.wrtOrgan}" th:text="${commonCode.itemValue}"></div>
</th:block>
<th:block th:each="commonCode:${session.commonCode.get('OFG')}">
<div class="col-auto" th:if="${commonCode.itemCd eq comment.wrtPart}" th:text="${commonCode.itemValue}"></div>
</th:block>
<div class="col-auto" th:text="${comment.wrtUserNm}"></div>
<div class="col-auto" th:text="|작성일시: ${#temporals.format(comment.wrtDt, 'yyyy-MM-dd HH:mm')}|"></div>
<div class="col-auto">
<button type="button" class="btn btn-sm btn-success childCommentBtn">댓글달기</button>
</div>
<div class="col-auto" th:if="${userSeq eq comment.wrtUserSeq}">
<button type="button" class="btn btn-sm btn-danger deleteCommentBtn">댓글삭제</button>
</div>
<div class="col-12" th:utext="${comment.comment}"></div>
<div class="col-12 childCommentDiv" style="display: none"></div>
<hr>
</div>
<th:block th:each="childComment:${comment.childCommentList}">
<div class="row justify-content-start">
<div class="col-auto">
<i class="bi bi-arrow-return-right" ></i>
</div>
<div class="col-auto">
<div class="row justify-content-start commentRow">
<input type="hidden" class="publicKey" th:value="${comment.publicKey}">
<input type="hidden" class="commentKey" th:value="${comment.commentKey}">
<th:block th:each="commonCode:${session.commonCode.get('OG')}">
<div class="col-auto" th:if="${commonCode.itemCd eq childComment.wrtOrgan}" th:text="${commonCode.itemValue}"></div>
</th:block>
<th:block th:each="commonCode:${session.commonCode.get('OFG')}">
<div class="col-auto" th:if="${commonCode.itemCd eq childComment.wrtPart}" th:text="${commonCode.itemValue}"></div>
</th:block>
<div class="col-auto" th:text="${childComment.wrtUserNm}"></div>
<div class="col-auto" th:text="|작성일시: ${#temporals.format(childComment.wrtDt, 'yyyy-MM-dd HH:mm')}|"></div>
<div class="col-auto" th:if="${userSeq eq comment.wrtUserSeq}">
<button type="button" class="btn btn-sm btn-danger deleteCommentBtn">댓글삭제</button>
</div>
<div class="col-12" th:utext="${childComment.comment}"></div>
</div>
</div>
<hr>
</div>
</th:block>
</th:block>
</div>
</div>
</div>
<div class="modal-footer">
<th:block th:if="${userSeq eq info.wrtUserSeq}"><!--작성자일 경우 수정 허용-->
<button type="button" class="btn btn-warning" id="editBtn">수정</button>
</th:block>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">닫기</button>
</div>

View File

@ -8,7 +8,7 @@
</th:block> </th:block>
<div layout:fragment="content"> <div layout:fragment="content">
<main class="pt-3"> <main class="pt-3">
<h4>공지사항</h4> <h4>Q&A</h4>
<input type="hidden" name="_csrf_header" th:value="${_csrf.headerName}"/> <input type="hidden" name="_csrf_header" th:value="${_csrf.headerName}"/>
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/> <input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
<div class="row mx-0"> <div class="row mx-0">