diff --git a/src/main/java/com/dbnt/faisp/main/ivsgtMgt/majorStatus/MajorStatusController.java b/src/main/java/com/dbnt/faisp/main/ivsgtMgt/majorStatus/MajorStatusController.java new file mode 100644 index 00000000..bef9c678 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/main/ivsgtMgt/majorStatus/MajorStatusController.java @@ -0,0 +1,83 @@ +package com.dbnt.faisp.main.ivsgtMgt.majorStatus; + + + +import com.dbnt.faisp.main.authMgt.service.AuthMgtService; +import com.dbnt.faisp.main.ivsgtMgt.majorStatus.model.MajorStatus; +import com.dbnt.faisp.main.ivsgtMgt.majorStatus.service.MajorStatusService; + +import com.dbnt.faisp.main.userInfo.model.UserInfo; +import lombok.RequiredArgsConstructor; +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartHttpServletRequest; +import org.springframework.web.servlet.ModelAndView; + +import java.time.LocalDateTime; +import java.util.List; + + +@RestController +@RequiredArgsConstructor +@RequestMapping("/ivsgt") +public class MajorStatusController { + + private final AuthMgtService authMgtService; + private final MajorStatusService majorStatusService; + + @GetMapping("/majorStatusPage") + public ModelAndView majorStatus(@AuthenticationPrincipal UserInfo loginUser, MajorStatus majorStatus){ + + ModelAndView mav = new ModelAndView("ivsgt/majorStatus/majorStatusPage"); + + mav.addObject("mgtOrganList", loginUser.getDownOrganCdList()); + mav.addObject("searchParams", majorStatus); + + majorStatus.setDownOrganCdList(loginUser.getDownOrganCdList()); + majorStatus.setQueryInfo(); + + mav.addObject("majorList", majorStatusService.selectMajorList(majorStatus)); + majorStatus.setContentCnt(majorStatusService.selectMajorListCnt(majorStatus)); + majorStatus.setPaginationInfo(); + return mav; + } + + @GetMapping("/majorEditModal") + public ModelAndView majorEditModal(@AuthenticationPrincipal UserInfo loginUser, MajorStatus majorStatus) { + ModelAndView mav = new ModelAndView("ivsgt/majorStatus/majorStatusEditModal"); + + if(majorStatus.getMajorKey()!=null){ + majorStatus = majorStatusService.selectMajor(majorStatus.getMajorKey()); + }else{ + majorStatus.setWrtOrgan(loginUser.getOgCd()); + majorStatus.setWrtUserNm(loginUser.getUserNm()); + majorStatus.setWrtDt(LocalDateTime.now()); + } + mav.addObject("majorStatus", majorStatus); + + return mav; + } + + + @GetMapping("/majorViewModal") + public ModelAndView majorViewModal(@AuthenticationPrincipal UserInfo loginUser,MajorStatus majorStatus){ + ModelAndView mav = null; + + mav = new ModelAndView("ivsgt/majorStatus/majorStatusViewModal"); + + mav.addObject("userSeq", loginUser.getUserSeq()); + mav.addObject("major", majorStatus); + return mav; + } + + @PostMapping("/saveContent") + public Integer saveContent (MajorStatus majorStatus, + MultipartHttpServletRequest request, + @RequestParam(value = "fileSeq", required = false) List< Integer > deleteFileSeq){ + majorStatus.setMultipartFileList(request.getMultiFileMap().get("uploadFiles")); + return majorStatusService.saveContent(majorStatus, deleteFileSeq); + } + + + +} diff --git a/src/main/java/com/dbnt/faisp/main/ivsgtMgt/majorStatus/mapper/MajorStatusMapper.java b/src/main/java/com/dbnt/faisp/main/ivsgtMgt/majorStatus/mapper/MajorStatusMapper.java new file mode 100644 index 00000000..b236e819 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/main/ivsgtMgt/majorStatus/mapper/MajorStatusMapper.java @@ -0,0 +1,17 @@ +package com.dbnt.faisp.main.ivsgtMgt.majorStatus.mapper; + +import com.dbnt.faisp.main.ivsgtMgt.boardInvestigation.model.ArrestType; +import com.dbnt.faisp.main.ivsgtMgt.boardInvestigation.model.RelatedReports; +import com.dbnt.faisp.main.ivsgtMgt.majorStatus.model.MajorStatus; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface MajorStatusMapper { + List selectMajorList(MajorStatus majorStatus); + List selectContentListWhere(MajorStatus majorStatus); + ArrestType selectArrestType(Integer majorKey); + Integer selectMajorListCnt(MajorStatus majorStatus); + List selectRelatedReportsList(Integer majorKey); +} diff --git a/src/main/java/com/dbnt/faisp/main/ivsgtMgt/majorStatus/model/MajorFile.java b/src/main/java/com/dbnt/faisp/main/ivsgtMgt/majorStatus/model/MajorFile.java new file mode 100644 index 00000000..1726cd73 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/main/ivsgtMgt/majorStatus/model/MajorFile.java @@ -0,0 +1,47 @@ +package com.dbnt.faisp.main.ivsgtMgt.majorStatus.model; + +import com.dbnt.faisp.config.FileInfo; +import lombok.*; +import org.hibernate.annotations.DynamicInsert; +import org.hibernate.annotations.DynamicUpdate; + +import javax.persistence.*; +import java.io.Serializable; + +@Getter +@Setter +@Entity +@NoArgsConstructor +@DynamicInsert +@DynamicUpdate +@Table(name = "major_file") +@IdClass(MajorFile.MajorFileId.class) +public class MajorFile extends FileInfo { + @Id + @Column(name = "major_key") + private Integer majorKey; + @Id + @Column(name = "file_seq") + private Integer fileSeq; + @Column(name = "orig_nm") + private String origNm; + @Column(name = "conv_nm") + private String convNm; + @Column(name = "file_extn") + private String fileExtn; + @Column(name = "file_size") + private String fileSize; + @Column(name = "save_path") + private String savePath; + + + @Embeddable + @Data + @NoArgsConstructor + @AllArgsConstructor + public static class MajorFileId implements Serializable { + private Integer majorKey; + private Integer fileSeq; + } + +} diff --git a/src/main/java/com/dbnt/faisp/main/ivsgtMgt/majorStatus/model/MajorStatus.java b/src/main/java/com/dbnt/faisp/main/ivsgtMgt/majorStatus/model/MajorStatus.java new file mode 100644 index 00000000..f5a8a54a --- /dev/null +++ b/src/main/java/com/dbnt/faisp/main/ivsgtMgt/majorStatus/model/MajorStatus.java @@ -0,0 +1,73 @@ +package com.dbnt.faisp.main.ivsgtMgt.majorStatus.model; + + +import com.dbnt.faisp.config.BaseModel; +import com.dbnt.faisp.main.publicBoard.model.PublicComment; +import com.dbnt.faisp.main.publicBoard.model.PublicFile; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.hibernate.annotations.DynamicInsert; +import org.hibernate.annotations.DynamicUpdate; +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.web.multipart.MultipartFile; + +import javax.persistence.*; +import java.time.LocalDateTime; +import java.util.List; + +@Getter +@Setter +@Entity +@NoArgsConstructor +@DynamicInsert +@DynamicUpdate +@Table(name = "major_status") +public class MajorStatus extends BaseModel { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "major_key") + private Integer majorKey; + + @Column(name="major_type") + private String majorType; + + @Column(name = "content_title") + private String contentTitle; + + @Column(name = "content_info") + private String contentInfo; + + @Column(name = "content_status") + private String contentStatus; + + @Column(name = "wrt_user_grd") + private String wrtUserGrd; + + @Column(name = "wrt_user_nm") + private String wrtUserNm; + + @Column(name = "wrt_dt") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm") + private LocalDateTime wrtDt; + + @Column(name="wrt_organ") + private String wrtOrgan; + + @Column(name="wrt_user_seq") + private Integer wrtUserSeq; + + @Column(name = "wrt_part") + private String wrtPart; + + @Transient + private Integer fileCnt; + @Transient + private Integer commentCnt; + @Transient + private List fileList; + @Transient + private List multipartFileList; + + +} diff --git a/src/main/java/com/dbnt/faisp/main/ivsgtMgt/majorStatus/repository/MajorFileRepository.java b/src/main/java/com/dbnt/faisp/main/ivsgtMgt/majorStatus/repository/MajorFileRepository.java new file mode 100644 index 00000000..f390d895 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/main/ivsgtMgt/majorStatus/repository/MajorFileRepository.java @@ -0,0 +1,14 @@ +package com.dbnt.faisp.main.ivsgtMgt.majorStatus.repository; + +import com.dbnt.faisp.main.ivsgtMgt.majorStatus.model.MajorFile; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.List; +import java.util.Optional; + +public interface MajorFileRepository extends JpaRepository { + + List findByMajorKey(Integer majorKey); + Optional findTopByMajorKeyOrderByFileSeq(Integer majorKey); + +} diff --git a/src/main/java/com/dbnt/faisp/main/ivsgtMgt/majorStatus/repository/MajorStatusRepository.java b/src/main/java/com/dbnt/faisp/main/ivsgtMgt/majorStatus/repository/MajorStatusRepository.java new file mode 100644 index 00000000..8c34985d --- /dev/null +++ b/src/main/java/com/dbnt/faisp/main/ivsgtMgt/majorStatus/repository/MajorStatusRepository.java @@ -0,0 +1,7 @@ +package com.dbnt.faisp.main.ivsgtMgt.majorStatus.repository; + +import com.dbnt.faisp.main.ivsgtMgt.majorStatus.model.MajorStatus; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface MajorStatusRepository extends JpaRepository { +} diff --git a/src/main/java/com/dbnt/faisp/main/ivsgtMgt/majorStatus/service/MajorStatusService.java b/src/main/java/com/dbnt/faisp/main/ivsgtMgt/majorStatus/service/MajorStatusService.java new file mode 100644 index 00000000..231fc8c8 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/main/ivsgtMgt/majorStatus/service/MajorStatusService.java @@ -0,0 +1,95 @@ +package com.dbnt.faisp.main.ivsgtMgt.majorStatus.service; + + +import com.dbnt.faisp.config.BaseService; +import com.dbnt.faisp.config.FileInfo; +import com.dbnt.faisp.main.ivsgtMgt.boardInvestigation.model.BoardInvestigation; +import com.dbnt.faisp.main.ivsgtMgt.majorStatus.mapper.MajorStatusMapper; +import com.dbnt.faisp.main.ivsgtMgt.majorStatus.model.MajorFile; +import com.dbnt.faisp.main.ivsgtMgt.majorStatus.model.MajorStatus; +import com.dbnt.faisp.main.ivsgtMgt.majorStatus.repository.MajorFileRepository; +import com.dbnt.faisp.main.ivsgtMgt.majorStatus.repository.MajorStatusRepository; +import lombok.RequiredArgsConstructor; +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.UUID; + +@Service +@RequiredArgsConstructor +public class MajorStatusService extends BaseService { + private final MajorStatusRepository majorStatusRepository; + private final MajorFileRepository majorFileRepository; + private final MajorStatusMapper majorStatusMapper; + + + public List selectMajorList(MajorStatus majorStatus) { + return majorStatusMapper.selectMajorList(majorStatus); + } + + public Integer selectMajorListCnt(MajorStatus majorStatus) { + return majorStatusMapper.selectMajorListCnt(majorStatus); + } + + public MajorStatus selectMajor(Integer majorKey) { + MajorStatus savedBoardInvestigation = majorStatusRepository.findById(majorKey).orElse(null); + if (savedBoardInvestigation != null) { + savedBoardInvestigation.setFileList(majorFileRepository.findByMajorKey(majorKey)); + + // savedBoardInvestigation.setArrestType(majorStatusMapper.selectArrestType(majorKey)); + // savedBoardInvestigation.setRelatedReportsList(majorStatusMapper.selectRelatedReportsList(majorKey)); + } + return savedBoardInvestigation; + } + + @Transactional + public Integer saveContent(MajorStatus majorStatus, List deleteFileSeq) { + Integer majorKey = majorStatusRepository.save(majorStatus).getMajorKey(); + if(deleteFileSeq!=null && deleteFileSeq.size()>0){ + deleteMajorFile(majorKey, deleteFileSeq); + } + if(majorStatus.getMultipartFileList()!= null){ + saveUploadFiles(majorKey, majorStatus.getMultipartFileList()); + } + return majorKey; + } + + private void saveUploadFiles(Integer majorkey, List multipartFileList) { + MajorFile lastFileInfo = majorFileRepository.findTopByMajorKeyOrderByFileSeq(majorkey).orElse(null); + int fileSeq = lastFileInfo==null?1:(lastFileInfo.getFileSeq()+1); + for(MultipartFile file : multipartFileList){ + String saveName = UUID.randomUUID().toString(); + + + String originalFilename = file.getOriginalFilename(); + int extnIdx = originalFilename.lastIndexOf("."); + MajorFile fileInfo = new MajorFile(); + fileInfo.setMajorKey(majorkey); + fileInfo.setFileSeq(fileSeq++); + fileInfo.setOrigNm(originalFilename.substring(0, extnIdx)); + fileInfo.setFileExtn(originalFilename.substring(extnIdx+1)); + fileInfo.setConvNm(saveName); + fileInfo.setFileSize(calculationSize(file.getSize())); + + majorFileRepository.save(fileInfo); + } + } + + private void deleteMajorFile(Integer majorKey, List deleteFileSeq) { + List majorFileList = majorFileRepository.findByMajorKey(majorKey); + for(MajorFile file: majorFileList){ + if(deleteFileSeq.contains(file.getFileSeq())){ + deleteStoredFile(new File(file.getSavePath(), file.getConvNm())); + majorFileRepository.delete(file); + } + } + } + + + public FileInfo selectMajorFile(Integer majorKey, Integer fileSeq){ + return majorFileRepository.findById(new MajorFile.MajorFileId(majorKey, fileSeq)).orElse(null); + } +} diff --git a/src/main/resources/mybatisMapper/MajorStatusMapper.xml b/src/main/resources/mybatisMapper/MajorStatusMapper.xml new file mode 100644 index 00000000..b9858c81 --- /dev/null +++ b/src/main/resources/mybatisMapper/MajorStatusMapper.xml @@ -0,0 +1,63 @@ + + + + + + + + + + and a.major_type = #{majorType} + + + and a.wrt_organ = #{wrtOrgan} + + + AND a.content_title LIKE CONCAT('%', #{content_title}, '%') + + + AND a.wrt_user_nm LIKE CONCAT('%', #{wrtUserNm}, '%') + + + and a.wrt_dt >= #{startDate}::date + + + and a.wrt_dt <= #{endDate}::date+1 + + + and a.wrt_organ in + + #{organCd} + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/static/js/ivsgt/majorStatus.js b/src/main/resources/static/js/ivsgt/majorStatus.js new file mode 100644 index 00000000..d879a5ff --- /dev/null +++ b/src/main/resources/static/js/ivsgt/majorStatus.js @@ -0,0 +1,196 @@ + +$(function(){ + $("#dateSelectorDiv").datepicker({ + format: "yyyy-mm-dd", + language: "ko", + autoclose: true + }); +}) + +// $(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, +// dataType:"html", +// beforeSend: function (xhr){ +// xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); +// }, +// success : function(html) { +// const parentComment = $("#parentComment"); +// if(!parentComment.val()){ +// $("#commentDiv").append(html) +// }else{ +// $("#childComment"+parentComment.val()).append(html); +// } +// commentFormReset(); +// alert("저장되었습니다."); +// contentFade("out"); +// }, +// error : function(xhr, status) { +// alert("저장에 실패하였습니다.") +// contentFade("out"); +// } +// }) +// } +// } +// }) + +// $(document).on('click', '.childCommentBtn', function (){ +// const childCommentFormDiv = $(this).parents(".commentRow").find(".childCommentFormDiv") +// childCommentFormDiv.show(); +// $("#parentComment").val($(this).parents(".commentRow").find(".commentKey").val()); +// $("#childFormRemoveBtn").show(); +// childCommentFormDiv.empty().append($("#commentForm")) +// }) +// $(document).on('click', '#childFormRemoveBtn', function (){ +// commentFormReset(); +// }) +// $(document).on('click', '.deleteCommentBtn', function (){ +// const commentRow = $(this).parents(".commentRow"); +// const publicKey = Number(commentRow.find(".publicKey").val()); +// const commentKey = Number(commentRow.find(".commentKey").val()); +// $.ajax({ +// type : 'POST', +// data : JSON.stringify({publicKey: publicKey, commentKey: commentKey}), +// url : "/publicBoard/deleteComment", +// contentType: 'application/json', +// beforeSend: function (xhr){ +// xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); +// }, +// success : function(result) { +// commentRow.remove(); +// $("#childComment"+commentKey).remove(); +// alert("삭제되었습니다."); +// contentFade("out"); +// }, +// error : function(xhr, status) { +// alert("삭제를 실패하였습니다.") +// contentFade("out"); +// } +// }) +// }) + +function getEditModal(majorKey, majorType){ + $.ajax({ + url: '/ivsgt/majorEditModal', + data: {majorKey: majorKey, majorType:majorType}, + type: 'GET', + dataType:"html", + success: function(html){ + $("#editContent").empty().append(html) + setUploadDiv(); + setEditor('editor', '570'); + $("#majorEditModal").modal('show'); + }, + error:function(){ + + } + }); +} + +function getViewModal(majorKey, majorType){ + $.ajax({ + url: '/ivsgt/majorViewModal', + data: {majorKey: majorKey, majorType: majorType}, + type: 'GET', + dataType:"html", + success: function(html){ + $("#viewContent").empty().append(html) + $("#majorViewModal").modal('show'); + }, + error:function(){ + + } + }); +} + +function saveContent(formId, majorType){ + if(contentCheck(formId)){ + if(confirm("저장하시겠습니까?")){ + contentFade("in"); + $("#content").val(""); + 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")); + }) + formData.append('content', CrossEditor.GetBodyValue()); + $.ajax({ + type : 'POST', + data : formData, + url : "/ivsgt/saveContent", + processData: false, + contentType: false, + success : function(result) { + alert("저장되었습니다."); + contentFade("out"); + $("#editModal").modal('hide'); + getViewModal(result, majorType); + }, + error : function(xhr, status) { + alert("저장에 실패하였습니다.") + contentFade("out"); + } + }) + } + } +} + +function contentCheck(formId){ + let flag = true; + if(!$("#title").val()){ + alert("제목을 입력해주세요.") + flag = false; + } + if($("#majorType").val()==="PLB003"){ + if(!$("#tabStatus").val()){ + alert("분류를 선택해주세요.") + flag = false; + } + } + flag = fileCheck(flag, files); + return flag; +} + +function commentFormReset(){ + const commentForm = $("#commentForm"); + commentForm[0].reset(); + $("#childFormRemoveBtn").hide(); + $("#parentComment").val(''); + $("#commentFormHome").append(commentForm) +} + + + + + +$(document).on('click', '#addMajorBtn', function (){ + getEditModal(null) +}) + +$(document).on('click', '.planTr', function (){ + $(".trChkBox").prop("checked", false); + $(this).find(".trChkBox").prop("checked", true); + getViewModal(Number($(this).find(".planKey").val())); +}) + +$(document).on('click', '#saveBtn', function (){ + savePublicBoard("boardEditForm") +}) + +$(document).on('click', '#editBtn', function (){ + $("#MajorStatusViewModal").modal('hide') + getEditModal($(this).attr("data-ciwkey")); +}) \ No newline at end of file diff --git a/src/main/resources/templates/ivsgt/majorStatus/majorStatusEditModal.html b/src/main/resources/templates/ivsgt/majorStatus/majorStatusEditModal.html new file mode 100644 index 00000000..23f1127b --- /dev/null +++ b/src/main/resources/templates/ivsgt/majorStatus/majorStatusEditModal.html @@ -0,0 +1,71 @@ + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/ivsgt/majorStatus/majorStatusPage.html b/src/main/resources/templates/ivsgt/majorStatus/majorStatusPage.html new file mode 100644 index 00000000..f109c464 --- /dev/null +++ b/src/main/resources/templates/ivsgt/majorStatus/majorStatusPage.html @@ -0,0 +1,156 @@ + + + + + +
+
+

주요사건처리현황

+ + +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
종류제목관서부서계급작성자작성일시첨부파일
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+
+ + + +
+ \ No newline at end of file diff --git a/src/main/resources/templates/ivsgt/majorStatus/majorStatusViewModal.html b/src/main/resources/templates/ivsgt/majorStatus/majorStatusViewModal.html new file mode 100644 index 00000000..43dbf97b --- /dev/null +++ b/src/main/resources/templates/ivsgt/majorStatus/majorStatusViewModal.html @@ -0,0 +1,100 @@ + + + + + \ No newline at end of file