package com.ruoyi.web.controller.dxp.system.index;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.dxp.dto.BarChartDto;
import com.ruoyi.dxp.dto.BarChartParam;
import com.ruoyi.dxp.dto.IndexStaticsDto;
import com.ruoyi.dxp.dto.WholeAccessBarChartDto;
import com.ruoyi.dxp.service.IIndexStaticsService;
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.RestController;

import java.util.List;

@RestController
@RequestMapping("/system/index")
public class IndexController extends BaseController {

    @Autowired
    private IIndexStaticsService iIndexStaticsService;

    /**
     * 获取首页统计数据
     *
     */
    @GetMapping("/statics")
    public AjaxResult getStatics() {
        IndexStaticsDto indexStatics = iIndexStaticsService.getIndexStatics();
        return success(indexStatics);
    }

    /**
     * 获取首页柱状图数据
     *
     */
    @GetMapping("/barchart")
    public AjaxResult getBarChart(BarChartParam param) {
        List<BarChartDto> callData = iIndexStaticsService.getCallData(param);
        return success(callData);
    }

    /**
     * 查询日分组
     */
    @GetMapping("/daygroup")
    public AjaxResult getAccessDataGroup(BarChartParam param) {
        List<WholeAccessBarChartDto> wholeAccessBarChartDtos = iIndexStaticsService.selectAccessAndShareGroupData(param);
        return success(wholeAccessBarChartDtos);
    }
}
