-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathNoteControllerV2.java
More file actions
100 lines (88 loc) · 4.52 KB
/
NoteControllerV2.java
File metadata and controls
100 lines (88 loc) · 4.52 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
package umc.th.juinjang.api.limjang.controller;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
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 io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import umc.th.juinjang.api.dto.ApiResponse;
import umc.th.juinjang.api.limjang.controller.parameter.LimjangSortOptions;
import umc.th.juinjang.api.limjang.controller.request.NoteInitRequest;
import umc.th.juinjang.api.limjang.controller.request.NotePatchRequest;
import umc.th.juinjang.api.limjang.controller.request.NotePatchRequestV2;
import umc.th.juinjang.api.limjang.controller.request.NotePostRequest;
import umc.th.juinjang.api.limjang.service.NoteCommandServiceV2;
import umc.th.juinjang.api.limjang.service.NoteQueryServiceV2;
import umc.th.juinjang.api.limjang.service.response.ChecklistConditionResponse;
import umc.th.juinjang.api.limjang.service.response.NotePostResponse;
import umc.th.juinjang.api.limjang.service.response.UserNoteGetResponse;
import umc.th.juinjang.api.limjang.service.response.UserNotesGetResponse;
import umc.th.juinjang.api.limjang.service.response.UserNotesShareableGetResponse;
import umc.th.juinjang.common.code.status.SuccessStatus;
import umc.th.juinjang.domain.member.model.Member;
@RestController
@RequestMapping("/api/v2/users")
@RequiredArgsConstructor
public class NoteControllerV2 {
private final NoteCommandServiceV2 noteCommandService;
private final NoteQueryServiceV2 noteQueryService;
@Operation(summary = "임장 생성 API V2")
@PostMapping("/notes")
public ApiResponse<NotePostResponse> createNote(@RequestBody @Valid NotePostRequest request,
@AuthenticationPrincipal Member member) {
return ApiResponse.of(SuccessStatus._CREATED, noteCommandService.createNote(request, member));
}
@Operation(summary = "임장 생성 API INIT V2 - 간편한 임장 생성")
@PostMapping("/notes/init")
public ApiResponse<NotePostResponse> initNote(@RequestBody @Valid NoteInitRequest request,
@AuthenticationPrincipal Member member) {
return ApiResponse.of(SuccessStatus._CREATED, noteCommandService.initNote(request, member));
}
@Operation(summary = "마이 노트 조회 API V2")
@GetMapping("/notes")
public ApiResponse<UserNotesGetResponse> findUsersNotes(
@RequestParam("sort") LimjangSortOptions sortOptions,
@RequestParam(value = "keyword", required = false) String keyword,
@AuthenticationPrincipal Member member) {
return ApiResponse.onSuccess(noteQueryService.findUsersNotes(member, sortOptions, keyword));
}
@Operation(summary = "임장 수정 API V2")
@PatchMapping("/notes/{noteId}")
public ApiResponse<Void> updateNote(@PathVariable(name = "noteId") Long noteId,
@RequestBody @Valid NotePatchRequest request,
@AuthenticationPrincipal Member member) {
noteCommandService.updateNoteV2(noteId, request);
return ApiResponse.onSuccess(null);
}
@Operation(summary = "임장 수정 API V2 - UI/UX 리팩토링")
@PatchMapping("/notes/init/{noteId}")
public ApiResponse<Void> updateNoteV2(@PathVariable(name = "noteId") Long noteId,
@RequestBody @Valid NotePatchRequestV2 request,
@AuthenticationPrincipal Member member) {
noteCommandService.updateNoteInitV2(noteId, request);
return ApiResponse.onSuccess(null);
}
@Operation(summary = "임장 노트 출력 - 공유하기 선택 화면 API")
@GetMapping("/notes/shareable")
public ApiResponse<UserNotesShareableGetResponse> findNotesShareable(@AuthenticationPrincipal Member member) {
return ApiResponse.onSuccess(noteQueryService.findNotesShareable(member));
}
@Operation(summary = "임장 노트 상세보기(내 임장) 화면 API")
@GetMapping("/notes/{noteId}")
public ApiResponse<UserNoteGetResponse> findNote(@AuthenticationPrincipal Member member,
@PathVariable("noteId") Long noteId) {
return ApiResponse.onSuccess(noteQueryService.findNote(noteId));
}
@GetMapping("/notes/{noteId}/checklist-condition")
public ApiResponse<ChecklistConditionResponse> checkChecklistCondition(
@PathVariable Long noteId
) {
return ApiResponse.onSuccess(noteQueryService.checkLimjangChecklistSatisfaction(noteId));
}
}