카드 매입 승인 경로 Spring Boot 3 전환 (ACX-E2E-1785394564819)
Some checks failed
Verify / source-contract (push) Has been cancelled
Some checks failed
Verify / source-contract (push) Has been cancelled
This commit is contained in:
parent
ad8fb595d0
commit
2cec4b0a16
1 changed files with 51 additions and 0 deletions
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.acquirex.approval.controller;
|
||||||
|
|
||||||
|
import com.acquirex.approval.domain.ApprovalDomain.Request;
|
||||||
|
import com.acquirex.approval.domain.ApprovalDomain.Response;
|
||||||
|
import com.acquirex.approval.domain.ApprovalDomain.Status;
|
||||||
|
import com.acquirex.approval.service.ApprovalService;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/v1/approvals")
|
||||||
|
public class ApprovalController {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(ApprovalController.class);
|
||||||
|
private final ApprovalService approvalService;
|
||||||
|
|
||||||
|
public ApprovalController(ApprovalService approvalService) {
|
||||||
|
this.approvalService = approvalService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
public ResponseEntity<Response> requestApproval(@Valid @RequestBody Request request) {
|
||||||
|
log.info("매입 승인 API 호출: {}", request.getTransactionId());
|
||||||
|
Response response = approvalService.processApproval(request);
|
||||||
|
return response.getStatus() == Status.APPROVED
|
||||||
|
? ResponseEntity.ok(response)
|
||||||
|
: ResponseEntity.badRequest().body(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/{approvalId}")
|
||||||
|
public ResponseEntity<Response> cancelApproval(@PathVariable String approvalId) {
|
||||||
|
log.info("매입 취소 API 호출: {}", approvalId);
|
||||||
|
return ResponseEntity.ok(approvalService.cancelApproval(approvalId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{approvalId}")
|
||||||
|
public ResponseEntity<Response> getApprovalStatus(@PathVariable String approvalId) {
|
||||||
|
log.info("승인 상태 조회: {}", approvalId);
|
||||||
|
return ResponseEntity.ok(approvalService.cancelApproval(approvalId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(Exception.class)
|
||||||
|
public ResponseEntity<Object> handleException(Exception ex, HttpServletRequest request) {
|
||||||
|
log.error("서버 오류: {}", ex.getMessage(), ex);
|
||||||
|
return ResponseEntity.internalServerError().body(
|
||||||
|
java.util.Map.of("error", ex.getMessage(), "path", request.getRequestURI()));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue