Skip to content

Commit

Permalink
refactor: 근무 일이 지나지 않은 신청 내역 조회 (대기, 거절, 수락)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgjinsu committed Aug 10, 2024
1 parent d8bfe8e commit d5e8062
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ Optional<Apply> findApplyPerDay(@Param("memberId") Long memberId, @Param("date")
List<Apply> findApplyPerMonth(@Param("memberId") Long memberId, @Param("monthStart") LocalDate monthStart,
@Param("monthEnd") LocalDate monthEnd);

@Query("select a from Apply a join fetch a.workDate w join fetch w.jobPost j where a.member.id = :memberId and a.status = 'PENDING' order by a.createdDate desc")
@Query("select a from Apply a join fetch a.workDate w join fetch w.jobPost j where a.member.id = :memberId and a.status in :statusList order by a.createdDate desc")
List<Apply> findPendingApply(@Param("memberId") Long memberId);

@Query("select a from Apply a join fetch a.workDate w join fetch w.jobPost j where a.member.id = :memberId and w.date >= :now order by a.createdDate desc")
List<Apply> findFutureApply(@Param("memberId") Long memberId, @Param("now") LocalDate now);
@Query("select a from Apply a join fetch a.workDate w join fetch w.jobPost j where a.member.id = :memberId and a.status in :statusList and w.date >= :now order by a.createdDate desc")
List<Apply> findFutureApply(@Param("memberId") Long memberId, @Param("statusList") List<ApplyStatus> statusList,
@Param("now") LocalDate now);


/**
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/jikgong/domain/apply/service/ApplyWorkerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -198,14 +199,22 @@ public List<ApplyHistoryResponse> findPendingApply(Long workerId) {
}

/**
* 근무 일이 지나지 않은 신청 내역 조회 (진행, 대기, 거절 전부)
* 근무 일이 지나지 않은 신청 내역 조회 (대기, 거절, 수락)
* 웹에서 보여주기 위함
*/
@Transactional(readOnly = true)
public List<ApplyHistoryResponse> findApplyFutureHistory(Long workerId) {
Member worker = memberRepository.findById(workerId)
.orElseThrow(() -> new JikgongException(ErrorCode.MEMBER_NOT_FOUND));

return applyRepository.findFutureApply(worker.getId(), LocalDate.now()).stream()
// 조회하고자 하는 상태
List<ApplyStatus> statusList = Arrays.asList(
ApplyStatus.PENDING,
ApplyStatus.REJECTED,
ApplyStatus.ACCEPTED
);

return applyRepository.findFutureApply(worker.getId(), statusList, LocalDate.now()).stream()
.map(ApplyHistoryResponse::from)
.collect(Collectors.toList());
}
Expand Down

0 comments on commit d5e8062

Please sign in to comment.