From b45563609bd124be2dd676d59cf3785a0b5fc56a Mon Sep 17 00:00:00 2001 From: "Lee, yeeun" Date: Fri, 22 Nov 2024 19:18:02 +0900 Subject: [PATCH 1/3] =?UTF-8?q?:recycle:Refactor:=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=9E=90=EA=B0=80=20=EC=B2=98=EC=9D=8C=20=EC=9E=91=EC=84=B1?= =?UTF-8?q?=ED=95=9C=20PT=20=EC=98=81=EC=83=81=20=EA=B2=8C=EC=8B=9C?= =?UTF-8?q?=EA=B8=80=20=EC=A1=B0=ED=9A=8C=20repository=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/board/domain/repository/BoardRepository.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/univ/yesummit/domain/board/domain/repository/BoardRepository.java b/src/main/java/univ/yesummit/domain/board/domain/repository/BoardRepository.java index 1724aba..d95ba57 100644 --- a/src/main/java/univ/yesummit/domain/board/domain/repository/BoardRepository.java +++ b/src/main/java/univ/yesummit/domain/board/domain/repository/BoardRepository.java @@ -2,10 +2,12 @@ import org.springframework.data.jpa.repository.JpaRepository; import univ.yesummit.domain.board.domain.Board; +import univ.yesummit.domain.member.entity.Member; import java.util.List; - +import java.util.Optional; public interface BoardRepository extends JpaRepository { + Optional findFirstByWriter(Member member); List findBySummitId(Long summitId); } From 00c3830ddd07809119e9ae797a2260da172276b2 Mon Sep 17 00:00:00 2001 From: "Lee, yeeun" Date: Fri, 22 Nov 2024 19:18:30 +0900 Subject: [PATCH 2/3] =?UTF-8?q?:recycle:Refactor:=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=9E=90=EA=B0=80=20=EC=B2=98=EC=9D=8C=20=EC=9E=91=EC=84=B1?= =?UTF-8?q?=ED=95=9C=20PT=20=EC=98=81=EC=83=81=20=EA=B2=8C=EC=8B=9C?= =?UTF-8?q?=EA=B8=80=20=EC=A1=B0=ED=9A=8C=20service=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yesummit/domain/board/application/BoardService.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/univ/yesummit/domain/board/application/BoardService.java b/src/main/java/univ/yesummit/domain/board/application/BoardService.java index e635d94..db393d3 100644 --- a/src/main/java/univ/yesummit/domain/board/application/BoardService.java +++ b/src/main/java/univ/yesummit/domain/board/application/BoardService.java @@ -80,17 +80,14 @@ public BoardInfoResDto boardInfo(Long boardId) { // (내가 작성한) 게시글 한개 조회 @Transactional - public BoardInfoResDto myBoardInfo(Long memberId, Long boardId) { + public BoardInfoResDto myBoardInfo(Long memberId) { Member member = memberRepository.findById(memberId) .orElseThrow(() -> new IllegalArgumentException("회원이 존재하지 않습니다.")); - Board board = boardRepository.findById(boardId) + Board board = boardRepository.findFirstByWriter(member) .orElseThrow(() -> new IllegalArgumentException("게시글이 존재하지 않습니다.")); - checkBoardOwnership(member, board); - boolean isLike = boardLikeRepository.existsByBoardAndMember(board, member); - return BoardInfoResDto.of(member, board, isLike); } @@ -148,4 +145,4 @@ public Board findById(Long boardId) { return boardRepository.findById(boardId) .orElseThrow(() -> new IllegalArgumentException("게시글이 존재하지 않습니다.")); } -} \ No newline at end of file +} From fa916e358bbf75a4ac00c13af77f4f3c30bbcb2c Mon Sep 17 00:00:00 2001 From: "Lee, yeeun" Date: Fri, 22 Nov 2024 19:18:47 +0900 Subject: [PATCH 3/3] =?UTF-8?q?:recycle:Refactor:=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=9E=90=EA=B0=80=20=EC=B2=98=EC=9D=8C=20=EC=9E=91=EC=84=B1?= =?UTF-8?q?=ED=95=9C=20PT=20=EC=98=81=EC=83=81=20=EA=B2=8C=EC=8B=9C?= =?UTF-8?q?=EA=B8=80=20=EC=A1=B0=ED=9A=8C=20controller=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/univ/yesummit/domain/board/api/BoardController.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/univ/yesummit/domain/board/api/BoardController.java b/src/main/java/univ/yesummit/domain/board/api/BoardController.java index 64023a4..1341f0f 100644 --- a/src/main/java/univ/yesummit/domain/board/api/BoardController.java +++ b/src/main/java/univ/yesummit/domain/board/api/BoardController.java @@ -73,8 +73,8 @@ public ResponseEntity boardInfo(@PathVariable(name = "boardId") @ApiResponse(responseCode = "404", description = "게시글 없음", content = @Content(schema = @Schema(example = "게시글이 존재하지 않습니다."))), }) @GetMapping("/my") - public ResponseEntity myBoardInfo(@User LoginUser loginUser, @PathVariable(name = "boardId") Long boardId) { - BoardInfoResDto myBoardInfo = boardService.myBoardInfo(loginUser.getMemberId(), boardId); + public ResponseEntity myBoardInfo(@User LoginUser loginUser) { + BoardInfoResDto myBoardInfo = boardService.myBoardInfo(loginUser.getMemberId()); return new ResponseEntity<>(myBoardInfo, HttpStatus.OK); } @@ -107,4 +107,5 @@ public ResponseEntity boardDelete(@User LoginUser loginUser, boardService.boardDelete(loginUser.getMemberId(), boardId); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } + }