1
1
package kea.dpang.faq.controller
2
2
3
+ import io.swagger.v3.oas.annotations.Operation
4
+ import io.swagger.v3.oas.annotations.Parameter
5
+ import io.swagger.v3.oas.annotations.tags.Tag
3
6
import kea.dpang.faq.base.BaseResponse
4
7
import kea.dpang.faq.base.SuccessResponse
5
8
import kea.dpang.faq.dto.PostCreateRequestDto
@@ -13,13 +16,17 @@ import org.springframework.web.bind.annotation.*
13
16
import java.util.*
14
17
15
18
@RestController
19
+ @Tag(name = " FAQ" )
16
20
@RequestMapping(" /api/posts" )
17
21
class PostController (private val postService : PostService ) {
18
22
23
+ @Operation(summary = " 게시글 작성" , description = " 관리자 권한을 가진 사용자가 새로운 게시글을 생성합니다." )
19
24
@PreAuthorize(" hasRole('ADMIN') or hasRole('SUPER_ADMIN')" )
20
25
@PostMapping
21
26
fun createPost (
27
+ @Parameter(hidden = true )
22
28
@RequestHeader(" X-DPANG-CLIENT-ID" ) clientId : UUID ,
29
+ @Parameter(description = " 포스트 생성 정보" )
23
30
@RequestBody postCreateDto : PostCreateRequestDto
24
31
): ResponseEntity <SuccessResponse <PostResponse >> {
25
32
@@ -35,9 +42,11 @@ class PostController(private val postService: PostService) {
35
42
return ResponseEntity (successResponse, HttpStatus .CREATED )
36
43
}
37
44
45
+ @Operation(summary = " 게시글 조회" , description = " 특정 게시글을 조회합니다." )
38
46
@PreAuthorize(" hasAnyRole('USER', 'ADMIN','SUPER_ADMIN')" )
39
47
@GetMapping(" /{postId}" )
40
48
fun readPost (
49
+ @Parameter(description = " 조회할 포스트의 ID" )
41
50
@PathVariable postId : Long
42
51
): ResponseEntity <SuccessResponse <PostResponse >> {
43
52
@@ -53,9 +62,11 @@ class PostController(private val postService: PostService) {
53
62
return ResponseEntity (successResponse, HttpStatus .OK )
54
63
}
55
64
65
+ @Operation(summary = " 카테고리별 게시글 조회" , description = " 특정 카테고리의 게시글을 조회합니다." )
56
66
@PreAuthorize(" hasAnyRole('USER', 'ADMIN','SUPER_ADMIN')" )
57
67
@GetMapping(" /category/{categoryName}" )
58
68
fun readPostsByCategory (
69
+ @Parameter(description = " 조회할 카테고리" )
59
70
@PathVariable categoryName : String
60
71
): ResponseEntity <SuccessResponse <List <PostResponse >>> {
61
72
@@ -71,11 +82,15 @@ class PostController(private val postService: PostService) {
71
82
return ResponseEntity (successResponse, HttpStatus .OK )
72
83
}
73
84
85
+ @Operation(summary = " 게시글 수정" , description = " 관리자 권한을 가진 사용자가 특정 게시글을 수정합니다." )
74
86
@PreAuthorize(" hasAnyRole('ADMIN','SUPER_ADMIN')" )
75
87
@PutMapping(" /{postId}" )
76
88
fun updatePost (
89
+ @Parameter(hidden = true )
77
90
@RequestHeader(" X-DPANG-CLIENT-ID" ) clientId : UUID ,
91
+ @Parameter(description = " 수정할 포스트의 ID" )
78
92
@PathVariable postId : Long ,
93
+ @Parameter(description = " 포스트 수정 정보" )
79
94
@RequestBody faqUpdateDto : PostUpdateRequestDto
80
95
): ResponseEntity <SuccessResponse <PostResponse >> {
81
96
@@ -91,9 +106,11 @@ class PostController(private val postService: PostService) {
91
106
return ResponseEntity (successResponse, HttpStatus .OK )
92
107
}
93
108
109
+ @Operation(summary = " 게시글 삭제" , description = " 관리자 권한을 가진 사용자가 특정 게시글을 삭제합니다." )
94
110
@PreAuthorize(" hasAnyRole('ADMIN','SUPER_ADMIN')" )
95
111
@DeleteMapping(" /{postId}" )
96
112
fun deletePost (
113
+ @Parameter(description = " 삭제할 게시글의 ID" )
97
114
@PathVariable postId : Long
98
115
): ResponseEntity <BaseResponse > {
99
116
0 commit comments