diff --git a/src/main/java/com/team20/t4/member/MemberController.java b/src/main/java/com/team20/t4/member/MemberController.java index 9b8ca34..7f66d71 100644 --- a/src/main/java/com/team20/t4/member/MemberController.java +++ b/src/main/java/com/team20/t4/member/MemberController.java @@ -62,4 +62,6 @@ public OnlyResponseString updateProfileImage(@RequestPart(value = "file") Multip return new OnlyResponseString("회원 프로필 이미지 수정에 성공했습니다."); } + + } diff --git a/src/main/java/com/team20/t4/plan/PlanController.java b/src/main/java/com/team20/t4/plan/PlanController.java index 4b9ecec..e92a827 100644 --- a/src/main/java/com/team20/t4/plan/PlanController.java +++ b/src/main/java/com/team20/t4/plan/PlanController.java @@ -1,13 +1,9 @@ package com.team20.t4.plan; -import com.team20.t4.plan.domain.Progress; -import com.team20.t4.plan.domain.State; import com.team20.t4.plan.dto.*; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; -import java.util.List; - @RequiredArgsConstructor @RestController public class PlanController { @@ -45,4 +41,9 @@ public Long sendAppointmentRequest(@RequestBody RegisterHistorySaveRequestDto dt public Long updateState(@PathVariable Long registerHistoryId, @RequestBody UpdateStateDto state) { return planService.response(registerHistoryId, state.getState()); } + + @GetMapping("/member/plan/scheduled") + public ListAppointmentSimpleResponseDto getScheduledPlan(){ + return planService.getScheduledPlan(); + } } diff --git a/src/main/java/com/team20/t4/plan/PlanService.java b/src/main/java/com/team20/t4/plan/PlanService.java index 0eef0a8..4c7772a 100644 --- a/src/main/java/com/team20/t4/plan/PlanService.java +++ b/src/main/java/com/team20/t4/plan/PlanService.java @@ -138,4 +138,18 @@ public Long response(Long registerHistoryId, State newState) { return registerHistoryEntity.getId(); } + @Transactional + public ListAppointmentSimpleResponseDto getScheduledPlan() { + Member loginedMember = memberService.getLoginedMember(); + List list = new ArrayList<>(); + + for (RegisterHistory registerHistory : registerHistoryRepository.readRegisterHistoriesByPermittedMemberAndOnProcess(loginedMember)) { + Plan plan = registerHistory.getPlan(); + Post post = plan.getPost(); + AppointmentSimpleResponseDto simpleResponseDto = new AppointmentSimpleResponseDto(post, plan); + list.add(simpleResponseDto); + } + ListAppointmentSimpleResponseDto responseDto = new ListAppointmentSimpleResponseDto(list); + return responseDto; + } } diff --git a/src/main/java/com/team20/t4/plan/domain/RegisterHistoryRepository.java b/src/main/java/com/team20/t4/plan/domain/RegisterHistoryRepository.java index c973dd0..6d47534 100644 --- a/src/main/java/com/team20/t4/plan/domain/RegisterHistoryRepository.java +++ b/src/main/java/com/team20/t4/plan/domain/RegisterHistoryRepository.java @@ -14,4 +14,9 @@ public interface RegisterHistoryRepository extends JpaRepository readRegisterHistoriesByPermittedMember(@Param("applicant") Member applicant); + // Plan.progress != COMPLETED_PLAN 이고 State.PERMITTED인 회원의 RegisterHistory + @Query("SELECT h FROM RegisterHistory h where h.applicant = :applicant and h.state = com.team20.t4.plan.domain.State.PERMITTED and h.plan.progress != com.team20.t4.plan.domain.Progress.COMPLETED_PLAN") + List readRegisterHistoriesByPermittedMemberAndOnProcess(@Param("applicant") Member applicant); + + } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index ca3fc85..2e45867 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,3 +1,3 @@ -spring.profiles.active=test +spring.profiles.active=dev spring.jpa.show_sql=true spring.jpa.properties.hibernate.format_sql=true \ No newline at end of file