Skip to content

Commit

Permalink
fix : 전체 게시글 내용 가져오도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
ji-woong-song committed Dec 5, 2023
1 parent d0b9e01 commit 1cedf52
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package backend.spectrum.dguonoff.domain.admin.api;

import backend.spectrum.dguonoff.domain.admin.dto.BoardDetailDTO;
import backend.spectrum.dguonoff.domain.admin.dto.BoardOutlineDTO;
import backend.spectrum.dguonoff.domain.admin.dto.BoardTotalDTO;
import backend.spectrum.dguonoff.domain.admin.service.BoardService;
import java.util.List;
import lombok.RequiredArgsConstructor;
Expand All @@ -18,7 +18,7 @@ public class BoardController {
private final BoardService boardService;

@GetMapping("/")
public ResponseEntity<List<BoardOutlineDTO>> getOutlines() {
public ResponseEntity<List<BoardTotalDTO>> getOutlines() {
return ResponseEntity.ok(boardService.getOutlines());
}
@GetMapping("/{boardId}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
@Getter
@Builder
@AllArgsConstructor
public class BoardOutlineDTO {
public class BoardTotalDTO {
private Long boardId;
private String title;
private String authorId;
private String body;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import backend.spectrum.dguonoff.DAO.User;
import backend.spectrum.dguonoff.DAO.model.Role;
import backend.spectrum.dguonoff.domain.admin.dto.BoardDetailDTO;
import backend.spectrum.dguonoff.domain.admin.dto.BoardOutlineDTO;
import backend.spectrum.dguonoff.domain.admin.dto.BoardTotalDTO;
import backend.spectrum.dguonoff.domain.admin.dto.PostBoardDTO;
import backend.spectrum.dguonoff.domain.admin.repository.BoardRepository;
import backend.spectrum.dguonoff.domain.user.exception.UserNotFoundException;
Expand Down Expand Up @@ -51,11 +51,12 @@ public Long updateBoard(String userId, Long boardId ,PostBoardDTO dto) {
}

@Transactional(readOnly = true)
public List<BoardOutlineDTO> getOutlines() {
return boardRepository.findAll().stream().map(board -> BoardOutlineDTO.builder()
public List<BoardTotalDTO> getOutlines() {
return boardRepository.findAll().stream().map(board -> BoardTotalDTO.builder()
.boardId(board.getId())
.authorId(board.getAuthor().getId())
.title(board.getTitle())
.body(board.getBody())
.build()
).collect(Collectors.toList());
}
Expand Down

0 comments on commit 1cedf52

Please sign in to comment.