package com.hz.pm.api.sys.controller;

import com.hz.pm.api.sys.manage.ProcessStatisticsManage;
import com.hz.pm.api.sys.model.vo.ProcessDetailStatVO;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
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.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * <p>
 * ProcessStatisticsController
 * </p>
 *
 * @author WendyYang
 * @since 2023/7/31
 **/
@Validated
@RestController
@RequestMapping("/api/v1/process/statistics")
@AllArgsConstructor
public class ProcessStatisticsController {

    private final ProcessStatisticsManage processStatisticsManage;

    @GetMapping("/detail")
    @ApiOperation("流程统计详情")
    public ProcessDetailStatVO processStatDetail(@RequestParam(required = false, defaultValue = "DAYS") TimeUnit unit,
                                                 @Valid @NotNull(message = "流程类型不能为空") Integer instType) {
        return processStatisticsManage.processStatDetail(unit, instType);
    }

    @GetMapping("/list")
    @ApiOperation("流程统计详情列表")
    public List<ProcessDetailStatVO> listProcessStatDetail(@RequestParam(required = false, defaultValue = "DAYS") TimeUnit unit) {
        return processStatisticsManage.processStatDetailList(unit);
    }

}
