Skip to content

Commit

Permalink
develop scheduled plan list #4
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingadinga committed Aug 28, 2022
1 parent b7ff110 commit 59ab48a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/team20/t4/member/MemberController.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,6 @@ public OnlyResponseString updateProfileImage(@RequestPart(value = "file") Multip
return new OnlyResponseString("회원 프로필 이미지 수정에 성공했습니다.");
}



}
9 changes: 5 additions & 4 deletions src/main/java/com/team20/t4/plan/PlanController.java
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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();
}
}
14 changes: 14 additions & 0 deletions src/main/java/com/team20/t4/plan/PlanService.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,18 @@ public Long response(Long registerHistoryId, State newState) {
return registerHistoryEntity.getId();
}

@Transactional
public ListAppointmentSimpleResponseDto getScheduledPlan() {
Member loginedMember = memberService.getLoginedMember();
List<AppointmentSimpleResponseDto> 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ public interface RegisterHistoryRepository extends JpaRepository<RegisterHistory
@Query("SELECT h FROM RegisterHistory h where h.applicant = :applicant and h.state = com.team20.t4.plan.domain.State.PERMITTED")
List<RegisterHistory> 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<RegisterHistory> readRegisterHistoriesByPermittedMemberAndOnProcess(@Param("applicant") Member applicant);


}
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
spring.profiles.active=test
spring.profiles.active=dev
spring.jpa.show_sql=true
spring.jpa.properties.hibernate.format_sql=true

0 comments on commit 59ab48a

Please sign in to comment.