WangHan
2025-04-03 a1b85ef72062ca80db35546e4216dd564f3e0f57
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
package com.iplatform.base.controller;
 
import com.iplatform.base.SystemController;
import com.iplatform.base.service.ApiTimeServiceImpl;
import com.iplatform.model.vo.ApiTime;
import com.walker.infrastructure.utils.StringUtils;
import com.walker.web.ResponseValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
 
@RestController
@RequestMapping("/test/api")
public class ApiTimeController extends SystemController {
 
    private ApiTimeServiceImpl apiTimeService;
 
    @Autowired
    public ApiTimeController(ApiTimeServiceImpl apiTimeService){
        this.apiTimeService = apiTimeService;
    }
 
    /**
     * 查询接口调用时间记录
     * @param currentDate 当前日期,如:20240229(可选)
     * @param maxSize 限制返回记录最大条数,如:200(可选)
     * @param cost 条件:最小花费时间,毫秒,超过该时间的记录,如:200(可选)
     * @return
     */
    @RequestMapping("/time")
    public ResponseValue getCostMostList(String currentDate, String cost, String maxSize){
        Integer dateValue = null;
        Integer maxSizeValue = null;
        Long costValue = null;
        if(StringUtils.isNotEmpty(currentDate)){
            dateValue = Integer.parseInt(currentDate);
        }
        if(StringUtils.isNotEmpty(maxSize)){
            maxSizeValue = Integer.parseInt(maxSize);
        }
        if(StringUtils.isNotEmpty(cost)){
            costValue = Long.parseLong(cost);
        }
        List<ApiTime> data = this.apiTimeService.queryCostList(dateValue, maxSizeValue, costValue);
        return ResponseValue.success(data);
    }
}