Skip to content

Commit

Permalink
merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
yumzen committed May 22, 2024
2 parents f855618 + f011ac9 commit 4354a9d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequiredArgsConstructor
@RestController
@RequestMapping("/api/v1/apply")
Expand All @@ -30,19 +31,19 @@ public ApplicationResponse<Void> createApply(@AuthenticationPrincipal PrincipalD
//팀 공고 요청 api
@Operation(summary = "내가 모집 중인 팀 정보 API", description = "내가 모집 중인 팀 페이지에서 필요한 팀 정보 요청")
@GetMapping("/{post_id}")
public ApplicationResponse<ApplyRes> getApply(@AuthenticationPrincipal PrincipalDetails principalDetails,@PathVariable("post_id") Long postId){
public ApplicationResponse<ApplyRes> getApply(@AuthenticationPrincipal PrincipalDetails principalDetails, @PathVariable("post_id") Long postId){
return ApplicationResponse.ok(applyService.findApply(principalDetails.getMember(),postId));
}
//내가 모집 중인 팀 지원자 정보 요청 api
@Operation(summary = "내가 모집 중인 팀 지원자 정보 API", description = "내가 모집 중인 팀 페이지에서 필요한 지원자 정보 요청")
@GetMapping("/{post_id}/applylist")
public ApplicationResponse<ApplyPageRes> getApplyList(@AuthenticationPrincipal PrincipalDetails principalDetails,@PathVariable("post_id") Long postId,@RequestParam(name = "page", defaultValue = "0") int page,@RequestParam(name = "size", defaultValue = "11") int size){
public ApplicationResponse<ApplyPageRes> getApplyList(@AuthenticationPrincipal PrincipalDetails principalDetails, @PathVariable("post_id") Long postId, @RequestParam(name = "page", defaultValue = "0") int page, @RequestParam(name = "size", defaultValue = "11") int size){
return ApplicationResponse.ok(applyService.applyListPage(principalDetails.getMember(),postId,page,size));
}
//내가 참여한 공고 정보 요청 api
@Operation(summary = "내가 참여한 공고 정보 API", description = "내가 참여한 공고 정보")
@GetMapping("/my-participation-post")
public ApplicationResponse<ParticipationPageRes> getMyParticipationPostList(@AuthenticationPrincipal PrincipalDetails principalDetails,@RequestParam(name = "page", defaultValue = "0") int page,@RequestParam(name = "size", defaultValue = "6") int size){
public ApplicationResponse<ParticipationPageRes> getMyParticipationPostList(@AuthenticationPrincipal PrincipalDetails principalDetails, @RequestParam(name = "page", defaultValue = "0") int page, @RequestParam(name = "size", defaultValue = "6") int size){
return ApplicationResponse.ok(applyService.myParticipationPostListPage(principalDetails.getMember(),page,size));
}
//지원서 열람 요청 api
Expand Down Expand Up @@ -102,8 +103,8 @@ public ApplicationResponse<Void> updatePostPeriod(@AuthenticationPrincipal Princ

@Operation(summary = "내가 지원한 팀 리스트 API", description = "현재 지원 중인 상태의 팀 정보 반환")
@GetMapping("/my")
public ApplicationResponse<List<MyPageRes>> getMyApplyList(@AuthenticationPrincipal PrincipalDetails principalDetails) {
return ApplicationResponse.ok(applyService.getMyApplyList(principalDetails.getMember()));
public ApplicationResponse<Page<MyPageRes>> getMyApplyList(@AuthenticationPrincipal PrincipalDetails principalDetails, @PageableDefault(size = 6) Pageable pageable) {
return ApplicationResponse.ok(applyService.getMyApplyList(principalDetails.getMember(), pageable));
}

@Operation(summary = "지원서 열람 API", description = "해당 공고에 대한 사용자의 지원서 정보 반환")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

@Builder
public record ParticipationList(
Long postId,
String title,
String leaderName,
LocalDateTime startDate,
Expand All @@ -17,6 +18,7 @@ public record ParticipationList(
) {
public static ParticipationList of(Post post) {
return ParticipationList.builder()
.postId(post.getPostId())
.title(post.getTitle())
.leaderName(post.getMember().getName())
.startDate(post.getStartDate())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public interface ApplyRepository extends JpaRepository<Apply,Long> {

List<Apply> findApplyByApplyTypeAndMemberAndIsCanceledFalse(ApplyType applyType, Member member);

List<Apply> findAllByMemberAndDeletedAtIsNullOrderByCreatedAtDesc(Member member);
Page<Apply> findAllByMemberAndDeletedAtIsNullOrderByCreatedAtDesc(Member member, Pageable pageable);

Apply findApplyByMemberAndPost(Member member,Post post);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@
import com.gongjakso.server.domain.post.repository.StackNameRepository;
import com.gongjakso.server.global.exception.ApplicationException;
import com.gongjakso.server.global.exception.ErrorCode;
import com.gongjakso.server.global.util.email.EmailClient;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -48,7 +44,7 @@ public class ApplyService {
private final CategoryRepository categoryRepository;
private final StackNameRepository stackNameRepository;
private final ApplyStackRepository applyStackRepository;
private final EmailClient emailClient;
// private final EmailClient emailClient;

@Transactional
public void save(Member member, Long postId, ApplyReq req) {
Expand Down Expand Up @@ -263,15 +259,12 @@ public void updatePostPeriod(Member member,Long postId, PeriodReq req) {
}


public List<MyPageRes> getMyApplyList(Member member) {
public Page<MyPageRes> getMyApplyList(Member member, Pageable pageable) {
// Validation

// Business Logic
List<Apply> applyList = applyRepository.findAllByMemberAndDeletedAtIsNullOrderByCreatedAtDesc(member);


// Response
return applyList.stream()
Page<Apply> applyPage = applyRepository.findAllByMemberAndDeletedAtIsNullOrderByCreatedAtDesc(member, pageable);
List<MyPageRes> applyList = applyPage.stream()
.filter(apply -> apply.getPost().getStatus() == PostStatus.RECRUITING ||
apply.getPost().getStatus() == PostStatus.EXTENSION ||
apply.getPost().getStatus() == PostStatus.CANCEL ||
Expand All @@ -284,7 +277,10 @@ public List<MyPageRes> getMyApplyList(Member member) {

return MyPageRes.of(post, apply, categoryList);
})
.collect(Collectors.toList());
.toList();

// Response
return new PageImpl<>(applyList, pageable, applyPage.getTotalElements());
}

public ApplicationRes getMyApplication(Member member, Long postId){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,9 @@ public PostScrapRes scrapPost(Member member, Long postId) {
post.setScrapCount(post.getScrapCount() + 1);
}
}
postScrapRepository.save(postScrap);
postRepository.save(post);
return PostScrapRes.of(postScrap, post.getScrapCount());
PostScrap savePostScrap = postScrapRepository.save(postScrap);
Post savePost = postRepository.save(post);
return PostScrapRes.of(savePostScrap, savePost.getScrapCount());
}

@Transactional
Expand Down Expand Up @@ -379,7 +379,7 @@ public Page<GetProjectRes> getMyScrapProject(Member member, Pageable page){

Page<PostScrap> scrapPageList = postScrapRepository.findAllByMemberAndPostPostTypeTrueAndPostDeletedAtIsNullAndScrapStatusTrueOrderByPostScrapIdDesc(member, pageable);

List<GetProjectRes> filteredProjects = scrapPageList.stream()
List<GetProjectRes> myScrapProjects = scrapPageList.stream()
.map(scrap -> {
Post post = scrap.getPost();
post.getCategories().size();
Expand All @@ -389,7 +389,7 @@ public Page<GetProjectRes> getMyScrapProject(Member member, Pageable page){
.collect(Collectors.toList()); // 리스트로 수집

// 필터링된 리스트를 페이지로 반환
return new PageImpl<>(filteredProjects, pageable, scrapPageList.getTotalElements());
return new PageImpl<>( myScrapProjects, pageable, myScrapProjects.size());
}

@Transactional
Expand All @@ -398,7 +398,7 @@ public Page<GetContestRes> getMyScrapContest(Member member, Pageable page){

Page<PostScrap> scrapPageList = postScrapRepository.findAllByMemberAndPostPostTypeFalseAndPostDeletedAtIsNullAndScrapStatusTrueOrderByPostScrapIdDesc(member, pageable);

List<GetContestRes> filteredContests = scrapPageList.stream()
List<GetContestRes> myScrapContests = scrapPageList.stream()
.map(scrap -> {
Post post = scrap.getPost();
post.getCategories().size();
Expand All @@ -408,9 +408,10 @@ public Page<GetContestRes> getMyScrapContest(Member member, Pageable page){
.collect(Collectors.toList()); // 리스트로 수집

// 필터링된 리스트를 페이지로 반환
return new PageImpl<>(filteredContests, pageable, scrapPageList.getTotalElements());
return new PageImpl<>(myScrapContests, pageable, myScrapContests.size());
}


@Transactional
public PostSimpleRes completePost(Member member, Long postId) {
// Validation: Post 논리적 삭제 및 사용자의 권한 여부 확인
Expand Down

0 comments on commit 4354a9d

Please sign in to comment.