Skip to content

Commit e416e3c

Browse files
authored
Merge pull request #45 from prgrms-web-devcourse-final-project/feature/EA3-77-study-api
[EA3-77] refactor: 스터디 컨트롤러 분리 및 반환값 수정
2 parents d88fdd0 + f5904a1 commit e416e3c

File tree

8 files changed

+104
-55
lines changed

8 files changed

+104
-55
lines changed
Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package grep.neogul_coder.domain.study.controller;
22

3-
import grep.neogul_coder.domain.study.controller.dto.request.DelegateLeaderRequest;
4-
import grep.neogul_coder.domain.study.controller.dto.request.ExtendStudyRequest;
53
import grep.neogul_coder.domain.study.controller.dto.request.StudyCreateRequest;
64
import grep.neogul_coder.domain.study.controller.dto.request.StudyEditRequest;
75
import grep.neogul_coder.domain.study.controller.dto.response.*;
86
import grep.neogul_coder.global.response.ApiResponse;
7+
import jakarta.validation.Valid;
98
import org.springframework.web.bind.annotation.*;
109

1110
import java.util.List;
@@ -15,8 +14,8 @@
1514
public class StudyController implements StudySpecification {
1615

1716
@GetMapping
18-
public ApiResponse<List<StudyListResponse>> getStudyList() {
19-
return ApiResponse.success(List.of(new StudyListResponse()));
17+
public ApiResponse<List<StudyItemResponse>> getStudies() {
18+
return ApiResponse.success(List.of(new StudyItemResponse()));
2019
}
2120

2221
@GetMapping("/{studyId}/header")
@@ -29,6 +28,11 @@ public ApiResponse<StudyResponse> getStudy(@PathVariable("studyId") Long studyId
2928
return ApiResponse.success(new StudyResponse());
3029
}
3130

31+
@GetMapping("/me/images")
32+
public ApiResponse<List<StudyImageResponse>> getStudyImages() {
33+
return ApiResponse.success(List.of(new StudyImageResponse()));
34+
}
35+
3236
@GetMapping("/{studyId}/info")
3337
public ApiResponse<StudyInfoResponse> getStudyInfo(@PathVariable("studyId") Long studyId) {
3438
return ApiResponse.success(new StudyInfoResponse());
@@ -40,46 +44,18 @@ public ApiResponse<StudyMyInfoResponse> getStudyMyInfo(@PathVariable("studyId")
4044
}
4145

4246
@PostMapping
43-
public ApiResponse<Void> createStudy(@RequestBody StudyCreateRequest request) {
47+
public ApiResponse<Void> createStudy(@RequestBody @Valid StudyCreateRequest request) {
4448
return ApiResponse.noContent();
4549
}
4650

4751
@PutMapping("/{studyId}")
4852
public ApiResponse<Void> editStudy(@PathVariable("studyId") Long studyId,
49-
@RequestBody StudyEditRequest request) {
50-
return ApiResponse.noContent("스터디가 수정되었습니다.");
53+
@RequestBody @Valid StudyEditRequest request) {
54+
return ApiResponse.noContent();
5155
}
5256

5357
@DeleteMapping("/{studyId}")
5458
public ApiResponse<Void> deleteStudy(@PathVariable("studyId") Long studyId) {
55-
return ApiResponse.noContent("스터디가 삭제되었습니다.");
56-
}
57-
58-
@DeleteMapping("/{studyId}/me")
59-
public ApiResponse<Void> leaveStudy(@PathVariable("studyId") Long studyId) {
60-
return ApiResponse.noContent("스터디에서 탈퇴되었습니다.");
61-
}
62-
63-
@DeleteMapping("/{studyId}/users/{userId}")
64-
public ApiResponse<Void> deleteMember(@PathVariable("studyId") Long studyId,
65-
@PathVariable("userId") Long userId) {
66-
return ApiResponse.noContent("해당 스터디원이 강퇴되었습니다.");
67-
}
68-
69-
@PostMapping("/{studyId}/delegate")
70-
public ApiResponse<Void> delegateLeader(@PathVariable("studyId") Long studyId,
71-
@RequestBody DelegateLeaderRequest request) {
72-
return ApiResponse.noContent("스터디장이 위임되었습니다.");
73-
}
74-
75-
@PostMapping("/{studyId}/extend")
76-
public ApiResponse<Void> extendStudy(@PathVariable("studyId") Long studyId,
77-
@RequestBody ExtendStudyRequest request) {
78-
return ApiResponse.noContent("스터디가 연장되었습니다.");
79-
}
80-
81-
@PostMapping("/{studyId}/join")
82-
public ApiResponse<Void> joinExtendStudy(@PathVariable("studyId") Long studyId) {
83-
return ApiResponse.noContent("연장된 스터디에 참여하였습니다.");
59+
return ApiResponse.noContent();
8460
}
8561
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package grep.neogul_coder.domain.study.controller;
2+
3+
import grep.neogul_coder.domain.study.controller.dto.request.DelegateLeaderRequest;
4+
import grep.neogul_coder.domain.study.controller.dto.request.ExtendStudyRequest;
5+
import grep.neogul_coder.global.response.ApiResponse;
6+
import jakarta.validation.Valid;
7+
import org.springframework.web.bind.annotation.*;
8+
9+
@RestController
10+
public class StudyManagementController implements StudyManagementSpecification {
11+
12+
@DeleteMapping("/{studyId}/me")
13+
public ApiResponse<Void> leaveStudy(@PathVariable("studyId") Long studyId) {
14+
return ApiResponse.noContent();
15+
}
16+
17+
@DeleteMapping("/{studyId}/users/{userId}")
18+
public ApiResponse<Void> deleteMember(@PathVariable("studyId") Long studyId,
19+
@PathVariable("userId") Long userId) {
20+
return ApiResponse.noContent();
21+
}
22+
23+
@PostMapping("/{studyId}/delegate")
24+
public ApiResponse<Void> delegateLeader(@PathVariable("studyId") Long studyId,
25+
@RequestBody DelegateLeaderRequest request) {
26+
return ApiResponse.noContent();
27+
}
28+
29+
@PostMapping("/{studyId}/extend")
30+
public ApiResponse<Void> extendStudy(@PathVariable("studyId") Long studyId,
31+
@RequestBody @Valid ExtendStudyRequest request) {
32+
return ApiResponse.noContent();
33+
}
34+
35+
@PostMapping("/{studyId}/join")
36+
public ApiResponse<Void> joinExtendStudy(@PathVariable("studyId") Long studyId) {
37+
return ApiResponse.noContent();
38+
}
39+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package grep.neogul_coder.domain.study.controller;
2+
3+
import grep.neogul_coder.domain.study.controller.dto.request.DelegateLeaderRequest;
4+
import grep.neogul_coder.domain.study.controller.dto.request.ExtendStudyRequest;
5+
import grep.neogul_coder.global.response.ApiResponse;
6+
import io.swagger.v3.oas.annotations.Operation;
7+
import io.swagger.v3.oas.annotations.tags.Tag;
8+
9+
@Tag(name = "StudyManagement", description = "스터디 관리 API")
10+
public interface StudyManagementSpecification {
11+
12+
@Operation(summary = "스터디 탈퇴", description = "스터디를 탈퇴합니다.")
13+
ApiResponse<Void> leaveStudy(Long studyId);
14+
15+
@Operation(summary = "스터디원 강퇴", description = "스터디원을 강퇴합니다.")
16+
ApiResponse<Void> deleteMember(Long studyId, Long userId);
17+
18+
@Operation(summary = "스터디장 위임", description = "스터디원에게 스터디장을 위임합니다.")
19+
ApiResponse<Void> delegateLeader(Long studyId, DelegateLeaderRequest request);
20+
21+
@Operation(summary = "스터디 연장", description = "스터디장이 스터디를 연장합니다.")
22+
ApiResponse<Void> extendStudy(Long studyId, ExtendStudyRequest request);
23+
24+
@Operation(summary = "연장 스터디 참여", description = "스터디원이 연장된 스터디에 참여합니다.")
25+
ApiResponse<Void> joinExtendStudy(Long studyId);
26+
}
Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package grep.neogul_coder.domain.study.controller;
22

3-
import grep.neogul_coder.domain.study.controller.dto.request.DelegateLeaderRequest;
4-
import grep.neogul_coder.domain.study.controller.dto.request.ExtendStudyRequest;
53
import grep.neogul_coder.domain.study.controller.dto.request.StudyCreateRequest;
64
import grep.neogul_coder.domain.study.controller.dto.request.StudyEditRequest;
75
import grep.neogul_coder.domain.study.controller.dto.response.*;
@@ -15,14 +13,17 @@
1513
public interface StudySpecification {
1614

1715
@Operation(summary = "스터디 목록 조회", description = "가입한 스터디 목록을 조회합니다.")
18-
ApiResponse<List<StudyListResponse>> getStudyList();
16+
ApiResponse<List<StudyItemResponse>> getStudies();
1917

2018
@Operation(summary = "스터디 헤더 조회", description = "스터디 헤더 정보를 조회합니다.")
2119
ApiResponse<StudyHeaderResponse> getStudyHeader(Long studyId);
2220

2321
@Operation(summary = "스터디 조회", description = "스터디를 조회합니다.")
2422
ApiResponse<StudyResponse> getStudy(Long studyId);
2523

24+
@Operation(summary = "스터디 대표 이미지 조회", description = "참여중인 스터디의 대표 이미지 목록을 조회합니다.")
25+
ApiResponse<List<StudyImageResponse>> getStudyImages();
26+
2627
@Operation(summary = "스터디 정보 조회", description = "스터디장이 스터디 정보를 조회합니다.")
2728
ApiResponse<StudyInfoResponse> getStudyInfo(Long studyId);
2829

@@ -37,19 +38,4 @@ public interface StudySpecification {
3738

3839
@Operation(summary = "스터디 삭제", description = "스터디를 삭제합니다.")
3940
ApiResponse<Void> deleteStudy(Long studyId);
40-
41-
@Operation(summary = "스터디 탈퇴", description = "스터디를 탈퇴합니다.")
42-
ApiResponse<Void> leaveStudy(Long studyId);
43-
44-
@Operation(summary = "스터디원 강퇴", description = "스터디원을 강퇴합니다.")
45-
ApiResponse<Void> deleteMember(Long studyId, Long userId);
46-
47-
@Operation(summary = "스터디장 위임", description = "스터디원에게 스터디장을 위임합니다.")
48-
ApiResponse<Void> delegateLeader(Long studyId, DelegateLeaderRequest request);
49-
50-
@Operation(summary = "스터디 연장", description = "스터디장이 스터디를 연장합니다.")
51-
ApiResponse<Void> extendStudy(Long studyId, ExtendStudyRequest request);
52-
53-
@Operation(summary = "연장 스터디 참여", description = "스터디원이 연장된 스터디에 참여합니다.")
54-
ApiResponse<Void> joinExtendStudy(Long studyId);
5541
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package grep.neogul_coder.domain.study.controller.dto.request;
22

33
import io.swagger.v3.oas.annotations.media.Schema;
4+
import jakarta.validation.constraints.NotNull;
45
import lombok.Getter;
56

67
import java.time.LocalDate;
78

89
@Getter
910
public class ExtendStudyRequest {
1011

12+
@NotNull
1113
@Schema(description = "연장 스터디의 종료일", example = "2025-07-15")
1214
private LocalDate newEndDate;
1315
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package grep.neogul_coder.domain.study.controller.dto.response;
2+
3+
import io.swagger.v3.oas.annotations.media.Schema;
4+
import lombok.Getter;
5+
6+
@Getter
7+
public class StudyImageResponse {
8+
9+
@Schema(description = "스터디 번호", example = "3")
10+
private Long studyId;
11+
12+
@Schema(description = "대표 이미지", example = "http://localhost:8083/image.jpg")
13+
private String imageUrl;
14+
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
import java.time.LocalDate;
99

1010
@Getter
11-
public class StudyListResponse {
11+
public class StudyItemResponse {
12+
13+
@Schema(description = "스터디 번호", example = "3")
14+
private Long studyId;
1215

1316
@Schema(description = "스터디 이름", example = "자바 스터디")
1417
private String name;

src/main/java/grep/neogul_coder/global/response/ApiResponse.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package grep.neogul_coder.global.response;
22

3+
import lombok.Getter;
4+
5+
@Getter
36
public class ApiResponse<T> {
47

58
private String code;

0 commit comments

Comments
 (0)