1
1
package com .prgrms2 .java .bitta .jobpost .controller ;
2
2
3
3
import com .prgrms2 .java .bitta .jobpost .dto .JobPostDTO ;
4
+ import com .prgrms2 .java .bitta .global .dto .PageRequestDTO ;
4
5
import com .prgrms2 .java .bitta .jobpost .service .JobPostService ;
5
6
import io .swagger .v3 .oas .annotations .Operation ;
6
7
import io .swagger .v3 .oas .annotations .Parameter ;
7
8
import io .swagger .v3 .oas .annotations .media .Content ;
8
9
import io .swagger .v3 .oas .annotations .media .Schema ;
9
10
import io .swagger .v3 .oas .annotations .responses .ApiResponse ;
10
11
import io .swagger .v3 .oas .annotations .tags .Tag ;
12
+ import jakarta .validation .Valid ;
11
13
import lombok .RequiredArgsConstructor ;
12
14
import lombok .extern .log4j .Log4j2 ;
15
+ import org .springframework .data .domain .Page ;
13
16
import org .springframework .http .ResponseEntity ;
17
+ import org .springframework .validation .annotation .Validated ;
14
18
import org .springframework .web .bind .annotation .*;
15
19
16
- import java .util .List ;
17
20
import java .util .Map ;
18
21
19
22
import static com .prgrms2 .java .bitta .global .constants .ApiResponses .*;
20
23
21
24
@ Tag (name = "일거리 API 컨트롤러" , description = "일거리와 관련된 REST API를 제공하는 컨틀롤러입니다." )
22
25
@ RestController
23
26
@ RequiredArgsConstructor
24
- @ RequestMapping ("/api/v1/jobpost " )
27
+ @ RequestMapping ("/api/v1/job-post " )
25
28
@ Log4j2
26
29
public class JobPostController {
27
30
private final JobPostService jobPostService ;
@@ -48,9 +51,10 @@ public class JobPostController {
48
51
)
49
52
}
50
53
)
54
+
51
55
@ GetMapping
52
- public ResponseEntity <List <JobPostDTO >> findAll ( ) {
53
- return ResponseEntity .ok (jobPostService .getList ());
56
+ public ResponseEntity <Page <JobPostDTO >> getList ( @ Valid PageRequestDTO pageRequestDTO ) {
57
+ return ResponseEntity .ok (jobPostService .getList (pageRequestDTO ));
54
58
}
55
59
56
60
@ Operation (
@@ -76,7 +80,7 @@ public ResponseEntity<List<JobPostDTO>> findAll() {
76
80
}
77
81
)
78
82
@ PostMapping
79
- public ResponseEntity <JobPostDTO > registerJobPost (@ RequestBody JobPostDTO jobPostDTO ) {
83
+ public ResponseEntity <JobPostDTO > registerJobPost (@ Valid @ RequestBody JobPostDTO jobPostDTO ) {
80
84
return ResponseEntity .ok (jobPostService .register (jobPostDTO ));
81
85
}
82
86
@@ -110,7 +114,7 @@ public ResponseEntity<JobPostDTO> registerJobPost(@RequestBody JobPostDTO jobPos
110
114
schema = @ Schema (type = "integer" )
111
115
)
112
116
@ GetMapping ("/{id}" )
113
- public ResponseEntity <JobPostDTO > readJobPost (@ PathVariable ("id" ) Long id ) {
117
+ public ResponseEntity <JobPostDTO > readJobPost (@ PathVariable ("id" ) @ Valid Long id ) {
114
118
return ResponseEntity .ok (jobPostService .read (id ));
115
119
}
116
120
@@ -152,7 +156,7 @@ public ResponseEntity<JobPostDTO> readJobPost(@PathVariable("id") Long id) {
152
156
schema = @ Schema (type = "integer" )
153
157
)
154
158
@ PutMapping ("/{id}" )
155
- public ResponseEntity <JobPostDTO > modifyJobPost (@ RequestBody JobPostDTO jobPostDTO , @ PathVariable ("id" ) Long id ) {
159
+ public ResponseEntity <JobPostDTO > modifyJobPost (@ RequestBody JobPostDTO jobPostDTO , @ Valid @ PathVariable ("id" ) Long id ) {
156
160
return ResponseEntity .ok (jobPostService .modify (jobPostDTO ));
157
161
}
158
162
@@ -194,8 +198,8 @@ public ResponseEntity<JobPostDTO> modifyJobPost(@RequestBody JobPostDTO jobPostD
194
198
schema = @ Schema (type = "integer" )
195
199
)
196
200
@ DeleteMapping ("/{id}" )
197
- public ResponseEntity <Map <String , String >> deleteJobPost (@ PathVariable ("id" ) Long id ) {
201
+ public ResponseEntity <Map <String , String >> deleteJobPost (@ Valid @ PathVariable ("id" ) Long id ) {
198
202
jobPostService .remove (id );
199
- return ResponseEntity .ok (Map .of ("message" , "success " ));
203
+ return ResponseEntity .ok (Map .of ("message" , "삭제가 완료되었습니다 " ));
200
204
}
201
205
}
0 commit comments