Search in sources :

Example 1 with BoardResponseDTO

use of com.varsql.web.dto.board.BoardResponseDTO in project varsql by varsqlinfo.

the class BoardService method viewBoardInfo.

/**
 * @Method Name  : viewBoardInfo
 * @Method 설명 : 글 상세보기.
 * @작성자   : ytkim
 * @작성일   : 2021. 7. 8.
 * @변경이력  :
 * @param boardCode
 * @param articleId
 * @return
 */
public BoardResponseDTO viewBoardInfo(String boardCode, long articleId) {
    BoardEntity boardEntity = boardEntityRepository.findByArticleId(articleId);
    if (boardEntity == null) {
        throw new BoardNotFoundException("article id not found : " + articleId);
    }
    BoardResponseDTO dto = BoardResponseDTO.toDto(boardEntity, true);
    dto.setModifyAuth(isModify(boardEntity));
    return dto;
}
Also used : BoardResponseDTO(com.varsql.web.dto.board.BoardResponseDTO) BoardEntity(com.varsql.web.model.entity.board.BoardEntity) BoardNotFoundException(com.varsql.web.exception.BoardNotFoundException)

Example 2 with BoardResponseDTO

use of com.varsql.web.dto.board.BoardResponseDTO in project varsql by varsqlinfo.

the class BoardController method modify.

@RequestMapping(value = "/{" + VarsqlParamConstants.BOARD_CODE + "}/modify", method = RequestMethod.GET)
public ModelAndView modify(@PathVariable(required = true, name = VarsqlParamConstants.BOARD_CODE) String boardCode, @RequestParam(value = "articleId", required = true) long articleId, HttpServletRequest req, ModelAndView mav) throws Exception {
    boardCode = VarsqlUtils.getVonnid(req);
    BoardResponseDTO dto = boardService.viewBoardInfo(boardCode, articleId);
    if (!dto.isModifyAuth()) {
        throw new PermissionDeniedException("no permission");
    }
    ModelMap model = mav.getModelMap();
    model.addAttribute("param", HttpUtils.getServletRequestParam(req));
    model.addAttribute("articleInfo", VartechUtils.objectToJsonString(dto));
    return getModelAndView("/boardWrite", VIEW_PAGE.BOARD, model);
}
Also used : BoardResponseDTO(com.varsql.web.dto.board.BoardResponseDTO) ModelMap(org.springframework.ui.ModelMap) PermissionDeniedException(com.varsql.core.exception.PermissionDeniedException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

BoardResponseDTO (com.varsql.web.dto.board.BoardResponseDTO)2 PermissionDeniedException (com.varsql.core.exception.PermissionDeniedException)1 BoardNotFoundException (com.varsql.web.exception.BoardNotFoundException)1 BoardEntity (com.varsql.web.model.entity.board.BoardEntity)1 ModelMap (org.springframework.ui.ModelMap)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1