|
3 | 3 | import com.api.builtin.application.NoticeFacade; |
4 | 4 | import com.api.global.support.response.Message; |
5 | 5 | import com.api.global.support.response.TtoklipResponse; |
6 | | -import com.api.global.util.SecurityUtil; |
7 | 6 | import com.domain.bulletin.domain.NoticeCreate; |
8 | 7 | import com.domain.bulletin.domain.NoticeEdit; |
9 | 8 | import com.domain.bulletin.domain.NoticeResponse; |
10 | 9 | import com.domain.bulletin.domain.NoticeResponses; |
11 | | -import io.swagger.v3.oas.annotations.Operation; |
12 | | -import io.swagger.v3.oas.annotations.Parameter; |
13 | | -import io.swagger.v3.oas.annotations.media.Content; |
14 | | -import io.swagger.v3.oas.annotations.media.ExampleObject; |
15 | | -import io.swagger.v3.oas.annotations.media.Schema; |
16 | | -import io.swagger.v3.oas.annotations.responses.ApiResponses; |
17 | | -import io.swagger.v3.oas.annotations.tags.Tag; |
| 10 | +import com.api.global.util.SecurityUtil; |
18 | 11 | import lombok.RequiredArgsConstructor; |
19 | 12 | import org.springframework.http.MediaType; |
20 | 13 | import org.springframework.validation.annotation.Validated; |
21 | | -import org.springframework.web.bind.annotation.DeleteMapping; |
22 | | -import org.springframework.web.bind.annotation.GetMapping; |
23 | | -import org.springframework.web.bind.annotation.PatchMapping; |
24 | | -import org.springframework.web.bind.annotation.PathVariable; |
25 | | -import org.springframework.web.bind.annotation.PostMapping; |
26 | | -import org.springframework.web.bind.annotation.RequestBody; |
27 | | -import org.springframework.web.bind.annotation.RequestMapping; |
28 | | -import org.springframework.web.bind.annotation.RequestParam; |
29 | | -import org.springframework.web.bind.annotation.RestController; |
| 14 | +import org.springframework.web.bind.annotation.*; |
30 | 15 |
|
31 | | -@Tag(name = "Notice", description = "공지사항 api입니다") |
32 | 16 | @RequiredArgsConstructor |
33 | 17 | @RestController |
34 | 18 | @RequestMapping("/api/v1/notice") |
35 | | -public class BulletinController { |
| 19 | +public class BulletinController implements BulletinControllerDocs { |
36 | 20 |
|
37 | | - private final static int PAGE_SIZE = 10; // 페이지 당 데이터 수 |
38 | 21 | private final NoticeFacade noticeFacade; |
| 22 | + private final static int PAGE_SIZE = 10; |
39 | 23 |
|
40 | | - @Operation(summary = "모든 공지사항 불러오기", description = "공지사항 목록을 가져옵니다") |
41 | | - @ApiResponses(value = { |
42 | | - @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "공지사항 조회 성공", |
43 | | - content = @Content( |
44 | | - mediaType = "application/json", |
45 | | - schema = @Schema(implementation = TtoklipResponse.class), |
46 | | - examples = @ExampleObject( |
47 | | - name = "SuccessResponse", |
48 | | - value = NotiConstant.noticeResponse, |
49 | | - description = "공지사항이 조회되었습니다" |
50 | | - )))}) |
| 24 | + @Override |
51 | 25 | @GetMapping |
52 | 26 | public TtoklipResponse<NoticeResponses> getNoticeList( |
53 | | - @Parameter(description = "페이지 번호 (0부터 시작, 기본값 0)", example = "0") |
54 | | - @RequestParam(required = false, defaultValue = "0") final int page) { |
| 27 | + @RequestParam(required = false, defaultValue = "0") int page) { |
55 | 28 | NoticeResponses noticeResponses = noticeFacade.getNoticeList(page, PAGE_SIZE); |
56 | 29 | return new TtoklipResponse<>(noticeResponses); |
57 | 30 | } |
58 | 31 |
|
59 | | - @Operation(summary = "공지사항 생성", description = "공지사항을 만듭니다") |
60 | | - @ApiResponses(value = { |
61 | | - @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "공지사항 생성 성공", |
62 | | - content = @Content( |
63 | | - mediaType = MediaType.APPLICATION_JSON_VALUE, |
64 | | - schema = @Schema(implementation = TtoklipResponse.class), |
65 | | - examples = @ExampleObject( |
66 | | - name = "SuccessResponse", |
67 | | - value = NotiConstant.createNoticeResponse, |
68 | | - description = "공지사항이 생성되었습니다" |
69 | | - )))}) |
| 32 | + @Override |
70 | 33 | @PostMapping(value = "/create", consumes = MediaType.APPLICATION_JSON_VALUE) |
71 | | - public TtoklipResponse<Message> register(final @Validated @RequestBody NoticeCreate request) { |
| 34 | + public TtoklipResponse<Message> register(@Validated @RequestBody NoticeCreate request) { |
72 | 35 | Message message = noticeFacade.register(request); |
73 | 36 | return new TtoklipResponse<>(message); |
74 | 37 | } |
75 | 38 |
|
76 | | - @Operation(summary = "공지사항 조회", description = "공지사항 ID에 해당하는 공지사항을 조회합니다.") |
77 | | - @ApiResponses(value = { |
78 | | - @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "공지사항 성공", |
79 | | - content = @Content( |
80 | | - mediaType = MediaType.APPLICATION_JSON_VALUE, |
81 | | - schema = @Schema(implementation = TtoklipResponse.class), |
82 | | - examples = @ExampleObject( |
83 | | - name = "SuccessResponse", |
84 | | - value = NotiConstant.singleNoticeResponse, |
85 | | - description = "공지사항이 조회되었습니다." |
86 | | - )))}) |
| 39 | + @Override |
87 | 40 | @GetMapping("/{noticeId}") |
88 | | - public TtoklipResponse<NoticeResponse> getSingleNotice(final @PathVariable Long noticeId) { |
| 41 | + public TtoklipResponse<NoticeResponse> getSingleNotice(@PathVariable Long noticeId) { |
89 | 42 | NoticeResponse singleNotice = noticeFacade.getSingleNotice(noticeId); |
90 | 43 | return new TtoklipResponse<>(singleNotice); |
91 | 44 | } |
92 | 45 |
|
93 | | - @Operation(summary = "공지사항 삭제", description = "공지사항 ID에 해당하는 공지사항을 삭제합니다.") |
94 | | - @ApiResponses(value = { |
95 | | - @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "공지사항 삭제 성공", |
96 | | - content = @Content( |
97 | | - mediaType = MediaType.APPLICATION_JSON_VALUE, |
98 | | - schema = @Schema(implementation = TtoklipResponse.class), |
99 | | - examples = @ExampleObject( |
100 | | - name = "SuccessResponse", |
101 | | - value = NotiConstant.deleteNoticeResponse, |
102 | | - description = "공지사항을 삭제하였습니다" |
103 | | - )))}) |
| 46 | + @Override |
104 | 47 | @DeleteMapping("/{noticeId}") |
105 | | - public TtoklipResponse<Message> deleteNotice(final @PathVariable Long noticeId) { |
| 48 | + public TtoklipResponse<Message> deleteNotice(@PathVariable Long noticeId) { |
106 | 49 | Message message = noticeFacade.delete(noticeId); |
107 | 50 | return new TtoklipResponse<>(message); |
108 | 51 | } |
109 | 52 |
|
110 | | - @Operation(summary = "공지사항 수정", description = "공지사항 ID에 해당하는 공지사항을 수정합니다.") |
111 | | - @ApiResponses(value = { |
112 | | - @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "공지사항 수정 성공", |
113 | | - content = @Content( |
114 | | - mediaType = MediaType.APPLICATION_JSON_VALUE, |
115 | | - schema = @Schema(implementation = TtoklipResponse.class), |
116 | | - examples = @ExampleObject( |
117 | | - name = "SuccessResponse", |
118 | | - value = NotiConstant.updateNoticeResponse, |
119 | | - description = "공지사항이 수정되었습니다." |
120 | | - )))}) |
| 53 | + @Override |
121 | 54 | @PatchMapping("/{noticeId}") |
122 | | - public TtoklipResponse<Message> edit(final @PathVariable Long noticeId, |
123 | | - final @RequestBody NoticeEdit request) { |
| 55 | + public TtoklipResponse<Message> edit(@PathVariable Long noticeId, @RequestBody NoticeEdit request) { |
124 | 56 | Long currentMemberId = SecurityUtil.getCurrentMember().getId(); |
125 | 57 | Message message = noticeFacade.edit(noticeId, request, currentMemberId); |
126 | 58 | return new TtoklipResponse<>(message); |
|
0 commit comments