package com.nantian.cloud.dbcapp.controller;

import com.nantian.cloud.dbcapp.bean.PublicInstitutionDomain;
import com.nantian.cloud.dbcapp.service.PublicInstutionNumService;
import com.nantian.sc.cloud.common.log.annotation.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@CrossOrigin
@RestController
@AllArgsConstructor
@RequestMapping("/publicInstitution")
@Api(value = "Calculate", tags = "计算")
public class PublicInstitutionController {
    @Autowired
    PublicInstutionNumService publicInstutionNumService;

    @GetMapping("/publicInstitutionNum")
    @SysLog("查询机构数总量")
    @ApiOperation(value = "查询机构数总量", notes = "查询机构数总量")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "area", value = "地区", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "institution", value = "机构", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "time", value = "时间", required = false, dataType = "string", paramType = "path")
    })
    public PublicInstitutionDomain getTotalStructure(String area, String institution , String time ) throws IOException {
        PublicInstitutionDomain publicInstitutionDomain=publicInstutionNumService.getPublicInstitutionDomain(area,institution,time);
        return publicInstitutionDomain;
    }


    @GetMapping("/getEveryAreaData")
    @SysLog("查询各地区五个统计项的数据")
    @ApiOperation(value = "查询各地区五个统计项的数据", notes = "查询各地区五个统计项的数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "institution", value = "机构", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "time", value = "时间", required = false, dataType = "string", paramType = "path")
    })
    public List<Object> getEveryAreaData(String institution , String time ) throws IOException {
        List<Object> listTotal=new ArrayList<>();
        listTotal=publicInstutionNumService.getEveryAreaData(institution,time);
        return listTotal;
    }

    @GetMapping("/getChartData")
    public List<Object> getChartData() throws IOException {
        List<Object> listTotal=new ArrayList<>();
        listTotal=publicInstutionNumService.getChartData();
        return listTotal;
    }//
}
