“mitao”
2026-04-15 5ad8d714d43ecf06aa9d900a69e7b22018ce7ed6
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
package com.tcm.training.admin.statistics.controller;
 
import com.tcm.training.admin.common.ApiResponse;
import com.tcm.training.admin.statistics.service.RevenueStatisticsAppService;
import com.tcm.training.admin.statistics.vo.RevenueStatisticsVO;
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.LocalDate;
 
@Validated
@RestController
@RequestMapping({"/api/v1", "/api"})
public class RevenueStatisticsController {
 
    private final RevenueStatisticsAppService revenueStatisticsAppService;
 
    public RevenueStatisticsController(RevenueStatisticsAppService revenueStatisticsAppService) {
        this.revenueStatisticsAppService = revenueStatisticsAppService;
    }
 
    @GetMapping("/revenue-statistics")
    public ApiResponse<RevenueStatisticsVO> statistics(
            @RequestParam(required = false) String type,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate dateFrom,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate dateTo) {
        return ApiResponse.ok(revenueStatisticsAppService.statistics(type, dateFrom, dateTo));
    }
 
    @GetMapping("/revenue-statistics/export")
    public void export(HttpServletResponse response,
                       @RequestParam(required = false) String type,
                       @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate dateFrom,
                       @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate dateTo) throws IOException {
        revenueStatisticsAppService.export(response, type, dateFrom, dateTo);
    }
}