BoardService
페이지 정보
본문
package web.service;
import java.util.List;
import java.util.stream.Collectors;
import web.domain.Board;
import web.dto.BoardDTO;
import web.dto.BoardListAllDTO;
import web.dto.BoardListReplyCountDTO;
import web.dto.PageRequestDTO;
import web.dto.PageResponseDTO;
public interface BoardService {
Long register(BoardDTO boardDTO); //등록
BoardDTO readOne(Long bno); //조회
void readOnePlus(Long bno); //조회 + 1 처리
void modify(BoardDTO boardDTO); //수정
void remove(Long bno); //삭제
PageResponseDTO<BoardDTO> list(PageRequestDTO pageRequestDTO); //목록
//댓글 수 출력 - 목록
PageResponseDTO<BoardListReplyCountDTO> listWithReplyCount(PageRequestDTO pageRequestDTO);
//게시글의 이미지와 댓글의 숫자까지 처리
PageResponseDTO<BoardListAllDTO> listWithAll(PageRequestDTO pageRequestDTO);
//DTO를 엔티티로 변환하기
default Board dtoToEntity(BoardDTO boardDTO) {
Board board = Board.builder()
.bno(boardDTO.getBno())
.title(boardDTO.getTitle())
.content(boardDTO.getContent())
.writer(boardDTO.getWriter())
.build();
if(boardDTO.getFileNames() != null) {
boardDTO.getFileNames().forEach(fileName -> {
String[] arr = fileName.split("_");
board.addImage(arr[0], arr[1]);
});
}
return board;
}
//엔티티를 DTO로 변환하기
default BoardDTO entityToDTO(Board board) {
BoardDTO boardDTO = BoardDTO.builder()
.bno(board.getBno())
.title(board.getTitle())
.content(board.getContent())
.writer(board.getWriter())
.regDate(board.getRegDate())
.modDate(board.getModDate())
.build();
List<String> fileNames = board.getImageSet()
.stream()
.sorted()
.map(boardImage -> boardImage.getUuid()+"_"+boardImage.getFileName())
.collect(Collectors.toList());
boardDTO.setFileNames(fileNames);
return boardDTO;
}
}
- 이전글BoardController 24.07.02
- 다음글BoardServiceImpl 24.07.02
댓글목록
등록된 댓글이 없습니다.