package com.dbnt.faisp.ivsgtMgt.boardInvestigation; import com.dbnt.faisp.authMgt.service.AuthMgtService; import com.dbnt.faisp.ivsgtMgt.boardInvestigation.model.ArrestType; import com.dbnt.faisp.ivsgtMgt.boardInvestigation.model.BoardInvestigation; import com.dbnt.faisp.ivsgtMgt.boardInvestigation.service.BoardInvestigationService; import com.dbnt.faisp.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 IvsgtController { private final AuthMgtService authMgtService; private final BoardInvestigationService boardInvestigationService; @GetMapping("/arrest") public ModelAndView ivsgt(@AuthenticationPrincipal UserInfo loginUser, BoardInvestigation boardInvestigation) { ModelAndView mav = new ModelAndView("ivsgt/arrest"); //메뉴권한 확인 String accessAuth = authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/ivsgt/arrest").get(0).getAccessAuth(); mav.addObject("accessAuth", accessAuth); mav.addObject("boardInvestigationList", boardInvestigationService.selectBoardInvestigationList(boardInvestigation)); mav.addObject("mgtOrganList", loginUser.getDownOrganCdList()); boardInvestigation.setQueryInfo(); boardInvestigation.setContentCnt(boardInvestigationService.selectBoardInvestigationListCnt(boardInvestigation)); boardInvestigation.setPaginationInfo(); mav.addObject("searchParams", boardInvestigation); return mav; } @GetMapping("/arrestEditModal") public ModelAndView arrestEditModal(@AuthenticationPrincipal UserInfo loginUser, BoardInvestigation boardInvestigation){ ModelAndView mav = new ModelAndView("ivsgt/arrestEditModal"); if(boardInvestigation.getIvsgtKey()!=null){ boardInvestigation = boardInvestigationService.selectBoardInvestigation(boardInvestigation.getIvsgtKey()); System.out.println(boardInvestigation.toString()); }else{ boardInvestigation.setWrtOrgan(loginUser.getOgCd()); boardInvestigation.setWrtNm(loginUser.getUserNm()); boardInvestigation.setWrtDt(LocalDateTime.now()); } mav.addObject("boardInvestigation", boardInvestigation); return mav; } @GetMapping("/arrestViewModal") public ModelAndView arrestViewModal(@AuthenticationPrincipal UserInfo loginUser, BoardInvestigation boardInvestigation){ ModelAndView mav = new ModelAndView("ivsgt/arrestViewModal"); boardInvestigation = boardInvestigationService.selectBoardInvestigation(boardInvestigation.getIvsgtKey()); mav.addObject("boardInvestigation", boardInvestigation); mav.addObject("userSeq",loginUser.getUserSeq()); //메뉴권한 확인 mav.addObject("accessAuth", authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/ivsgt/arrest").get(0).getAccessAuth()); return mav; } @PostMapping("/saveBoardInvestigation") public Integer saveBoardInvestigation(@AuthenticationPrincipal UserInfo loginUser, BoardInvestigation boardInvestigation, ArrestType arrestType, MultipartHttpServletRequest request, @RequestParam(value = "fileSeq", required = false) List deleteFileSeq){ boardInvestigation.setWrtUserSeq(loginUser.getUserSeq()); boardInvestigation.setMultipartFileList(request.getMultiFileMap().get("uploadFiles")); return boardInvestigationService.saveBoardInvestigation(boardInvestigation, arrestType, deleteFileSeq); } }