package com.tcm.training.admin.trade.controller; import com.tcm.training.admin.common.ApiResponse; import com.tcm.training.admin.common.PageResponse; import com.tcm.training.admin.trade.service.PaymentFlowAppService; import com.tcm.training.admin.trade.vo.PaymentFlowListItemVO; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.time.LocalDateTime; @Validated @RestController @RequestMapping({"/api/v1", "/api"}) public class RefundFlowController { private final PaymentFlowAppService paymentFlowAppService; public RefundFlowController(PaymentFlowAppService paymentFlowAppService) { this.paymentFlowAppService = paymentFlowAppService; } @GetMapping("/refund-flows") public ApiResponse> page( @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int pageSize, @RequestParam(required = false) String flowNo, @RequestParam(required = false) String businessOrderNo, @RequestParam(required = false) String userPhone, @RequestParam(required = false) String productKeyword, @RequestParam(required = false) String businessType, @RequestParam(required = false) String paymentMethod, @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime tradeFrom, @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime tradeTo) { return ApiResponse.ok(paymentFlowAppService.pageRefundFlows( page, pageSize, flowNo, businessOrderNo, userPhone, productKeyword, businessType, paymentMethod, tradeFrom, tradeTo )); } @GetMapping("/refund-flows/export") public void export(HttpServletResponse response, @RequestParam(required = false) String flowNo, @RequestParam(required = false) String businessOrderNo, @RequestParam(required = false) String userPhone, @RequestParam(required = false) String productKeyword, @RequestParam(required = false) String businessType, @RequestParam(required = false) String paymentMethod, @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime tradeFrom, @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime tradeTo) throws IOException { paymentFlowAppService.exportRefundFlows( response, flowNo, businessOrderNo, userPhone, productKeyword, businessType, paymentMethod, tradeFrom, tradeTo ); } }