Skip to content

Commit beb3cab

Browse files
Merge pull request #76 from prgrms-web-devcourse-final-project/feat/#44
[Plan] CRUD를 위한 전체적인 구조 추가 및 변경
2 parents f25337a + 878a9b5 commit beb3cab

24 files changed

Lines changed: 1220 additions & 220 deletions

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

Lines changed: 129 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
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;
1321
import jakarta.validation.Valid;
1422
import lombok.RequiredArgsConstructor;
15-
import org.springframework.http.HttpStatus;
1623
import org.springframework.web.bind.annotation.*;
1724

1825
import java.util.List;
@@ -25,6 +32,7 @@
2532
public 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} - 계획 공유 거절
Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
package com.back.web7_9_codecrete_be.domain.plans.dto.request;
22

3+
import jakarta.validation.constraints.FutureOrPresent;
34
import jakarta.validation.constraints.NotBlank;
5+
import jakarta.validation.constraints.NotNull;
46
import jakarta.validation.constraints.Size;
57
import lombok.Getter;
68
import lombok.NoArgsConstructor;
79

10+
import java.time.LocalDate;
11+
812

913
@Getter
1014
@NoArgsConstructor
1115
public class PlanAddRequest {
16+
@NotNull(message = "콘서트 ID는 필수입니다.")
17+
private Long concertId;
18+
1219
@NotBlank(message = "제목은 필수입니다.")
13-
@Size(max = 30, message = "제목은 30자 이하여야 합니다.")
20+
@Size(max = 100, message = "제목은 100자 이하여야 합니다.")
1421
private String title;
1522

16-
@NotBlank(message = "날짜는 필수입니다.")
17-
@Size(max = 30, message = "날짜는 30자 이하여야 합니다.")
18-
private String date;
23+
@NotNull(message = "날짜는 필수입니다.")
24+
@FutureOrPresent(message = "날짜는 현재 또는 미래 날짜여야 합니다.")
25+
private LocalDate planDate;
1926
}

src/main/java/com/back/web7_9_codecrete_be/domain/plans/dto/request/PlanKickParticipantRequest.java renamed to src/main/java/com/back/web7_9_codecrete_be/domain/plans/dto/request/PlanParticipantInviteRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@Getter
99
@NoArgsConstructor
10-
public class PlanKickParticipantRequest {
10+
public class PlanParticipantInviteRequest {
1111
@NotNull(message = "사용자 ID는 필수입니다.")
1212
private Long userId;
13-
}
13+
}

src/main/java/com/back/web7_9_codecrete_be/domain/plans/dto/request/PlanInviteRequest.java renamed to src/main/java/com/back/web7_9_codecrete_be/domain/plans/dto/request/PlanParticipantKickRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@Getter
99
@NoArgsConstructor
10-
public class PlanInviteRequest {
10+
public class PlanParticipantKickRequest {
1111
@NotNull(message = "사용자 ID는 필수입니다.")
1212
private Long userId;
13-
}
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.back.web7_9_codecrete_be.domain.plans.dto.request;
2+
3+
import com.back.web7_9_codecrete_be.domain.plans.entity.PlanParticipant;
4+
import jakarta.validation.constraints.NotNull;
5+
import lombok.Getter;
6+
import lombok.NoArgsConstructor;
7+
8+
@Getter
9+
@NoArgsConstructor
10+
public class PlanParticipantRoleUpdateRequest {
11+
12+
@NotNull(message = "역할은 필수입니다.")
13+
private PlanParticipant.ParticipantRole role;
14+
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
package com.back.web7_9_codecrete_be.domain.plans.dto.request;
22

3-
import jakarta.validation.constraints.NotBlank;
3+
import jakarta.validation.constraints.FutureOrPresent;
44
import jakarta.validation.constraints.Size;
55
import lombok.Getter;
66
import lombok.NoArgsConstructor;
77

8+
import java.time.LocalDate;
9+
810

911
@Getter
1012
@NoArgsConstructor
1113
public class PlanUpdateRequest {
12-
@NotBlank(message = "제목은 필수입니다.")
13-
@Size(max = 30, message = "제목은 30자 이하여야 합니다.")
14+
@Size(max = 100, message = "제목은 100자 이하여야 합니다.")
1415
private String title;
1516

16-
@NotBlank(message = "날짜는 필수입니다.")
17-
@Size(max = 30, message = "날짜는 30자 이하여야 합니다.")
18-
private String date;
17+
@FutureOrPresent(message = "날짜는 현재 또는 미래 날짜여야 합니다.")
18+
private LocalDate planDate;
1919
}

0 commit comments

Comments
 (0)