use of com.worksmobile.Assignment.Domain.NodePtrDTO in project Assignment by WMPeople.
the class RestController method destroy.
/**
* 게시물 삭제시 호출되는 함수입니다.
* @param board_id 삭제를 원하는 게시물의 board_id
* @param version 삭제를 원하는 게시물의 version
*/
@RequestMapping(value = "/boards/{board_id}/{version}", method = RequestMethod.DELETE)
@ResponseBody
public Map<String, Object> destroy(@PathVariable(value = "board_id") int board_id, @PathVariable(value = "version") int version) throws Exception {
Map<String, Object> resultMap = new HashMap<>();
try {
NodePtrDTO leapPtrDTO = new NodePtrDTO(board_id, version);
versionManagementService.deleteArticle(leapPtrDTO);
resultMap.put("result", "success");
} catch (Exception e) {
resultMap.put("result", e.getMessage());
}
return resultMap;
}
use of com.worksmobile.Assignment.Domain.NodePtrDTO in project Assignment by WMPeople.
the class RestController method history.
/**
* 이력 상세보기 입니다.
* @param board_id 상세 조회 할 게시물의 board_id
* @param version 상세 조회 할 게시물의 version
* @return modelAndView 이력의 상세 내용, board-boardHistory 구분자 , file 데이터 , viewName을 리턴합니다.
*/
@RequestMapping(value = "/history/{board_id}/{version}", method = RequestMethod.GET)
@ResponseBody
public ModelAndView history(@PathVariable(value = "board_id") int board_id, @PathVariable(value = "version") int version) {
NodePtrDTO node = new NodePtrDTO(board_id, version);
BoardHistoryDTO boardHistory = boardHistoryMapper.getHistory(node);
BoardDTO board = new BoardDTO(boardHistory);
FileDTO file = fileMapper.getFile(board.getFile_id());
String deCompreesedContent = "";
try {
deCompreesedContent = Compress.deCompress(boardHistory.getHistory_content());
} catch (IOException e) {
e.printStackTrace();
deCompreesedContent = "압축 해제 실패";
throw new RuntimeException(e);
}
board.setContent(deCompreesedContent);
ModelAndView modelAndView = new ModelAndView();
modelAndView.addObject("board", board);
modelAndView.addObject("isHistory", 1);
modelAndView.addObject("file", file);
modelAndView.setViewName("boardDetail");
return modelAndView;
}
use of com.worksmobile.Assignment.Domain.NodePtrDTO in project Assignment by WMPeople.
the class RestController method updateWithoutAttachment.
/**
* 게시물에 첨부파일을 유지하고 싶은 경우를 제외하고는 글수정 데이터를 받아 DB에 등록합니다.
* @param board 사용자가 수정한 board 데이터를 받습니다.
* @param attachment 첨부파일 데이터를 받습니다.
*/
@RequestMapping(value = "/boards/update2", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> updateWithoutAttachment(BoardDTO board, MultipartHttpServletRequest attachment) {
Map<String, Object> resultMap = new HashMap<>();
MultipartFile mFile = null;
Iterator<String> iter = attachment.getFileNames();
while (iter.hasNext()) {
String uploadFile_name = iter.next();
mFile = attachment.getFile(uploadFile_name);
}
try {
if (mFile != null) {
if (!mFile.getOriginalFilename().equals("")) {
FileDTO file = new FileDTO();
file.setFile_name(mFile.getOriginalFilename());
file.setFile_data(mFile.getBytes());
file.setFile_size(mFile.getSize());
fileMapper.createFile(file);
board.setFile_id(file.getFile_id());
}
}
NodePtrDTO leapPtrDTO = new NodePtrDTO(board.getBoard_id(), board.getVersion());
NodePtrDTO newNode = versionManagementService.modifyVersion(board, leapPtrDTO);
if (newNode == null) {
resultMap.put("result", "수정 실패");
} else {
resultMap.put("result", "success");
}
} catch (Exception e) {
resultMap.put("result", e.getMessage());
e.printStackTrace();
return resultMap;
}
return resultMap;
}
use of com.worksmobile.Assignment.Domain.NodePtrDTO in project Assignment by WMPeople.
the class VersionManagementTest method testRecoverVersion.
@Test
public void testRecoverVersion() throws InterruptedException, ExecutionException, JsonProcessingException {
BoardHistoryDTO createdHistoryDTO = versionManagementService.createArticle(defaultBoardDTO);
NodePtrDTO prevPtrDTO = createdHistoryDTO;
BoardDTO prevLeapDTO = boardMapper.viewDetail(prevPtrDTO.toMap());
NodePtrDTO newLeapPtrDTO = versionManagementService.recoverVersion(prevPtrDTO, prevPtrDTO);
BoardHistoryDTO recoveredHistoryDTO = boardHistoryMapper.getHistory(newLeapPtrDTO);
BoardDTO newLeapDTO = boardMapper.viewDetail(newLeapPtrDTO.toMap());
prevLeapDTO.setNodePtrDTO(newLeapPtrDTO);
assertNotNull(recoveredHistoryDTO);
Utils.assertConvertToJsonObject(newLeapDTO, prevLeapDTO);
}
use of com.worksmobile.Assignment.Domain.NodePtrDTO in project Assignment by WMPeople.
the class VersionManagementTest method testDeleteRootNode.
@Test
public void testDeleteRootNode() throws JsonProcessingException {
NodePtrDTO child = makeChild(defaultCreatedDTO);
assertNotNull(child);
NodePtrDTO newLeafNodePtr = versionManagementService.deleteVersion(defaultCreatedDTO);
assertNull(newLeafNodePtr);
}
Aggregations