package cn.stylefeng.workflow.instance.modular.stat.business.controller;

import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.workflow.instance.modular.stat.business.pojo.ScopeStatResult;
import cn.stylefeng.workflow.instance.modular.stat.business.pojo.StatResult;
import cn.stylefeng.workflow.instance.modular.stat.business.service.InstanceStatService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@ApiResource(name = "流程信息的统计")
public class InstanceStatController {

    @Resource
    private InstanceStatService instanceStatService;

    @GetResource(name = "获取流程信息的统计，近几天的情况展示", path = "/instanceStat/getRecentStat")
    public ResponseData<StatResult> getRecentStat(@RequestParam("days") Integer days) {
        return new SuccessResponseData<>(instanceStatService.getRecentStat(days));
    }

    @GetResource(name = "获取流程统计，范围下的不同数据的返回", path = "/instanceStat/getScopeData")
    public ResponseData<List<ScopeStatResult>> getScopeData(@RequestParam("days") Integer days) {
        return new SuccessResponseData<>(instanceStatService.getStatScopeInfo(days));
    }

}
