package com.yccrc.kede.controller.other;

import cn.hutool.core.bean.BeanUtil;
import com.yccrc.common.core.controller.BaseController;
import com.yccrc.common.vo.Result;
import com.yccrc.kede.service.IEnterpriseProjectService;
import com.yccrc.kede.service.IEnterpriseService;
import com.yccrc.kede.service.IProjectService;
import com.yccrc.kede.vo.IndexRptVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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;

/**
 * 行政区域Controller
 *
 * @author chuanglx
 * @date 2022-01-12
 */
@RestController
@RequestMapping("/index/report")
@Api(tags = "首页数据统计")
public class ReportController extends BaseController {
    @Autowired
    IEnterpriseService enterpriseService;
    @Autowired
    IProjectService projectService;
    @Autowired
    private IEnterpriseProjectService enterpriseProjectService;

    @ApiOperation(value = "统计数据")
    @GetMapping
    public Result<IndexRptVO> report() {
        IndexRptVO vo = enterpriseService.rptEnterprise();
        BeanUtil.copyProperties(projectService.rptProject(), vo, "entSumCnt", "entValidCnt", "entExpiredCnt");
        return new Result<IndexRptVO>().ok(vo);
    }

    @ApiOperation(value = "项目统计数据")
    @GetMapping("/project")
    public Result<IndexRptVO> reportTotal() {
        IndexRptVO vo = enterpriseService.rptEnterprise();
        BeanUtil.copyProperties(enterpriseProjectService.rptProject(), vo, "entSumCnt", "entValidCnt", "entExpiredCnt");
        return new Result<IndexRptVO>().ok(vo);
    }

}
