Search in sources :

Example 21 with NodePtrDTO

use of com.worksmobile.Assignment.Domain.NodePtrDTO in project Assignment by WMPeople.

the class VersionManagementTest method testMakeLeapVersion.

@Test
public void testMakeLeapVersion() throws InterruptedException, ExecutionException, JsonProcessingException {
    BoardDTO child = new BoardDTO();
    child.setSubject("childSub");
    child.setContent("childCont");
    NodePtrDTO parentPtrDTO = defaultCreatedDTO;
    NodePtrDTO resultPtrDTO = versionManagementService.modifyVersion(child, parentPtrDTO);
    BoardDTO parentBoardDTO = boardMapper.viewDetail(parentPtrDTO.toMap());
    assertNull(parentBoardDTO);
    BoardDTO leapBoardDTO = boardMapper.viewDetail(resultPtrDTO.toMap());
    assertNotNull(leapBoardDTO);
    int defaultVersion = defaultBoardDTO.getVersion() == null ? 0 : defaultBoardDTO.getVersion();
    assertEquals((Integer) (defaultVersion + 1), resultPtrDTO.getVersion());
    child.setNodePtrDTO(resultPtrDTO);
    Utils.assertConvertToJsonObject(child, leapBoardDTO);
}
Also used : NodePtrDTO(com.worksmobile.Assignment.Domain.NodePtrDTO) BoardDTO(com.worksmobile.Assignment.Domain.BoardDTO) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 22 with NodePtrDTO

use of com.worksmobile.Assignment.Domain.NodePtrDTO in project Assignment by WMPeople.

the class BoardController method diff.

/**
 * 두 버전의 content를 비교할 때 호출되는 메쏘드 입니다.
 * @param board_id1 첫번째 버전의 board_id
 * @param version1 첫번째 버전의 version
 * @param board_id2 두번째 버전의 board_id
 * @param version2 두번째 버전의 version
 * @return modelAndView 객체로 viewName과, content를 프론트에 전송합니다.
 * @throws Exception
 */
@RequestMapping(value = "/boards/diff", method = RequestMethod.POST)
public ModelAndView diff(int board_id1, int version1, int board_id2, int version2) throws Exception {
    NodePtrDTO left = new NodePtrDTO(board_id1, version1);
    NodePtrDTO right = new NodePtrDTO(board_id2, version2);
    String leftContent = Compress.deCompress(boardHistoryMapper.getHistory(left).getHistory_content());
    String rightContent = Compress.deCompress(boardHistoryMapper.getHistory(right).getHistory_content());
    // 압출 해결 후 리턴 , 맵으로 리턴
    ModelAndView modelAndView = new ModelAndView();
    modelAndView.addObject("leftContent", leftContent);
    modelAndView.addObject("rightContent", rightContent);
    modelAndView.setViewName("diff");
    return modelAndView;
}
Also used : NodePtrDTO(com.worksmobile.Assignment.Domain.NodePtrDTO) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 23 with NodePtrDTO

use of com.worksmobile.Assignment.Domain.NodePtrDTO in project Assignment by WMPeople.

the class RestController method versionManagement.

/**
 * 버전관리 페이지 이동시 호출되는 메쏘드입니다.
 * @param board_id 버전관리를 원하는 LeafNode의 board_id
 * @param version 버전관리를 원하는 LeafNode의 version
 * @return modelAndView LeafNode의 이력 List를 프론트에 전송합니다.
 * @throws Exception
 */
@RequestMapping(value = "/boards/management/{board_id}/{version}", method = RequestMethod.GET)
public ModelAndView versionManagement(@PathVariable(value = "board_id") int board_id, @PathVariable(value = "version") int version) throws Exception {
    NodePtrDTO leapPtrDTO = new NodePtrDTO(board_id, version);
    List<BoardHistoryDTO> boardHistory = versionManagementService.getRelatedHistory(leapPtrDTO);
    ModelAndView modelAndView = new ModelAndView();
    modelAndView.addObject("list", boardHistory);
    modelAndView.setViewName("versionManagement");
    return modelAndView;
}
Also used : NodePtrDTO(com.worksmobile.Assignment.Domain.NodePtrDTO) ModelAndView(org.springframework.web.servlet.ModelAndView) BoardHistoryDTO(com.worksmobile.Assignment.Domain.BoardHistoryDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 24 with NodePtrDTO

use of com.worksmobile.Assignment.Domain.NodePtrDTO in project Assignment by WMPeople.

the class RestController method versionRecover.

/**
 * 버전관리 페이지에서 버전 복구 버튼을 눌렀을 때 호출되는 메쏘드 입니다.
 * @param board_id 복원을 원하는 버전 board_id
 * @param version 복원을 원하는 버전 version
 * @param leafBoard_id 복원을 원하는 버전의 LeafNode의 board_id
 * @param leafVersion  복원을 원하는 버전의 LeafNode의 version
 * @return resultMap 버전 복구 후 url 주소와 메쏘드 실행 성공 유무를 알려주는 Map을 리턴합니다.
 * @throws Exception
 */
@RequestMapping(value = "/boards/recover/{board_id}/{version}/{leafBoard_id}/{leafVersion}", method = RequestMethod.GET)
public Map<String, Object> versionRecover(@PathVariable(value = "board_id") int board_id, @PathVariable(value = "version") int version, @PathVariable(value = "leafBoard_id") int leafBoard_id, @PathVariable(value = "leafVersion") int leafVersion) throws Exception {
    Map<String, Object> resultMap = new HashMap<String, Object>();
    NodePtrDTO newLeapNode = null;
    try {
        NodePtrDTO recoverPtr = new NodePtrDTO(board_id, version);
        NodePtrDTO leapNodePtr = new NodePtrDTO();
        leapNodePtr.setBoard_id(leafBoard_id);
        leapNodePtr.setVersion(leafVersion);
        newLeapNode = versionManagementService.recoverVersion(recoverPtr, leapNodePtr);
        resultMap.put("result", "success");
    } catch (Exception e) {
        resultMap.put("result", e.getMessage());
        return resultMap;
    }
    resultMap.put("board_id", newLeapNode.getBoard_id());
    resultMap.put("version", newLeapNode.getVersion());
    return resultMap;
}
Also used : NodePtrDTO(com.worksmobile.Assignment.Domain.NodePtrDTO) HashMap(java.util.HashMap) IOException(java.io.IOException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 25 with NodePtrDTO

use of com.worksmobile.Assignment.Domain.NodePtrDTO in project Assignment by WMPeople.

the class RestController method updateMaintainAttachment.

/**
 * 게시물에 첨부파일을 유지하고 싶은 경우를 글수정 데이터를 받아 DB에 등록합니다.
 * @param board 사용자가 수정한 board 데이터를 받습니다.
 * 글 수정 전 자신의 첨부파일을 DB에서 가져와 새로운 게시물에 등록합니다.
 */
@RequestMapping(value = "/boards/update3", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> updateMaintainAttachment(BoardDTO board) {
    Map<String, Object> resultMap = new HashMap<String, Object>();
    try {
        BoardDTO pastBoard = new BoardDTO();
        HashMap<String, Integer> params = new HashMap<String, Integer>();
        params.put("board_id", board.getBoard_id());
        params.put("version", board.getVersion());
        pastBoard = boardMapper.viewDetail(params);
        if (pastBoard == null) {
            String json = Utils.jsonStringIfExceptionToString(pastBoard);
            throw new RuntimeException("update3 메소드에서 viewDetail 메소드 실행 에러" + json);
        }
        board.setFile_id(pastBoard.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());
        return resultMap;
    }
    return resultMap;
}
Also used : NodePtrDTO(com.worksmobile.Assignment.Domain.NodePtrDTO) HashMap(java.util.HashMap) BoardDTO(com.worksmobile.Assignment.Domain.BoardDTO) IOException(java.io.IOException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

NodePtrDTO (com.worksmobile.Assignment.Domain.NodePtrDTO)29 BoardHistoryDTO (com.worksmobile.Assignment.Domain.BoardHistoryDTO)16 Test (org.junit.Test)15 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)15 BoardDTO (com.worksmobile.Assignment.Domain.BoardDTO)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)5 ModelAndView (org.springframework.web.servlet.ModelAndView)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 FileDTO (com.worksmobile.Assignment.Domain.FileDTO)2 Transactional (org.springframework.transaction.annotation.Transactional)2 MultipartFile (org.springframework.web.multipart.MultipartFile)1