-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGroupController.java
More file actions
120 lines (103 loc) · 4.38 KB
/
GroupController.java
File metadata and controls
120 lines (103 loc) · 4.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package project.flipnote.group.controller;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import project.flipnote.common.model.response.CursorPagingResponse;
import project.flipnote.common.security.dto.AuthPrinciple;
import project.flipnote.group.controller.docs.GroupControllerDocs;
import project.flipnote.group.model.FindGroupMemberResponse;
import project.flipnote.group.model.GroupCreateRequest;
import project.flipnote.group.model.GroupCreateResponse;
import project.flipnote.group.model.GroupDetailResponse;
import project.flipnote.group.model.GroupInfo;
import project.flipnote.group.model.GroupListRequest;
import project.flipnote.group.model.GroupPutRequest;
import project.flipnote.group.model.GroupPutResponse;
import project.flipnote.group.service.GroupService;
@RequiredArgsConstructor
@RestController
@RequestMapping("/v1/groups")
public class GroupController implements GroupControllerDocs {
private final GroupService groupService;
//그룹 생성 API
@PostMapping("")
public ResponseEntity<GroupCreateResponse> create(
@AuthenticationPrincipal AuthPrinciple authPrinciple,
@Valid @RequestBody GroupCreateRequest req) {
GroupCreateResponse res = groupService.create(authPrinciple, req);
return ResponseEntity.status(HttpStatus.CREATED).body(res);
}
//그룹 수정
@PutMapping("/{groupId}")
public ResponseEntity<GroupPutResponse> changeGroup(
@AuthenticationPrincipal AuthPrinciple authPrinciple,
@Valid @RequestBody GroupPutRequest req,
@PathVariable("groupId") Long groupId) {
GroupPutResponse res = groupService.changeGroup(authPrinciple, req, groupId);
return ResponseEntity.ok(res);
}
//그룹 상세 API
@GetMapping("/{groupId}")
public ResponseEntity<GroupDetailResponse> findGroupDetail(
@AuthenticationPrincipal AuthPrinciple authPrinciple,
@PathVariable("groupId") Long groupId) {
GroupDetailResponse res = groupService.findGroupDetail(authPrinciple, groupId);
return ResponseEntity.ok(res);
}
//그룹 삭제 API
@DeleteMapping("/{groupId}")
public ResponseEntity<Void> deleteGroup(
@AuthenticationPrincipal AuthPrinciple authPrinciple,
@PathVariable("groupId") Long groupId
) {
groupService.deleteGroup(authPrinciple, groupId);
return ResponseEntity.noContent().build();
}
//그룹내 멤버 조회
@GetMapping("/{groupId}/members")
public ResponseEntity<FindGroupMemberResponse> findGroupMembers(
@AuthenticationPrincipal AuthPrinciple authPrinciple,
@PathVariable("groupId") Long groupId) {
FindGroupMemberResponse res = groupService.findGroupMembers(authPrinciple, groupId);
return ResponseEntity.ok(res);
}
//그룹 전체 조회
@GetMapping
public ResponseEntity<CursorPagingResponse<GroupInfo>> findGroup(
@AuthenticationPrincipal AuthPrinciple authPrinciple,
@Valid @ModelAttribute GroupListRequest req
) {
CursorPagingResponse<GroupInfo> res = groupService.findGroup(authPrinciple, req);
return ResponseEntity.ok(res);
}
//내 그룹 전체 조회
@GetMapping("/me")
public ResponseEntity<CursorPagingResponse<GroupInfo>> findMyGroup(
@AuthenticationPrincipal AuthPrinciple authPrinciple,
@Valid @ModelAttribute GroupListRequest req
) {
CursorPagingResponse<GroupInfo> res = groupService.findMyGroup(authPrinciple, req);
return ResponseEntity.ok(res);
}
//내가 생성한 그룹 전체 조회
@GetMapping("/created")
public ResponseEntity<CursorPagingResponse<GroupInfo>> findCreatedGroup(
@AuthenticationPrincipal AuthPrinciple authPrinciple,
@Valid @ModelAttribute GroupListRequest req
) {
CursorPagingResponse<GroupInfo> res = groupService.findCreatedGroup(authPrinciple, req);
return ResponseEntity.ok(res);
}
}