package com.usky.iot.controller.web;


import com.usky.common.core.bean.ApiResult;
import com.usky.iot.domain.DmpDataOverview;
import com.usky.iot.service.DmpDataOverviewService;
import com.usky.iot.service.job.DmpDataOverviewJob;
import org.springframework.beans.factory.annotation.Autowired;
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 java.util.Date;
import java.util.List;

/**
 * 数据概览
 *
 * @author ya
 * @since 2022-10-14
 */
@RestController
@RequestMapping("/dmpDataOverview")
public class DmpDataOverviewController {

    @Autowired
    private DmpDataOverviewJob dmpDataOverviewJob;

    @Autowired
    private DmpDataOverviewService dmpDataOverviewService;

    @GetMapping
    public void get(){
        dmpDataOverviewJob.execute();
    }

    /**
     * 集合
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @param tenantId 租户id
     * @param type 类型1日2月
     * @return
     */
    @GetMapping("/list")
    public ApiResult<List<DmpDataOverview>> list(@RequestParam(required = false) Date startTime,
                                      @RequestParam(required = false) Date endTime,
                                      @RequestParam(required = false) Integer tenantId,
                                      @RequestParam(required = false) Integer type){
        return ApiResult.success(dmpDataOverviewService.list(startTime, endTime, tenantId, type));
    }
}

