-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathApplicantController.java
60 lines (52 loc) · 2.54 KB
/
ApplicantController.java
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
package com.cruru.applicant.controller;
import com.cruru.applicant.controller.dto.ApplicantBasicResponse;
import com.cruru.applicant.controller.dto.ApplicantDetailResponse;
import com.cruru.applicant.controller.dto.ApplicantMoveRequest;
import com.cruru.applicant.controller.dto.ApplicantUpdateRequest;
import com.cruru.applicant.service.ApplicantService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
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.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/v1/applicants")
@RequiredArgsConstructor
public class ApplicantController {
private final ApplicantService applicantService;
@PutMapping("/move-process/{processId}")
public ResponseEntity<Void> updateApplicantProcess(
@PathVariable Long processId,
@RequestBody @Valid ApplicantMoveRequest moveRequest
) {
applicantService.updateApplicantProcess(processId, moveRequest);
return ResponseEntity.ok().build();
}
@GetMapping("/{applicant_id}")
public ResponseEntity<ApplicantBasicResponse> read(@PathVariable("applicant_id") Long applicantId) {
ApplicantBasicResponse applicantResponse = applicantService.findById(applicantId);
return ResponseEntity.ok().body(applicantResponse);
}
@GetMapping("/{applicant_id}/detail")
public ResponseEntity<ApplicantDetailResponse> readDetail(@PathVariable("applicant_id") Long applicantId) {
ApplicantDetailResponse applicantDetailResponse = applicantService.findDetailById(applicantId);
return ResponseEntity.ok().body(applicantDetailResponse);
}
@PatchMapping("/{applicant_id}/reject")
public ResponseEntity<ApplicantDetailResponse> reject(@PathVariable("applicant_id") Long applicantId) {
applicantService.reject(applicantId);
return ResponseEntity.ok().build();
}
@PatchMapping("/{applicant_id}")
private ResponseEntity<Void> update(
@PathVariable("applicant_id") Long applicantId,
@RequestBody @Valid ApplicantUpdateRequest request) {
applicantService.update(request, applicantId);
return ResponseEntity.ok().build();
}
}