From 0c8624c9783d8c0f379ff72576b0136985e8002f Mon Sep 17 00:00:00 2001 From: changha Date: Mon, 6 May 2024 16:08:24 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=A7=88=EC=9D=B4=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20=EB=82=B4=EA=B0=80=20=EC=83=9D=EC=84=B1=ED=95=9C=20?= =?UTF-8?q?=EA=B2=8C=EC=8B=9C=EA=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/adapter/in/web/MemberController.java | 17 ++++++++++++++--- .../sanEseo/post/adapter/PostAdapter.java | 5 +++++ .../sanEseo/post/adapter/PostRepository.java | 2 ++ .../sanEseo/post/application/port/PostPort.java | 1 + 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/seoultech/sanEseo/member/adapter/in/web/MemberController.java b/src/main/java/com/seoultech/sanEseo/member/adapter/in/web/MemberController.java index 9c98729..a4c461a 100644 --- a/src/main/java/com/seoultech/sanEseo/member/adapter/in/web/MemberController.java +++ b/src/main/java/com/seoultech/sanEseo/member/adapter/in/web/MemberController.java @@ -11,6 +11,7 @@ import com.seoultech.sanEseo.member.application.port.out.MemberPort; import com.seoultech.sanEseo.member.application.service.AuthService; import com.seoultech.sanEseo.member.application.service.MemberService; +import com.seoultech.sanEseo.post.application.port.PostPort; import com.seoultech.sanEseo.post.domain.Post; import com.seoultech.sanEseo.post_district.application.service.GetPostDistrictResponse; import lombok.RequiredArgsConstructor; @@ -28,6 +29,7 @@ public class MemberController { private final MemberService memberService; private final AuthUseCase authUseCase; private final LikeService likesService; + private final PostPort postPort; @PostMapping public ResponseEntity register(@RequestBody RegisterRequest request) { @@ -56,7 +58,16 @@ public ResponseEntity checkDuplicateName(@RequestParam String username) { @GetMapping("/liked-posts/{category}") public ResponseEntity getLikedPosts(@LoginMember AuthMember authMember, @PathVariable int category) { List posts = likesService.findLikedPostsByMember(authMember.getId()); - List posts1 = likesService.filterPostsByCategory(posts, category); - return ApiResponse.ok("좋아요한 게시글 조회 성공", posts1); + List filterPostsByCategory = likesService.filterPostsByCategory(posts, category); + return ApiResponse.ok("좋아요한 게시글 조회 성공", filterPostsByCategory); } -} + + // 내가 생성한 게시글 조회 + @GetMapping("/my-posts") + public ResponseEntity getMyPosts(@LoginMember AuthMember authMember) { + List posts = postPort.findMyPosts(authMember.getId()); + List filterPostsByCategory = likesService.filterPostsByCategory(posts, 1); + return ApiResponse.ok("내가 생성한 게시글 조회 성공", filterPostsByCategory); + } + +} \ No newline at end of file diff --git a/src/main/java/com/seoultech/sanEseo/post/adapter/PostAdapter.java b/src/main/java/com/seoultech/sanEseo/post/adapter/PostAdapter.java index 443ba26..0b09542 100644 --- a/src/main/java/com/seoultech/sanEseo/post/adapter/PostAdapter.java +++ b/src/main/java/com/seoultech/sanEseo/post/adapter/PostAdapter.java @@ -40,5 +40,10 @@ public boolean existsByNameAndDescription(String title, String description) { } + @Override + public List findMyPosts(Long id) { + return postRepository.findByMemberId(id); + } + } diff --git a/src/main/java/com/seoultech/sanEseo/post/adapter/PostRepository.java b/src/main/java/com/seoultech/sanEseo/post/adapter/PostRepository.java index c8f2bba..2dbc8d1 100644 --- a/src/main/java/com/seoultech/sanEseo/post/adapter/PostRepository.java +++ b/src/main/java/com/seoultech/sanEseo/post/adapter/PostRepository.java @@ -7,4 +7,6 @@ public interface PostRepository extends JpaRepository { boolean existsByTitleAndDescription(String title, String description); + + List findByMemberId(Long id); } diff --git a/src/main/java/com/seoultech/sanEseo/post/application/port/PostPort.java b/src/main/java/com/seoultech/sanEseo/post/application/port/PostPort.java index 044cf1b..389a13f 100644 --- a/src/main/java/com/seoultech/sanEseo/post/application/port/PostPort.java +++ b/src/main/java/com/seoultech/sanEseo/post/application/port/PostPort.java @@ -14,4 +14,5 @@ public interface PostPort { boolean existsByNameAndDescription(String name, String description); + List findMyPosts(Long id); }