|
@@ -36,7 +36,6 @@ import com.lemon.lifecenter.dto.BoardDTO;
|
|
|
import com.lemon.lifecenter.service.BoardService;
|
|
|
|
|
|
@Controller
|
|
|
-@RequestMapping("/board")
|
|
|
public class BoardController extends LifeCenterController {
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
|
|
@@ -111,7 +110,7 @@ public class BoardController extends LifeCenterController {
|
|
|
String sesGroupIdx = LifeCenterSessionController.getSession(request, "sesGroupIdx");
|
|
|
|
|
|
if (!sesGroupIdx.equals("1")) {
|
|
|
- LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '공지사항 작성 권한이 없습니다.', callBack : function(){ location.href='/board/notice/list'; } });" );
|
|
|
+ LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '공지사항 작성 권한이 없습니다.', callBack : function(){ location.href='/notice/list'; } });" );
|
|
|
return "/common/blank";
|
|
|
}
|
|
|
|
|
@@ -136,6 +135,7 @@ public class BoardController extends LifeCenterController {
|
|
|
dto.setFileName(saveFileName);
|
|
|
dto.setFileExtension(ext);
|
|
|
dto.setFileSize(fileSize);
|
|
|
+ dto.setBoardType("N");
|
|
|
}
|
|
|
|
|
|
String title = dto.getTitle().trim();
|
|
@@ -162,7 +162,7 @@ public class BoardController extends LifeCenterController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return "redirect:/board/notice/content?postSeq=" + dto.getPostSeq();
|
|
|
+ return "redirect:/notice/content?postSeq=" + dto.getPostSeq();
|
|
|
}
|
|
|
|
|
|
@RequestMapping("/notice/content")
|
|
@@ -208,10 +208,15 @@ public class BoardController extends LifeCenterController {
|
|
|
public void boardFile(HttpServletRequest request, HttpServletResponse response,
|
|
|
@RequestParam(value="postSeq", required=false, defaultValue="") int postSeq) {
|
|
|
|
|
|
- int total = boardService.selectFileCount(postSeq);
|
|
|
BoardDTO dto = new BoardDTO();
|
|
|
+ dto.setPostSeq(postSeq);
|
|
|
+ dto.setBoardType("N");
|
|
|
+ int total = boardService.selectFileCount(dto);
|
|
|
+
|
|
|
if (total > 0) {
|
|
|
- dto = boardService.selectFile(postSeq);
|
|
|
+ dto.setPostSeq(postSeq);
|
|
|
+ dto.setBoardType("N");
|
|
|
+ dto = boardService.selectFile(dto);
|
|
|
String filePath = config.filePath + "/" + dto.getFileName();
|
|
|
String fileName = dto.getFileOriginalName();
|
|
|
logger.error("filePath -- > " + filePath);
|
|
@@ -222,18 +227,27 @@ public class BoardController extends LifeCenterController {
|
|
|
@RequestMapping(value="/notice/content/delete")
|
|
|
@Transactional(propagation=Propagation.REQUIRED)
|
|
|
public String contentDelete(HttpServletRequest request, HttpServletResponse response,
|
|
|
- @RequestParam(value="postSeq", required=false, defaultValue="") int postSeq) {
|
|
|
+ @RequestParam(value="postSeq", required=false, defaultValue="") int postSeq,
|
|
|
+ @RequestParam(value="fileName", required=false, defaultValue="") String fileName) {
|
|
|
String sesGroupIdx = LifeCenterSessionController.getSession(request, "sesGroupIdx");
|
|
|
|
|
|
if (!sesGroupIdx.equals("1")) {
|
|
|
- LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '해당 글을 삭제할 수 없습니다.', callBack : function(){ location.href='/board/notice/list'; } });" );
|
|
|
+ LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '해당 글을 삭제할 수 없습니다.', callBack : function(){ location.href='/notice/list'; } });" );
|
|
|
return "/common/blank";
|
|
|
}
|
|
|
|
|
|
+ BoardDTO dto = new BoardDTO();
|
|
|
+ dto.setPostSeq(postSeq);
|
|
|
+ dto.setBoardType("N");
|
|
|
boardService.deleteNoticeIfno(postSeq);
|
|
|
- boardService.deleteFile(postSeq);
|
|
|
|
|
|
- LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '게시글이 삭제되었습니다. ', callBack : function(){ location.href='/board/notice/list'; } });" );
|
|
|
+ String path = config.filePath + "/" + fileName.trim();
|
|
|
+ File rFile = new File(path);
|
|
|
+ rFile.delete();
|
|
|
+
|
|
|
+ boardService.deleteFile(dto);
|
|
|
+
|
|
|
+ LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '게시글이 삭제되었습니다. ', callBack : function(){ location.href='/notice/list'; } });" );
|
|
|
|
|
|
return "/common/blank";
|
|
|
}
|
|
@@ -272,7 +286,7 @@ public class BoardController extends LifeCenterController {
|
|
|
String sesGroupIdx = LifeCenterSessionController.getSession(request, "sesGroupIdx");
|
|
|
|
|
|
if (!sesGroupIdx.equals("1")) {
|
|
|
- LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '공지사항 작성 권한이 없습니다.', callBack : function(){ location.href='./list'; } });" );
|
|
|
+ LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '공지사항 수정 권한이 없습니다.', callBack : function(){ location.href='./list'; } });" );
|
|
|
return "/common/blank";
|
|
|
}
|
|
|
|
|
@@ -302,7 +316,8 @@ public class BoardController extends LifeCenterController {
|
|
|
dto.setFileName(saveFileName);
|
|
|
dto.setFileExtension(ext);
|
|
|
dto.setFileSize(fileSize);
|
|
|
- int cnt = boardService.selectFileCount(postSeq);
|
|
|
+ dto.setBoardType("N");
|
|
|
+ int cnt = boardService.selectFileCount(dto);
|
|
|
if (cnt > 0) {
|
|
|
boardService.updateFile(dto);
|
|
|
} else {
|
|
@@ -314,14 +329,15 @@ public class BoardController extends LifeCenterController {
|
|
|
String path = config.filePath + "/" + dto.getFileName().trim();
|
|
|
File rFile = new File(path);
|
|
|
rFile.delete();
|
|
|
- boardService.deleteFile(postSeq);
|
|
|
+ dto.setBoardType("N");
|
|
|
+ boardService.deleteFile(dto);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
dto.setUpdateBy(sesId);
|
|
|
boardService.updateNoticeBoard(dto);
|
|
|
|
|
|
- return "redirect:/board/notice/content?postSeq=" + dto.getPostSeq();
|
|
|
+ return "redirect:/notice/content?postSeq=" + dto.getPostSeq();
|
|
|
}
|
|
|
|
|
|
@RequestMapping("/qna/list")
|
|
@@ -368,4 +384,237 @@ public class BoardController extends LifeCenterController {
|
|
|
mv.addObject("pageSize", dto.getLimitMax());
|
|
|
return mv;
|
|
|
}
|
|
|
+
|
|
|
+ @RequestMapping("/qna/new")
|
|
|
+ public ModelAndView boardQnaNew(HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ String sesGroupIdx = LifeCenterSessionController.getSession( request, "sesGroupIdx" );
|
|
|
+ ModelAndView mv = setMV("qna/new");
|
|
|
+ mv.addObject("groupIdx",sesGroupIdx);
|
|
|
+
|
|
|
+ return mv;
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping("/qna/new/insert")
|
|
|
+ @Transactional(propagation=Propagation.REQUIRED)
|
|
|
+ public String boardQnaNewInsert(
|
|
|
+ HttpServletRequest request, HttpServletResponse response,
|
|
|
+ @ModelAttribute("dto") final BoardDTO dto,
|
|
|
+ MultipartFile file) {
|
|
|
+ String sesId = LifeCenterSessionController.getSession(request, "sesId");
|
|
|
+
|
|
|
+ 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 {
|
|
|
+ String tempPath = config.filePath;
|
|
|
+ File saveFile = new File(tempPath, saveFileName);
|
|
|
+ FileCopyUtils.copy(file.getBytes(),saveFile);
|
|
|
+ } 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);
|
|
|
+ dto.setBoardType("Q");
|
|
|
+ }
|
|
|
+
|
|
|
+ String title = dto.getTitle().trim();
|
|
|
+ String content = dto.getContent().trim();
|
|
|
+
|
|
|
+ dto.setTitle(title);
|
|
|
+ dto.setContent(content);
|
|
|
+ dto.setCreateBy(sesId);
|
|
|
+
|
|
|
+ boardService.qnaInsert(dto);
|
|
|
+ int postSeq = dto.getPostSeq();
|
|
|
+
|
|
|
+ if (postSeq == 0) {
|
|
|
+ LifeCenterFunction.scriptMessage( response, "alertBox({ txt : '게시물 등록에 실패하였습니다.', callBack : function(){ history.back(); } });" );
|
|
|
+ return "/common/blank";
|
|
|
+ } else {
|
|
|
+ if (file.isEmpty() == false) {
|
|
|
+ boardService.fileUploadDataInsert(dto);
|
|
|
+ int fileIdx = dto.getFileIdx();
|
|
|
+ if (fileIdx == 0) {
|
|
|
+ LifeCenterFunction.scriptMessage( response, "alertBox({ txt : '게시물 등록에 실패하였습니다.', callBack : function(){ history.back(); } });" );
|
|
|
+ return "/common/blank";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return "redirect:/qna/content?postSeq=" + dto.getPostSeq();
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping("/qna/content")
|
|
|
+ public ModelAndView boardQnaContent(
|
|
|
+ @RequestParam(value="postSeq", required=false, defaultValue="") int postSeq,
|
|
|
+ HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ String referer = request.getHeader("referer");
|
|
|
+ String sesId = LifeCenterSessionController.getSession(request, "sesId");
|
|
|
+ String sesName = LifeCenterSessionController.getSession(request, "sesName");
|
|
|
+ String sesGroupIdx = LifeCenterSessionController.getSession( request, "sesGroupIdx" );
|
|
|
+
|
|
|
+ int total = boardService.selectQnaBoardCountOne(postSeq);
|
|
|
+ BoardDTO dto = new BoardDTO();
|
|
|
+ if (total > 0) {
|
|
|
+ boardService.updateQnaView(postSeq);
|
|
|
+ dto = boardService.selectQnaBoardInfoOne(postSeq);
|
|
|
+ }
|
|
|
+
|
|
|
+ int prePostCnt = boardService.selectQnaPrePostCount(postSeq);
|
|
|
+ int nextPostCnt = boardService.selectQnaNextPostCount(postSeq);
|
|
|
+
|
|
|
+ BoardDTO preDto = new BoardDTO();
|
|
|
+ BoardDTO nextDto = new BoardDTO();
|
|
|
+ if (prePostCnt > 0) {
|
|
|
+ preDto = boardService.selectQnaPrePost(postSeq);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (nextPostCnt > 0) {
|
|
|
+ nextDto = boardService.selectQnaNextPost(postSeq);
|
|
|
+ }
|
|
|
+
|
|
|
+ ModelAndView mv = setMV("qna/content");
|
|
|
+ mv.addObject("filePath", config.filePath);
|
|
|
+ mv.addObject("content", dto);
|
|
|
+ mv.addObject("sesId", sesId);
|
|
|
+ mv.addObject("sesName", sesName);
|
|
|
+ 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("/qna/content/answer")
|
|
|
+ public String boardQnaAnswer(HttpServletRequest request, HttpServletResponse response,
|
|
|
+ @ModelAttribute("dto") final BoardDTO dto) {
|
|
|
+
|
|
|
+ logger.error("postSeq -- > " + dto.getPostSeq());
|
|
|
+ logger.error("answerId -- > " + dto.getAnswerId());
|
|
|
+ logger.error("answerContent -- > " + dto.getAnswerContent());
|
|
|
+ boardService.qnaAnswerInsert(dto);
|
|
|
+
|
|
|
+ return "redirect:/qna/content?postSeq=" + dto.getPostSeq();
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping("/qna/edit")
|
|
|
+ public ModelAndView boarQnadEdit(HttpServletRequest request, HttpServletResponse response,
|
|
|
+ @RequestParam(value="postSeq", required=false, defaultValue="") int postSeq) {
|
|
|
+ ModelAndView mv = setMV("qna/edit");
|
|
|
+
|
|
|
+ BoardDTO dto = new BoardDTO();
|
|
|
+ int cnt = boardService.selectQnaBoardCountOne(postSeq);
|
|
|
+ if (cnt == 0) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ dto = boardService.selectQnaBoardInfoOne(postSeq);
|
|
|
+ }
|
|
|
+ mv.addObject("item", dto);
|
|
|
+ return mv;
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping("/qna/edit/update")
|
|
|
+ @Transactional(propagation=Propagation.REQUIRED)
|
|
|
+ public String boardQnaEditUpdate(
|
|
|
+ HttpServletRequest request, HttpServletResponse response,
|
|
|
+ @ModelAttribute("dto") final BoardDTO dto,
|
|
|
+ MultipartFile file) {
|
|
|
+
|
|
|
+ String sesId = LifeCenterSessionController.getSession(request, "sesId");
|
|
|
+
|
|
|
+ if (!sesId.equals(dto.getCreateBy())) {
|
|
|
+ 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);
|
|
|
+ dto.setBoardType("Q");
|
|
|
+ int cnt = boardService.selectFileCount(dto);
|
|
|
+ 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();
|
|
|
+ dto.setBoardType("Q");
|
|
|
+ boardService.deleteFile(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ dto.setUpdateBy(sesId);
|
|
|
+ boardService.updateQnaBoard(dto);
|
|
|
+
|
|
|
+ return "redirect:/qna/content?postSeq=" + postSeq;
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value="/qna/content/delete")
|
|
|
+ @Transactional(propagation=Propagation.REQUIRED)
|
|
|
+ public String contentQnaDelete(HttpServletRequest request, HttpServletResponse response,
|
|
|
+ @RequestParam(value="postSeq", required=false, defaultValue="") int postSeq,
|
|
|
+ @RequestParam(value="createBy", required=false, defaultValue="") String createBy,
|
|
|
+ @RequestParam(value="fileName", required=false, defaultValue="") String fileName) {
|
|
|
+
|
|
|
+ String sesId = LifeCenterSessionController.getSession(request, "sesId");
|
|
|
+
|
|
|
+ if (!sesId.equals(createBy)) {
|
|
|
+ LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '해당 글을 삭제할 수 없습니다.', callBack : function(){ location.href='/qna/list'; } });" );
|
|
|
+ return "/common/blank";
|
|
|
+ }
|
|
|
+
|
|
|
+ BoardDTO dto = new BoardDTO();
|
|
|
+ dto.setPostSeq(postSeq);
|
|
|
+ dto.setBoardType("Q");
|
|
|
+ boardService.deleteQnaIfno(postSeq);
|
|
|
+
|
|
|
+ String path = config.filePath + "/" + fileName.trim();
|
|
|
+ File rFile = new File(path);
|
|
|
+ rFile.delete();
|
|
|
+
|
|
|
+ boardService.deleteFile(dto);
|
|
|
+
|
|
|
+ LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '게시글이 삭제되었습니다. ', callBack : function(){ location.href='/qna/list'; } });" );
|
|
|
+
|
|
|
+ return "/common/blank";
|
|
|
+ }
|
|
|
}
|