quling
2026-08-22 87c4b63ce203f0fb34241eda92caeccbaceb7f54
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
61
62
63
64
65
package com.tcm.training.admin.points.controller;
 
import com.tcm.training.admin.common.ApiResponse;
import com.tcm.training.admin.points.service.PointsLedgerAppService;
import com.tcm.training.admin.points.vo.PointsLedgerPageVO;
import com.tcm.training.admin.points.vo.PointsRegionOptionVO;
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;
import java.util.List;
 
@Validated
@RestController
@RequestMapping({"/api/v1", "/api"})
public class PointsLedgerController {
 
    private final PointsLedgerAppService pointsLedgerAppService;
 
    public PointsLedgerController(PointsLedgerAppService pointsLedgerAppService) {
        this.pointsLedgerAppService = pointsLedgerAppService;
    }
 
    @GetMapping("/points-ledger")
    public ApiResponse<PointsLedgerPageVO> page(@RequestParam(required = false, defaultValue = "1") int page,
                                                @RequestParam(required = false, defaultValue = "10") int pageSize,
                                                @RequestParam(required = false) String userPhone,
                                                @RequestParam(required = false) String regionCode,
                                                @RequestParam(required = false) String clinicName,
                                                @RequestParam(required = false) String incomeExpenseType,
                                                @RequestParam(required = false) String businessType,
                                                @RequestParam(required = false) String contentKeyword,
                                                @RequestParam(required = false) String referenceNo,
                                                @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime operatedFrom,
                                                @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime operatedTo) {
        return ApiResponse.ok(pointsLedgerAppService.page(
                page, pageSize, userPhone, regionCode, clinicName, incomeExpenseType, businessType, contentKeyword, referenceNo, operatedFrom, operatedTo
        ));
    }
 
    @GetMapping("/points-ledger/export")
    public void export(HttpServletResponse response,
                       @RequestParam(required = false) String userPhone,
                       @RequestParam(required = false) String regionCode,
                       @RequestParam(required = false) String clinicName,
                       @RequestParam(required = false) String incomeExpenseType,
                       @RequestParam(required = false) String businessType,
                       @RequestParam(required = false) String contentKeyword,
                       @RequestParam(required = false) String referenceNo,
                       @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime operatedFrom,
                       @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime operatedTo) throws IOException {
        pointsLedgerAppService.export(response, userPhone, regionCode, clinicName, incomeExpenseType, businessType, contentKeyword, referenceNo, operatedFrom, operatedTo);
    }
 
    @GetMapping("/points-ledger/regions")
    public ApiResponse<List<PointsRegionOptionVO>> regionOptions() {
        return ApiResponse.ok(pointsLedgerAppService.regionOptions());
    }
}