package com.iformall.controller;

import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ResultData;
import com.iformall.service.WxChartDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.Map;

@Api(description = "图表")
@RestController
@RequestMapping("chart")
public class WxChartDataController extends BaseController {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private WxChartDataService wxChartDataService;

    @ApiOperation("queryData")
    @GetMapping("/queryData")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "chart", value = "chart", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "startdate", value = "startdate", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "enddate", value = "enddate", dataType = "String", paramType = "query")
    })
    @SystemControllerLog(description = "报表-图表")
    public ResultData queryData(@RequestParam Map<String, String> params) {
        String chart = params.get("chart");
        logger.info("[" + getIpAddr() + "] WxChartDataController::queryData chart: " + chart);
        params.put("tenantId",super.getTenantId());
        ResultData data = wxChartDataService.queryData(params);
        logger.info("[" + getIpAddr() + "] WxChartDataController::queryData chart: " + chart + " end");
        return data;
    }

}
