Skip to content

Commit 971a8f0

Browse files
committed
feat: Plan & Schedule CRUD 작업
1 parent e4b948b commit 971a8f0

2 files changed

Lines changed: 623 additions & 72 deletions

File tree

src/main/java/com/back/web7_9_codecrete_be/domain/plans/controller/PlanController.java

Lines changed: 128 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
package com.back.web7_9_codecrete_be.domain.plans.controller;
22

33
import com.back.web7_9_codecrete_be.domain.plans.dto.request.PlanAddRequest;
4+
import com.back.web7_9_codecrete_be.domain.plans.dto.request.PlanParticipantRoleUpdateRequest;
45
import 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;
58
import com.back.web7_9_codecrete_be.domain.plans.dto.response.PlanDeleteResponse;
69
import com.back.web7_9_codecrete_be.domain.plans.dto.response.PlanDetailResponse;
710
import com.back.web7_9_codecrete_be.domain.plans.dto.response.PlanListResponse;
811
import 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;
915
import 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;
1018
import com.back.web7_9_codecrete_be.global.rsData.RsData;
1119
import io.swagger.v3.oas.annotations.Operation;
1220
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -25,6 +33,7 @@
2533
public class PlanController {
2634

2735
private final PlanService planService;
36+
private final Rq rq;
2837

2938
/**
3039
* 계획 목록 조회
@@ -33,8 +42,9 @@ public class PlanController {
3342
*/
3443
@GetMapping("/list")
3544
@Operation(summary = "계획 목록 조회", description = "사용자의 계획 목록을 조회합니다.")
36-
public RsData<List<PlanListResponse>> getPlanList(@RequestParam Long userId) {
37-
List<PlanListResponse> planList = planService.getPlanList(userId);
45+
public RsData<List<PlanListResponse>> getPlanList() {
46+
User user = rq.getUser();
47+
List<PlanListResponse> planList = planService.getPlanList(user);
3848
return RsData.success("계획 목록 조회 성공", planList);
3949
}
4050

@@ -46,25 +56,24 @@ public RsData<List<PlanListResponse>> getPlanList(@RequestParam Long userId) {
4656
*/
4757
@GetMapping("/{planId}")
4858
@Operation(summary = "계획 상세 조회", description = "특정 계획의 상세 정보를 조회합니다.")
49-
public RsData<PlanDetailResponse> getPlanDetail(@PathVariable Long planId,
50-
@RequestParam Long userId) {
51-
PlanDetailResponse planDetail = planService.getPlanDetail(planId, userId);
59+
public RsData<PlanDetailResponse> getPlanDetail(@PathVariable Long planId) {
60+
User user = rq.getUser();
61+
PlanDetailResponse planDetail = planService.getPlanDetail(planId, user);
5262
return RsData.success("계획 상세 조회 성공", planDetail);
5363
}
5464

5565
/**
5666
* 계획 생성
5767
*
58-
* @param concertId 콘서트 ID
5968
* @param request 계획 생성 요청 DTO
6069
* @return 생성된 계획 정보 (201 Created)
6170
*/
62-
@PostMapping("/{concertId}")
71+
@PostMapping
6372
@Operation(summary = "계획 생성", description = "새로운 계획을 생성합니다.")
6473
public RsData<PlanResponse> createPlan(
65-
@PathVariable Long concertId,
6674
@Valid @RequestBody PlanAddRequest request) {
67-
PlanResponse planResponse = planService.createPlan(concertId, request);
75+
User user = rq.getUser();
76+
PlanResponse planResponse = planService.createPlan(user, request);
6877
return RsData.success(HttpStatus.CREATED, "계획 생성 성공", planResponse);
6978
}
7079

@@ -80,7 +89,8 @@ public RsData<PlanResponse> createPlan(
8089
public RsData<PlanResponse> updatePlan(
8190
@PathVariable Long planId,
8291
@Valid @RequestBody PlanUpdateRequest request) {
83-
PlanResponse planResponse = planService.updatePlan(planId, request);
92+
User user = rq.getUser();
93+
PlanResponse planResponse = planService.updatePlan(planId, user, request);
8494
return RsData.success("계획 수정 성공", planResponse);
8595
}
8696

@@ -92,12 +102,118 @@ public RsData<PlanResponse> updatePlan(
92102
*/
93103
@DeleteMapping("/delete/{planId}")
94104
@Operation(summary = "계획 삭제", description = "기존 계획을 삭제합니다.")
95-
public RsData<PlanDeleteResponse> deletePlan(@PathVariable Long planId) {
96-
PlanDeleteResponse deleteResponse = planService.deletePlan(planId);
105+
public RsData<PlanDeleteResponse> deletePlan(
106+
@PathVariable Long planId) {
107+
User user = rq.getUser();
108+
PlanDeleteResponse deleteResponse = planService.deletePlan(planId, user);
97109
return RsData.success("계획 삭제 성공", deleteResponse);
98110
}
99111

100112

113+
/**
114+
* 일정 추가
115+
*
116+
* @param planId 계획 ID
117+
* @param request 일정 추가 요청 DTO
118+
* @return 생성된 일정 정보 (201 Created)
119+
*/
120+
@PostMapping("/{planId}/schedules")
121+
@Operation(summary = "일정 추가", description = "계획에 새로운 일정을 추가합니다.")
122+
public RsData<ScheduleResponse> addSchedule(
123+
@PathVariable Long planId,
124+
@Valid @RequestBody ScheduleAddRequest request) {
125+
User user = rq.getUser();
126+
ScheduleResponse response = planService.addSchedule(planId, user, request);
127+
return RsData.success(HttpStatus.CREATED, "일정 추가 성공", response);
128+
}
129+
130+
/**
131+
* 일정 목록 조회 (타임라인)
132+
*
133+
* @param planId 계획 ID
134+
* @return 일정 목록 (200 OK)
135+
*/
136+
@GetMapping("/{planId}/schedules")
137+
@Operation(summary = "일정 목록 조회", description = "계획의 일정 목록을 타임라인 형태로 조회합니다.")
138+
public RsData<ScheduleListResponse> getSchedules(
139+
@PathVariable Long planId) {
140+
User user = rq.getUser();
141+
ScheduleListResponse response = planService.getSchedules(planId, user);
142+
return RsData.success("일정 목록 조회 성공", response);
143+
}
144+
145+
/**
146+
* 일정 상세 조회
147+
*
148+
* @param planId 계획 ID
149+
* @param scheduleId 일정 ID
150+
* @return 일정 상세 정보 (200 OK)
151+
*/
152+
@GetMapping("/{planId}/schedules/{scheduleId}")
153+
@Operation(summary = "일정 상세 조회", description = "특정 일정의 상세 정보를 조회합니다.")
154+
public RsData<ScheduleResponse> getSchedule(
155+
@PathVariable Long planId,
156+
@PathVariable Long scheduleId) {
157+
User user = rq.getUser();
158+
ScheduleResponse response = planService.getSchedule(planId, scheduleId, user);
159+
return RsData.success("일정 상세 조회 성공", response);
160+
}
161+
162+
/**
163+
* 일정 수정
164+
*
165+
* @param planId 계획 ID
166+
* @param scheduleId 일정 ID
167+
* @param request 일정 수정 요청 DTO
168+
* @return 수정된 일정 정보 (200 OK)
169+
*/
170+
@PatchMapping("/{planId}/schedules/{scheduleId}")
171+
@Operation(summary = "일정 수정", description = "기존 일정의 정보를 수정합니다.")
172+
public RsData<ScheduleResponse> updateSchedule(
173+
@PathVariable Long planId,
174+
@PathVariable Long scheduleId,
175+
@Valid @RequestBody ScheduleUpdateRequest request) {
176+
User user = rq.getUser();
177+
ScheduleResponse response = planService.updateSchedule(planId, scheduleId, user, request);
178+
return RsData.success("일정 수정 성공", response);
179+
}
180+
181+
/**
182+
* 일정 삭제
183+
*
184+
* @param planId 계획 ID
185+
* @param scheduleId 일정 ID
186+
* @return 삭제된 일정 ID (200 OK)
187+
*/
188+
@DeleteMapping("/{planId}/schedules/{scheduleId}")
189+
@Operation(summary = "일정 삭제", description = "기존 일정을 삭제합니다.")
190+
public RsData<ScheduleDeleteResponse> deleteSchedule(
191+
@PathVariable Long planId,
192+
@PathVariable Long scheduleId) {
193+
User user = rq.getUser();
194+
ScheduleDeleteResponse response = planService.deleteSchedule(planId, scheduleId, user);
195+
return RsData.success("일정 삭제 성공", response);
196+
}
197+
198+
/**
199+
* 참가자 역할 수정
200+
*
201+
* @param planId 계획 ID
202+
* @param participantId 참가자 ID
203+
* @param request 역할 수정 요청 DTO
204+
* @return 성공 메시지 (200 OK)
205+
*/
206+
@PatchMapping("/{planId}/participants/{participantId}/role")
207+
@Operation(summary = "참가자 역할 수정", description = "참가자의 역할을 수정합니다. (Owner, Editor, Viewer)")
208+
public RsData<Void> updateParticipantRole(
209+
@PathVariable Long planId,
210+
@PathVariable Long participantId,
211+
@Valid @RequestBody PlanParticipantRoleUpdateRequest request) {
212+
User user = rq.getUser();
213+
planService.updateParticipantRole(planId, participantId, user, request);
214+
return RsData.success("참가자 역할 수정 성공", null);
215+
}
216+
101217
// POST /api/v1/plans/invite/{planID} - 계획 공유 초대
102218
// POST /api/v1/plans/accept/{planID} - 계획 공유 수락
103219
// POST /api/v1/plans/deny/{planID} - 계획 공유 거절

0 commit comments

Comments
 (0)