|
@@ -21,6 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.FileCopyUtils;
|
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
@@ -47,7 +48,7 @@ public class BoardController extends LifeCenterController {
|
|
|
|
|
|
private LifeCenterPaging paging;
|
|
|
|
|
|
- @RequestMapping("/list")
|
|
|
+ @RequestMapping("/notice/list")
|
|
|
public ModelAndView boardList(
|
|
|
@RequestParam(value="searchTxt", required=false, defaultValue="") String searchTxt,
|
|
|
@RequestParam(value="selectState", required=false, defaultValue="") String selectState,
|
|
@@ -79,7 +80,7 @@ public class BoardController extends LifeCenterController {
|
|
|
paging = LifeCenterPaging.getInstance();
|
|
|
paging.paging(config, total, page, param);
|
|
|
|
|
|
- ModelAndView mv = setMV("board/list");
|
|
|
+ ModelAndView mv = setMV("notice/list");
|
|
|
mv.addObject("sesGroupIdx", sesGroupIdx);
|
|
|
mv.addObject("list", list);
|
|
|
mv.addObject("total", total);
|
|
@@ -91,18 +92,28 @@ public class BoardController extends LifeCenterController {
|
|
|
return mv;
|
|
|
}
|
|
|
|
|
|
- @RequestMapping("/new")
|
|
|
- public ModelAndView boardNew() {
|
|
|
- ModelAndView mv = setMV("board/new");
|
|
|
+ @RequestMapping("/notice/new")
|
|
|
+ public ModelAndView boardNew(HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ String sesGroupIdx = LifeCenterSessionController.getSession( request, "sesGroupIdx" );
|
|
|
+ ModelAndView mv = setMV("notice/new");
|
|
|
+ mv.addObject("groupIdx",sesGroupIdx);
|
|
|
+
|
|
|
return mv;
|
|
|
}
|
|
|
|
|
|
- @RequestMapping("/new/insert")
|
|
|
+ @RequestMapping("/notice/new/insert")
|
|
|
@Transactional(propagation=Propagation.REQUIRED)
|
|
|
public String boardNewInsert(
|
|
|
HttpServletRequest request, HttpServletResponse response,
|
|
|
@ModelAttribute("dto") final BoardDTO dto,
|
|
|
MultipartFile file) {
|
|
|
+ String sesId = LifeCenterSessionController.getSession(request, "sesId");
|
|
|
+ String sesGroupIdx = LifeCenterSessionController.getSession(request, "sesGroupIdx");
|
|
|
+
|
|
|
+ if (!sesGroupIdx.equals("1")) {
|
|
|
+ LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '공지사항 작성 권한이 없습니다.', callBack : function(){ location.href='/board/notice/list'; } });" );
|
|
|
+ return "/common/blank";
|
|
|
+ }
|
|
|
|
|
|
if (file.isEmpty() == false) {
|
|
|
UUID uuid = UUID.randomUUID();
|
|
@@ -112,7 +123,7 @@ public class BoardController extends LifeCenterController {
|
|
|
String saveFileName = uuid + "." + ext;
|
|
|
|
|
|
try {
|
|
|
- String tempPath = "../notice-temp";
|
|
|
+ String tempPath = config.filePath;
|
|
|
File saveFile = new File(tempPath, saveFileName);
|
|
|
FileCopyUtils.copy(file.getBytes(),saveFile);
|
|
|
} catch (IOException e) {
|
|
@@ -127,8 +138,6 @@ public class BoardController extends LifeCenterController {
|
|
|
dto.setFileSize(fileSize);
|
|
|
}
|
|
|
|
|
|
- String sesId = LifeCenterSessionController.getSession(request, "sesId");
|
|
|
-
|
|
|
String title = dto.getTitle().trim();
|
|
|
String content = dto.getContent().trim();
|
|
|
|
|
@@ -153,22 +162,210 @@ public class BoardController extends LifeCenterController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return "redirect:/board/content?postSeq=" + dto.getPostSeq();
|
|
|
+ return "redirect:/board/notice/content?postSeq=" + dto.getPostSeq();
|
|
|
}
|
|
|
|
|
|
- @RequestMapping("/content")
|
|
|
+ @RequestMapping("/notice/content")
|
|
|
public ModelAndView boardContent(
|
|
|
@RequestParam(value="postSeq", required=false, defaultValue="") int postSeq,
|
|
|
HttpServletRequest request, HttpServletResponse response) {
|
|
|
- String sesId = LifeCenterSessionController.getSession( request, "sesId" );
|
|
|
+ String referer = request.getHeader("referer");
|
|
|
String sesGroupIdx = LifeCenterSessionController.getSession( request, "sesGroupIdx" );
|
|
|
- ModelAndView mv = setMV("board/content");
|
|
|
+
|
|
|
+ int total = boardService.selectNoticeBoardCountOne(postSeq);
|
|
|
+ BoardDTO dto = new BoardDTO();
|
|
|
+ if (total > 0) {
|
|
|
+ boardService.updateNoticeView(postSeq);
|
|
|
+ dto = boardService.selectNoticeBoardInfoOne(postSeq);
|
|
|
+ }
|
|
|
+
|
|
|
+ int prePostCnt = boardService.selectPrePostCount(postSeq);
|
|
|
+ int nextPostCnt = boardService.selectNextPostCount(postSeq);
|
|
|
+
|
|
|
+ BoardDTO preDto = new BoardDTO();
|
|
|
+ BoardDTO nextDto = new BoardDTO();
|
|
|
+ if (prePostCnt > 0) {
|
|
|
+ preDto = boardService.selectPrePost(postSeq);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (nextPostCnt > 0) {
|
|
|
+ nextDto = boardService.selectNextPost(postSeq);
|
|
|
+ }
|
|
|
+
|
|
|
+ ModelAndView mv = setMV("notice/content");
|
|
|
+ mv.addObject("filePath", config.filePath);
|
|
|
+ mv.addObject("content", dto);
|
|
|
+ mv.addObject("groupIdx", sesGroupIdx);
|
|
|
+ mv.addObject("prePostCnt", prePostCnt);
|
|
|
+ mv.addObject("nextPostCnt", nextPostCnt);
|
|
|
+ mv.addObject("prePost", preDto);
|
|
|
+ mv.addObject("nextPost", nextDto);
|
|
|
+ mv.addObject("referer", referer);
|
|
|
+ return mv;
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value="/notice/content/file", method=RequestMethod.GET)
|
|
|
+ public void boardFile(HttpServletRequest request, HttpServletResponse response,
|
|
|
+ @RequestParam(value="postSeq", required=false, defaultValue="") int postSeq) {
|
|
|
+
|
|
|
+ int total = boardService.selectFileCount(postSeq);
|
|
|
+ BoardDTO dto = new BoardDTO();
|
|
|
+ if (total > 0) {
|
|
|
+ dto = boardService.selectFile(postSeq);
|
|
|
+ String filePath = config.filePath + "/" + dto.getFileName();
|
|
|
+ String fileName = dto.getFileOriginalName();
|
|
|
+ logger.error("filePath -- > " + filePath);
|
|
|
+ LifeCenterFileDownload.download(request, response, filePath, fileName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value="/notice/content/delete")
|
|
|
+ @Transactional(propagation=Propagation.REQUIRED)
|
|
|
+ public String contentDelete(HttpServletRequest request, HttpServletResponse response,
|
|
|
+ @RequestParam(value="postSeq", required=false, defaultValue="") int postSeq) {
|
|
|
+ String sesGroupIdx = LifeCenterSessionController.getSession(request, "sesGroupIdx");
|
|
|
+
|
|
|
+ if (!sesGroupIdx.equals("1")) {
|
|
|
+ LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '해당 글을 삭제할 수 없습니다.', callBack : function(){ location.href='/board/notice/list'; } });" );
|
|
|
+ return "/common/blank";
|
|
|
+ }
|
|
|
+
|
|
|
+ boardService.deleteNoticeIfno(postSeq);
|
|
|
+ boardService.deleteFile(postSeq);
|
|
|
+
|
|
|
+ LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '게시글이 삭제되었습니다. ', callBack : function(){ location.href='/board/notice/list'; } });" );
|
|
|
+
|
|
|
+ return "/common/blank";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping("/notice/edit")
|
|
|
+ public ModelAndView boardEdit(HttpServletRequest request, HttpServletResponse response,
|
|
|
+ @RequestParam(value="postSeq", required=false, defaultValue="") int postSeq) {
|
|
|
+ ModelAndView mv = setMV("notice/edit");
|
|
|
+ String sesGroupIdx = LifeCenterSessionController.getSession(request, "sesGroupIdx");
|
|
|
+//
|
|
|
+// if (!sesGroupIdx.equals("1")) {
|
|
|
+// LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '공지사항 작성 권한이 없습니다.', callBack : function(){ location.href='./list'; } });" );
|
|
|
+// return "/common/blank";
|
|
|
+// }
|
|
|
+
|
|
|
+ BoardDTO dto = new BoardDTO();
|
|
|
+ int cnt = boardService.selectNoticeBoardCountOne(postSeq);
|
|
|
+ if (cnt == 0) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ dto = boardService.selectNoticeBoardInfoOne(postSeq);
|
|
|
+ }
|
|
|
+ mv.addObject("groupIdx", sesGroupIdx);
|
|
|
+ mv.addObject("item", dto);
|
|
|
return mv;
|
|
|
}
|
|
|
|
|
|
- @RequestMapping("edit")
|
|
|
- public ModelAndView boardEdit() {
|
|
|
- ModelAndView mv = setMV("board/edit");
|
|
|
+ @RequestMapping("/notice/edit/update")
|
|
|
+ @Transactional(propagation=Propagation.REQUIRED)
|
|
|
+ public String boardEditUpdate(
|
|
|
+ HttpServletRequest request, HttpServletResponse response,
|
|
|
+ @ModelAttribute("dto") final BoardDTO dto,
|
|
|
+ MultipartFile file) {
|
|
|
+
|
|
|
+ String sesId = LifeCenterSessionController.getSession(request, "sesId");
|
|
|
+ String sesGroupIdx = LifeCenterSessionController.getSession(request, "sesGroupIdx");
|
|
|
+
|
|
|
+ if (!sesGroupIdx.equals("1")) {
|
|
|
+ LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '공지사항 작성 권한이 없습니다.', callBack : function(){ location.href='./list'; } });" );
|
|
|
+ return "/common/blank";
|
|
|
+ }
|
|
|
+
|
|
|
+ int postSeq = dto.getPostSeq();
|
|
|
+
|
|
|
+ if (file.isEmpty() == false) {
|
|
|
+ UUID uuid = UUID.randomUUID();
|
|
|
+ String fileName = file.getOriginalFilename();
|
|
|
+ int fileSize = (int) file.getSize(); //단위는 byte
|
|
|
+ String ext = FilenameUtils.getExtension(fileName);
|
|
|
+ String saveFileName = uuid + "." + ext;
|
|
|
+
|
|
|
+ try {
|
|
|
+ File saveFile = new File(config.filePath, saveFileName);
|
|
|
+ FileCopyUtils.copy(file.getBytes(),saveFile);
|
|
|
+
|
|
|
+ String path = config.filePath + "/" + dto.getFileName().trim();
|
|
|
+ File rFile = new File(path);
|
|
|
+ rFile.delete();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ LifeCenterFunction.scriptMessage( response, "alertBox({ txt : '파일 업로드에 실패하였습니다.', callBack : function(){ history.back(); } });" );
|
|
|
+ return "/common/blank";
|
|
|
+ }
|
|
|
+
|
|
|
+ dto.setFileOriginalName(fileName);
|
|
|
+ dto.setFileName(saveFileName);
|
|
|
+ dto.setFileExtension(ext);
|
|
|
+ dto.setFileSize(fileSize);
|
|
|
+ int cnt = boardService.selectFileCount(postSeq);
|
|
|
+ if (cnt > 0) {
|
|
|
+ boardService.updateFile(dto);
|
|
|
+ } else {
|
|
|
+ boardService.fileUploadDataInsert(dto);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if (dto.getFileOriginalName().equals("")) {
|
|
|
+ String path = config.filePath + "/" + dto.getFileName().trim();
|
|
|
+ File rFile = new File(path);
|
|
|
+ rFile.delete();
|
|
|
+ boardService.deleteFile(postSeq);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ dto.setUpdateBy(sesId);
|
|
|
+ boardService.updateNoticeBoard(dto);
|
|
|
+
|
|
|
+ return "redirect:/board/notice/content?postSeq=" + dto.getPostSeq();
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping("/qna/list")
|
|
|
+ public ModelAndView qnsList(@RequestParam(value="searchTxt", required=false, defaultValue="") String searchTxt,
|
|
|
+ @RequestParam(value="selectState", required=false, defaultValue="") String selectState,
|
|
|
+ @RequestParam(value="page", required=false, defaultValue="1") int page,
|
|
|
+ HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ String sesGroupIdx = LifeCenterSessionController.getSession( request, "sesGroupIdx" );
|
|
|
+ BoardDTO dto = new BoardDTO();
|
|
|
+
|
|
|
+ if (!selectState.equals("")) {
|
|
|
+ if (selectState.equals("title")) {
|
|
|
+ dto.setTitle(searchTxt);
|
|
|
+ } else if (selectState.equals("createBy")) {
|
|
|
+ dto.setCreateBy(searchTxt);
|
|
|
+ } else if (selectState.equals("content")) {
|
|
|
+ dto.setContent(searchTxt);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ dto.setLimit( ( Integer.valueOf( page ) - 1 ) * config.pageDataSize );
|
|
|
+ dto.setLimitMax( config.pageDataSize );
|
|
|
+
|
|
|
+ List<BoardDTO> list = new ArrayList<BoardDTO>();
|
|
|
+
|
|
|
+ int total = boardService.selectQnaListCount(dto);
|
|
|
+ if (total == 0) {
|
|
|
+ } else {
|
|
|
+ list = boardService.selectQnaList(dto);
|
|
|
+ }
|
|
|
+
|
|
|
+ String param = "";
|
|
|
+ paging = LifeCenterPaging.getInstance();
|
|
|
+ paging.paging(config, total, page, param);
|
|
|
+
|
|
|
+ ModelAndView mv = setMV("qna/list");
|
|
|
+ mv.addObject("sesGroupIdx", sesGroupIdx);
|
|
|
+ mv.addObject("list", list);
|
|
|
+ mv.addObject("total", total);
|
|
|
+ mv.addObject("selectState", selectState);
|
|
|
+ mv.addObject("searchTxt", searchTxt);
|
|
|
+ mv.addObject("paging", paging);
|
|
|
+ mv.addObject("page", page);
|
|
|
+ mv.addObject("pageSize", dto.getLimitMax());
|
|
|
return mv;
|
|
|
}
|
|
|
}
|