Skip to content

Commit

Permalink
Merge pull request #102 from SanE-Seo/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Changha-dev authored May 6, 2024
2 parents 4dd8117 + f695cb4 commit 0124950
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -56,7 +58,16 @@ public ResponseEntity<?> checkDuplicateName(@RequestParam String username) {
@GetMapping("/liked-posts/{category}")
public ResponseEntity<?> getLikedPosts(@LoginMember AuthMember authMember, @PathVariable int category) {
List<Post> posts = likesService.findLikedPostsByMember(authMember.getId());
List<GetPostDistrictResponse> posts1 = likesService.filterPostsByCategory(posts, category);
return ApiResponse.ok("좋아요한 게시글 조회 성공", posts1);
List<GetPostDistrictResponse> filterPostsByCategory = likesService.filterPostsByCategory(posts, category);
return ApiResponse.ok("좋아요한 게시글 조회 성공", filterPostsByCategory);
}
}

// 내가 생성한 게시글 조회
@GetMapping("/my-posts")
public ResponseEntity<?> getMyPosts(@LoginMember AuthMember authMember) {
List<Post> posts = postPort.findMyPosts(authMember.getId());
List<GetPostDistrictResponse> filterPostsByCategory = likesService.filterPostsByCategory(posts, 1);
return ApiResponse.ok("내가 생성한 게시글 조회 성공", filterPostsByCategory);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,10 @@ public boolean existsByNameAndDescription(String title, String description) {

}

@Override
public List<Post> findMyPosts(Long id) {
return postRepository.findByMemberId(id);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@

public interface PostRepository extends JpaRepository<Post, Long> {
boolean existsByTitleAndDescription(String title, String description);

List<Post> findByMemberId(Long id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ public interface PostPort {

boolean existsByNameAndDescription(String name, String description);

List<Post> findMyPosts(Long id);
}

0 comments on commit 0124950

Please sign in to comment.