Skip to content

Commit

Permalink
Merge pull request #44 from 9oormthon-univ/dev
Browse files Browse the repository at this point in the history
⚡Feat: 게시글 관련 로직 수정
  • Loading branch information
eunxeum authored Nov 23, 2024
2 parents 17eda10 + 62b0056 commit 751deb0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public ResponseEntity<List<BoardInfoResDto>> allBoardInfo(@PathVariable Long sum
@ApiResponse(responseCode = "404", description = "게시글 없음", content = @Content(schema = @Schema(example = "게시글이 존재하지 않습니다.")))
})
@GetMapping("/{boardId}")
public ResponseEntity<BoardInfoResDto> boardInfo(@PathVariable(name = "boardId") Long boardId) {
BoardInfoResDto boardInfo = boardService.boardInfo(boardId);
public ResponseEntity<BoardInfoResDto> boardInfo(@PathVariable(name = "boardId") Long boardId, @User LoginUser loginUser) {
BoardInfoResDto boardInfo = boardService.boardInfo(boardId, loginUser.getMemberId());
return new ResponseEntity<>(boardInfo, HttpStatus.OK);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import univ.yesummit.domain.board.api.dto.request.BoardSaveReqDto;
import univ.yesummit.domain.board.api.dto.request.BoardUpdateReqDto;
import univ.yesummit.domain.board.api.dto.response.BoardInfoResDto;
Expand All @@ -17,9 +16,7 @@
import univ.yesummit.domain.feed.repository.FeedRepository;
import univ.yesummit.domain.member.entity.Member;
import univ.yesummit.domain.member.repository.MemberRepository;
import univ.yesummit.global.s3.service.S3Service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -83,11 +80,12 @@ public List<BoardInfoResDto> allBoardInfoBySummitId(Long summitId, Long memberId

// 게시글 한개 조회
@Transactional
public BoardInfoResDto boardInfo(Long boardId) {
public BoardInfoResDto boardInfo(Long boardId, Long memberId) {
Member member = memberRepository.findById(memberId)
.orElseThrow(() -> new IllegalArgumentException("회원이 존재하지 않습니다."));
Board board = boardRepository.findById(boardId)
.orElseThrow(() -> new IllegalArgumentException("게시글이 존재하지 않습니다."));

return BoardInfoResDto.of(null, board, false);
return BoardInfoResDto.of(member, board, false);
}

// (내가 작성한) 게시글 한개 조회
Expand Down

0 comments on commit 751deb0

Please sign in to comment.