11package com .back .web7_9_codecrete_be .domain .plans .controller ;
22
33import com .back .web7_9_codecrete_be .domain .plans .dto .request .PlanAddRequest ;
4+ import com .back .web7_9_codecrete_be .domain .plans .dto .request .PlanParticipantRoleUpdateRequest ;
45import com .back .web7_9_codecrete_be .domain .plans .dto .request .PlanUpdateRequest ;
6+ import com .back .web7_9_codecrete_be .domain .plans .dto .request .ScheduleAddRequest ;
7+ import com .back .web7_9_codecrete_be .domain .plans .dto .request .ScheduleUpdateRequest ;
58import com .back .web7_9_codecrete_be .domain .plans .dto .response .PlanDeleteResponse ;
69import com .back .web7_9_codecrete_be .domain .plans .dto .response .PlanDetailResponse ;
710import com .back .web7_9_codecrete_be .domain .plans .dto .response .PlanListResponse ;
811import com .back .web7_9_codecrete_be .domain .plans .dto .response .PlanResponse ;
12+ import com .back .web7_9_codecrete_be .domain .plans .dto .response .ScheduleResponse ;
13+ import com .back .web7_9_codecrete_be .domain .plans .dto .response .ScheduleListResponse ;
14+ import com .back .web7_9_codecrete_be .domain .plans .dto .response .ScheduleDeleteResponse ;
915import com .back .web7_9_codecrete_be .domain .plans .service .PlanService ;
16+ import com .back .web7_9_codecrete_be .domain .users .entity .User ;
17+ import com .back .web7_9_codecrete_be .global .rq .Rq ;
1018import com .back .web7_9_codecrete_be .global .rsData .RsData ;
1119import io .swagger .v3 .oas .annotations .Operation ;
1220import io .swagger .v3 .oas .annotations .tags .Tag ;
1321import jakarta .validation .Valid ;
1422import lombok .RequiredArgsConstructor ;
15- import org .springframework .http .HttpStatus ;
1623import org .springframework .web .bind .annotation .*;
1724
1825import java .util .List ;
2532public class PlanController {
2633
2734 private final PlanService planService ;
35+ private final Rq rq ;
2836
2937 /**
3038 * 계획 목록 조회
@@ -33,8 +41,9 @@ public class PlanController {
3341 */
3442 @ GetMapping ("/list" )
3543 @ Operation (summary = "계획 목록 조회" , description = "사용자의 계획 목록을 조회합니다." )
36- public RsData <List <PlanListResponse >> getPlanList (@ RequestParam Long userId ) {
37- List <PlanListResponse > planList = planService .getPlanList (userId );
44+ public RsData <List <PlanListResponse >> getPlanList () {
45+ User user = rq .getUser ();
46+ List <PlanListResponse > planList = planService .getPlanList (user );
3847 return RsData .success ("계획 목록 조회 성공" , planList );
3948 }
4049
@@ -46,26 +55,25 @@ public RsData<List<PlanListResponse>> getPlanList(@RequestParam Long userId) {
4655 */
4756 @ GetMapping ("/{planId}" )
4857 @ Operation (summary = "계획 상세 조회" , description = "특정 계획의 상세 정보를 조회합니다." )
49- public RsData <PlanDetailResponse > getPlanDetail (@ PathVariable Long planId ,
50- @ RequestParam Long userId ) {
51- PlanDetailResponse planDetail = planService .getPlanDetail (planId , userId );
58+ public RsData <PlanDetailResponse > getPlanDetail (@ PathVariable Long planId ) {
59+ User user = rq . getUser ();
60+ PlanDetailResponse planDetail = planService .getPlanDetail (planId , user );
5261 return RsData .success ("계획 상세 조회 성공" , planDetail );
5362 }
5463
5564 /**
5665 * 계획 생성
5766 *
58- * @param concertId 콘서트 ID
5967 * @param request 계획 생성 요청 DTO
6068 * @return 생성된 계획 정보 (201 Created)
6169 */
62- @ PostMapping ( "/{concertId}" )
70+ @ PostMapping
6371 @ Operation (summary = "계획 생성" , description = "새로운 계획을 생성합니다." )
6472 public RsData <PlanResponse > createPlan (
65- @ PathVariable Long concertId ,
6673 @ Valid @ RequestBody PlanAddRequest request ) {
67- PlanResponse planResponse = planService .createPlan (concertId , request );
68- return RsData .success (HttpStatus .CREATED , "계획 생성 성공" , planResponse );
74+ User user = rq .getUser ();
75+ PlanResponse planResponse = planService .createPlan (user , request );
76+ return RsData .success ("계획 생성 성공" , planResponse );
6977 }
7078
7179 /**
@@ -80,7 +88,8 @@ public RsData<PlanResponse> createPlan(
8088 public RsData <PlanResponse > updatePlan (
8189 @ PathVariable Long planId ,
8290 @ Valid @ RequestBody PlanUpdateRequest request ) {
83- PlanResponse planResponse = planService .updatePlan (planId , request );
91+ User user = rq .getUser ();
92+ PlanResponse planResponse = planService .updatePlan (planId , user , request );
8493 return RsData .success ("계획 수정 성공" , planResponse );
8594 }
8695
@@ -92,12 +101,118 @@ public RsData<PlanResponse> updatePlan(
92101 */
93102 @ DeleteMapping ("/delete/{planId}" )
94103 @ Operation (summary = "계획 삭제" , description = "기존 계획을 삭제합니다." )
95- public RsData <PlanDeleteResponse > deletePlan (@ PathVariable Long planId ) {
96- PlanDeleteResponse deleteResponse = planService .deletePlan (planId );
104+ public RsData <PlanDeleteResponse > deletePlan (
105+ @ PathVariable Long planId ) {
106+ User user = rq .getUser ();
107+ PlanDeleteResponse deleteResponse = planService .deletePlan (planId , user );
97108 return RsData .success ("계획 삭제 성공" , deleteResponse );
98109 }
99110
100111
112+ /**
113+ * 일정 추가
114+ *
115+ * @param planId 계획 ID
116+ * @param request 일정 추가 요청 DTO
117+ * @return 생성된 일정 정보 (201 Created)
118+ */
119+ @ PostMapping ("/{planId}/schedules" )
120+ @ Operation (summary = "일정 추가" , description = "계획에 새로운 일정을 추가합니다." )
121+ public RsData <ScheduleResponse > addSchedule (
122+ @ PathVariable Long planId ,
123+ @ Valid @ RequestBody ScheduleAddRequest request ) {
124+ User user = rq .getUser ();
125+ ScheduleResponse response = planService .addSchedule (planId , user , request );
126+ return RsData .success ("일정 추가 성공" , response );
127+ }
128+
129+ /**
130+ * 일정 목록 조회 (타임라인)
131+ *
132+ * @param planId 계획 ID
133+ * @return 일정 목록 (200 OK)
134+ */
135+ @ GetMapping ("/{planId}/schedules" )
136+ @ Operation (summary = "일정 목록 조회" , description = "계획의 일정 목록을 타임라인 형태로 조회합니다." )
137+ public RsData <ScheduleListResponse > getSchedules (
138+ @ PathVariable Long planId ) {
139+ User user = rq .getUser ();
140+ ScheduleListResponse response = planService .getSchedules (planId , user );
141+ return RsData .success ("일정 목록 조회 성공" , response );
142+ }
143+
144+ /**
145+ * 일정 상세 조회
146+ *
147+ * @param planId 계획 ID
148+ * @param scheduleId 일정 ID
149+ * @return 일정 상세 정보 (200 OK)
150+ */
151+ @ GetMapping ("/{planId}/schedules/{scheduleId}" )
152+ @ Operation (summary = "일정 상세 조회" , description = "특정 일정의 상세 정보를 조회합니다." )
153+ public RsData <ScheduleResponse > getSchedule (
154+ @ PathVariable Long planId ,
155+ @ PathVariable Long scheduleId ) {
156+ User user = rq .getUser ();
157+ ScheduleResponse response = planService .getSchedule (planId , scheduleId , user );
158+ return RsData .success ("일정 상세 조회 성공" , response );
159+ }
160+
161+ /**
162+ * 일정 수정
163+ *
164+ * @param planId 계획 ID
165+ * @param scheduleId 일정 ID
166+ * @param request 일정 수정 요청 DTO
167+ * @return 수정된 일정 정보 (200 OK)
168+ */
169+ @ PatchMapping ("/{planId}/schedules/{scheduleId}" )
170+ @ Operation (summary = "일정 수정" , description = "기존 일정의 정보를 수정합니다." )
171+ public RsData <ScheduleResponse > updateSchedule (
172+ @ PathVariable Long planId ,
173+ @ PathVariable Long scheduleId ,
174+ @ Valid @ RequestBody ScheduleUpdateRequest request ) {
175+ User user = rq .getUser ();
176+ ScheduleResponse response = planService .updateSchedule (planId , scheduleId , user , request );
177+ return RsData .success ("일정 수정 성공" , response );
178+ }
179+
180+ /**
181+ * 일정 삭제
182+ *
183+ * @param planId 계획 ID
184+ * @param scheduleId 일정 ID
185+ * @return 삭제된 일정 ID (200 OK)
186+ */
187+ @ DeleteMapping ("/{planId}/schedules/{scheduleId}" )
188+ @ Operation (summary = "일정 삭제" , description = "기존 일정을 삭제합니다." )
189+ public RsData <ScheduleDeleteResponse > deleteSchedule (
190+ @ PathVariable Long planId ,
191+ @ PathVariable Long scheduleId ) {
192+ User user = rq .getUser ();
193+ ScheduleDeleteResponse response = planService .deleteSchedule (planId , scheduleId , user );
194+ return RsData .success ("일정 삭제 성공" , response );
195+ }
196+
197+ /**
198+ * 참가자 역할 수정
199+ *
200+ * @param planId 계획 ID
201+ * @param participantId 참가자 ID
202+ * @param request 역할 수정 요청 DTO
203+ * @return 성공 메시지 (200 OK)
204+ */
205+ @ PatchMapping ("/{planId}/participants/{participantId}/role" )
206+ @ Operation (summary = "참가자 역할 수정" , description = "참가자의 역할을 수정합니다. (Owner, Editor, Viewer)" )
207+ public RsData <Void > updateParticipantRole (
208+ @ PathVariable Long planId ,
209+ @ PathVariable Long participantId ,
210+ @ Valid @ RequestBody PlanParticipantRoleUpdateRequest request ) {
211+ User user = rq .getUser ();
212+ planService .updateParticipantRole (planId , participantId , user , request );
213+ return RsData .success ("참가자 역할 수정 성공" , null );
214+ }
215+
101216 // POST /api/v1/plans/invite/{planID} - 계획 공유 초대
102217 // POST /api/v1/plans/accept/{planID} - 계획 공유 수락
103218 // POST /api/v1/plans/deny/{planID} - 계획 공유 거절
0 commit comments