Skip to content

Commit

Permalink
Merge pull request #94 from SanE-Seo/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Changha-dev authored May 5, 2024
2 parents a739393 + df2d658 commit a6f6fcd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
import com.seoultech.sanEseo.global.config.web.AuthMember;
import com.seoultech.sanEseo.global.config.web.LoginMember;
import com.seoultech.sanEseo.global.response.ApiResponse;
import com.seoultech.sanEseo.like.application.service.LikeService;
import com.seoultech.sanEseo.post.application.service.AddPostRequest;

import com.seoultech.sanEseo.post.application.service.GetPostResponse;
import com.seoultech.sanEseo.post.application.service.PostService;
import com.seoultech.sanEseo.post.application.service.UpdatePostRequest;
import com.seoultech.sanEseo.post.domain.Post;
import com.seoultech.sanEseo.post_district.application.service.GetPostDistrictResponse;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

Expand All @@ -20,9 +19,11 @@
@RequestMapping("/api/posts")
public class PostController {
private final PostService postService;
private final LikeService likeService;

public PostController(PostService postService) {
public PostController(PostService postService, LikeService likeService) {
this.postService = postService;
this.likeService = likeService;
}

@PostMapping
Expand Down Expand Up @@ -52,7 +53,9 @@ public ResponseEntity<?> deletePost(@LoginMember AuthMember authMember, @PathVar
@GetMapping("/by-district-prefix")
public ResponseEntity<?> getPostsByDistrictPrefix(@RequestParam String districtName) {
List<Post> posts = postService.findPostsByDistrictNameStart(districtName);
return ApiResponse.ok("입력된 자치구를 포함하는 게시글 반환 완료.", posts);
List<Post> filterPostsByCategory = likeService.filterPostsByCategory(posts, 1);

return ApiResponse.ok("입력된 자치구를 포함하는 게시글 반환 완료", filterPostsByCategory);
}

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

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

List<Post> findByMemberId(Long memberId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ public PostDistrictService(DistrictPort districtPort, PostDistrictPort postDistr
this.postPort = postPort;
}

public void createPostDistrictRelation(Post post, Long districtId) {
District district = districtPort.findById(districtId);
PostDistrict postDistrict = new PostDistrict(post, district);

postDistrictPort.save(postDistrict);

}

public List<GetPostDistrictResponse> getPostDistrict(Long districtId) {
List<PostDistrict> postDistricts = postDistrictPort.findByDistrictId(districtId);
// 해당 post의 image를 가져오기 위해 imageService를 사용
Expand Down

0 comments on commit a6f6fcd

Please sign in to comment.