Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 스크랩 정보 조회 기능 #68

Merged
merged 2 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ public ApplicationResponse<PostScrapRes> scrapPost(@AuthenticationPrincipal Prin
return ApplicationResponse.ok(postService.scrapPost(principalDetails.getMember(), id));
}

@Operation(summary = "프로젝트 공고 스크랩 조회 기능", description = "프로젝트 공고 스크랩 조회")
@GetMapping("/scrap/{id}")
public ApplicationResponse<PostScrapRes> scrapGet(@AuthenticationPrincipal PrincipalDetails principalDetails, @PathVariable("id") Long id) {
return ApplicationResponse.ok(postService.scrapGet(principalDetails.getMember(), id));
}

@Operation(summary = "내가 모집 중인 팀 조회 API", description = "프로젝트/공모전 별 각 한 개씩 묶어서 리스트 형태로 반환")
@GetMapping("/my")
public ApplicationResponse<List<MyPageRes>> getMyPostList(@AuthenticationPrincipal PrincipalDetails principalDetails) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,21 @@ public PostScrapRes scrapPost(Member member, Long postId) {
}
}

public PostScrapRes scrapGet(Member member, Long postId){
try {
Post post = postRepository.findByPostIdAndDeletedAtIsNull(postId)
.orElseThrow(() -> new ApplicationException(NOT_FOUND_EXCEPTION));
if (member.getMemberId() == null) {
throw new ApplicationException(UNAUTHORIZED_EXCEPTION);
}

PostScrap postScrap = postScrapRepository.findByPostAndMember(post, member);
return new PostScrapRes(postScrap.getPost().getPostId(), postScrap.getMember().getMemberId(), postScrap.getScrapStatus());
}catch(Exception e) {
throw new ApplicationException(NOT_FOUND_EXCEPTION);
}
}

public List<MyPageRes> getMyPostList(Member member) {
// Validation

Expand Down
Loading