카드 매입 승인 경로 Spring Boot 3 전환 #8
1 changed files with 47 additions and 0 deletions
|
|
@ -0,0 +1,47 @@
|
|||
package com.acquirex.controller;
|
||||
|
||||
import com.acquirex.dto.ApprovalRequestDto;
|
||||
import com.acquirex.dto.ApprovalResponseDto;
|
||||
import com.acquirex.service.ApprovalService;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/approvals")
|
||||
public class ApprovalController {
|
||||
|
||||
private final ApprovalService approvalService;
|
||||
|
||||
public ApprovalController(ApprovalService approvalService) {
|
||||
this.approvalService = approvalService;
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<ApprovalResponseDto> requestApproval(@Valid @RequestBody ApprovalRequestDto request) {
|
||||
ApprovalResponseDto response = approvalService.requestApproval(request);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(response);
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/approve")
|
||||
public ResponseEntity<ApprovalResponseDto> approveRequest(@PathVariable Long id) {
|
||||
ApprovalResponseDto response = approvalService.approveRequest(id);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/reject")
|
||||
public ResponseEntity<ApprovalResponseDto> rejectRequest(@PathVariable Long id, @RequestBody Map<String, String> body) {
|
||||
String reason = body.getOrDefault("reason", "사유 미지정");
|
||||
ApprovalResponseDto response = approvalService.rejectRequest(id, reason);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<ApprovalResponseDto> getApprovalStatus(@PathVariable Long id) {
|
||||
ApprovalResponseDto response = approvalService.getApprovalStatus(id);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue