Skip to content

Commit

Permalink
Merge pull request #154 from Gongjakso/refactor/qa
Browse files Browse the repository at this point in the history
fix: QA 사항 업데이트
  • Loading branch information
dl-00-e8 authored May 20, 2024
2 parents 5d97690 + a6bd007 commit 1138f3e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
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.*;

Expand All @@ -30,19 +33,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 +105,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,9 @@
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 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 +45,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 +260,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 +278,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

0 comments on commit 1138f3e

Please sign in to comment.