Skip to content

Commit

Permalink
[FIX]액션 플랜 정렬 순서 최신순으로 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Hong0329 committed Feb 29, 2024
1 parent 2af23c5 commit ce50385
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@

public interface ActionPlanRepository extends JpaRepository<ActionPlan,Long> {

List<ActionPlan> findAllBySeedCaveMemberIdAndIsFinished(Long memberId, Boolean isFinished);
List<ActionPlan> findAllBySeedCaveMemberIdAndIsFinishedOrderByCreatedAtDesc(Long memberId, Boolean isFinished);

@Query("SELECT ap FROM ActionPlan ap JOIN ap.seed s JOIN s.cave c JOIN c.member m WHERE m.id = :memberId")
List<ActionPlan> findAllByMemberId(Long memberId);
List<ActionPlan> findAllByMemberIdOrderByCreatedAtDesc(Long memberId);
List<ActionPlan> findAllBySeedIdOrderByCreatedAtDesc(Long seedId);

List<ActionPlan> findAllBySeedId(Long seedId);

List<ActionPlan> findAllByMemberId(Long memberId);

Optional<ActionPlan> findActionPlanById(Long actionPlanId);

default ActionPlan findActionPlanByIdOrThrow(Long actionPlanId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void createActionPlan(Long seedId, ActionPlanCreateRequestDto actionPlanC

@Override
public List<ActionPlanGetResponseDto> getActionPlan(Long seedId) {
List<ActionPlan> actionPlans = actionPlanRepository.findAllBySeedId(seedId);
List<ActionPlan> actionPlans = actionPlanRepository.findAllBySeedIdOrderByCreatedAtDesc(seedId);

return actionPlans.stream()
.map(actionPlan -> ActionPlanGetResponseDto.of(actionPlan.getId(), actionPlan.getContent(), actionPlan.getIsScraped(), actionPlan.getIsFinished(),reviewRepository.existsByActionPlan(actionPlan)))
Expand Down Expand Up @@ -97,7 +97,7 @@ public int getActionPlanPercent(Long memberId) {

@Override
public List<DoingActionPlanGetResponseDto> getDoingActionPlan(Long memberId) {
List<ActionPlan> doingActionPlans = actionPlanRepository.findAllBySeedCaveMemberIdAndIsFinished(memberId,false);
List<ActionPlan> doingActionPlans = actionPlanRepository.findAllBySeedCaveMemberIdAndIsFinishedOrderByCreatedAtDesc(memberId,false);

return doingActionPlans.stream()
.map(actionPlan -> DoingActionPlanGetResponseDto.of(actionPlan.getId(), actionPlan.getContent(), actionPlan.getIsScraped(),actionPlan.getSeed().getId(),reviewRepository.existsByActionPlan(actionPlan)))
Expand All @@ -106,7 +106,7 @@ public List<DoingActionPlanGetResponseDto> getDoingActionPlan(Long memberId) {

@Override
public List<FinishedActionPlanGetResponseDto> getFinishedActionPlan(Long memberId) {
List<ActionPlan> finishedActionPlans = actionPlanRepository.findAllBySeedCaveMemberIdAndIsFinished(memberId,true);
List<ActionPlan> finishedActionPlans = actionPlanRepository.findAllBySeedCaveMemberIdAndIsFinishedOrderByCreatedAtDesc(memberId,true);

return finishedActionPlans.stream()
.map(actionPlan -> FinishedActionPlanGetResponseDto.of(actionPlan.getId(), actionPlan.getContent(), actionPlan.getIsScraped(),actionPlan.getSeed().getId(),reviewRepository.existsByActionPlan(actionPlan)))
Expand Down

0 comments on commit ce50385

Please sign in to comment.