use of com.worksmobile.Assignment.Domain.NodePtrDTO in project Assignment by WMPeople.
the class RestController method versionDestory.
/**
* 버전 삭제시 호출 되는 메쏘드 입니다.
* @param board_id 버전 삭제를 원하는 이력의 board_id
* @param version 버전 삭제를 원하는 이력의 version
* @return 성공 했는지 실패 했는지를 알려주는 Map을 리턴합니다.
*/
@RequestMapping(value = "/boards/version/{board_id}/{version}", method = RequestMethod.DELETE)
@ResponseBody
public Map<String, Object> versionDestory(@PathVariable(value = "board_id") int board_id, @PathVariable(value = "version") int version) {
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
NodePtrDTO deletePtrDTO = new NodePtrDTO(board_id, version);
BoardHistoryDTO deleteHistoryDTO = boardHistoryMapper.getHistory(deletePtrDTO);
int file_id = deleteHistoryDTO.getFile_id();
int fileCount = 0;
if (file_id != 0) {
fileCount = boardHistoryMapper.getFileCount(file_id);
}
if (fileCount == 1) {
int deletedCnt2 = fileMapper.deleteFile(file_id);
if (deletedCnt2 != 1) {
throw new RuntimeException("파일 삭제 에러");
}
;
}
versionManagementService.deleteVersion(deletePtrDTO);
resultMap.put("result", "success");
} catch (Exception e) {
resultMap.put("result", e.getMessage());
return resultMap;
}
return resultMap;
}
use of com.worksmobile.Assignment.Domain.NodePtrDTO in project Assignment by WMPeople.
the class VersionManagementTest method testCreateTempArticle.
@Test
public void testCreateTempArticle() throws IOException {
BoardDTO tempArticle = new BoardDTO();
tempArticle.setSubject("임시저장중...");
tempArticle.setContent("temp article content");
tempArticle.setBoard_id(defaultCreatedDTO.getBoard_id());
versionManagementService.createTempArticleOverwrite(tempArticle);
BoardDTO dbTempArticle = boardMapper.viewDetail(new NodePtrDTO(tempArticle.getBoard_id(), 0).toMap());
Utils.assertConvertToJsonObject(tempArticle.toMap(), dbTempArticle.toMap());
Utils.assertConvertToJsonObject(tempArticle, dbTempArticle);
BoardHistoryDTO dbTempHistoryDTO = boardHistoryMapper.getHistory(tempArticle);
Utils.assertConvertToJsonObject(tempArticle.toMap(), dbTempHistoryDTO.toMap());
assertEquals(tempArticle.getSubject(), dbTempHistoryDTO.getHistory_subject());
String decompressedContent = Compress.deCompress(dbTempHistoryDTO.getHistory_content());
assertEquals(tempArticle.getContent(), decompressedContent);
}
use of com.worksmobile.Assignment.Domain.NodePtrDTO in project Assignment by WMPeople.
the class VersionManagementTest method makeChild.
private NodePtrDTO makeChild(NodePtrDTO parentPtrDTO) throws JsonProcessingException {
BoardDTO child = new BoardDTO();
child.setSubject("childSub");
child.setContent("childCont");
NodePtrDTO childPtrDTO = versionManagementService.modifyVersion(child, parentPtrDTO);
child.setNodePtrDTO(childPtrDTO);
BoardDTO leapBoardDTO = boardMapper.viewDetail(childPtrDTO.toMap());
assertNotNull(leapBoardDTO);
int parentVersion = parentPtrDTO.getVersion() == null ? 0 : parentPtrDTO.getVersion();
assertEquals((Integer) (parentVersion + 1), childPtrDTO.getVersion());
Utils.assertConvertToJsonObject(child, leapBoardDTO);
return childPtrDTO;
}
use of com.worksmobile.Assignment.Domain.NodePtrDTO in project Assignment by WMPeople.
the class VersionManagementTest method testDeleteLeapNode.
@Test
public void testDeleteLeapNode() throws JsonProcessingException {
NodePtrDTO rootPtrDTO = defaultCreatedDTO;
NodePtrDTO deletePtrDTO = makeChild(rootPtrDTO);
versionManagementService.deleteVersion(deletePtrDTO);
List<BoardHistoryDTO> children = boardHistoryMapper.getChildren(rootPtrDTO);
assertEquals(0, children.size());
}
Aggregations