package com.dsk.web.controller.search.macroMarket;

import cn.hutool.core.bean.BeanUtil;
import com.dsk.common.core.domain.AjaxResult;
import com.dsk.common.dtos.OpRegionalEconomicDataV1Dto;
import com.dsk.system.domain.OpRegionalEconomicDataV1;
import com.dsk.system.service.EconomicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


/**
 * @ClassName EconomicController
 * @Description 经济大全
 * @Author Dgm
 * @Date 2023/5/18 10:09
 * @Version 1.0.0
 */
@RestController
@RequestMapping(value ="/economic")
public class EconomicController {

    @Autowired
    private EconomicService economicService;

    /***
     *@Description: 全国经济大全分页列表
     *@Param:
     *@return: com.dsk.common.core.domain.AjaxResult
     *@Author: Dgm
     *@date: 2023/5/18 10:29
     */
    @PostMapping("/national/list")
    public AjaxResult nationalList(@RequestBody OpRegionalEconomicDataV1Dto dto) {
//        return economicService.nationalList(dto);
        return new AjaxResult(HttpStatus.OK.value(), "", new OpRegionalEconomicDataV1());
    }

    /***
     *@Description: 全国经济大全详情
     *@Param:
     *@return: com.dsk.common.core.domain.AjaxResult
     *@Author: Dgm
     *@date: 2023/5/18 10:29
     */
    @GetMapping("/details/{id}")
    public AjaxResult details(@PathVariable("id") Integer id) {
//        return economicService.details(id);
        return new AjaxResult(HttpStatus.OK.value(), "", new OpRegionalEconomicDataV1());
    }


    /***
     *@Description: 地区经济-统计
     *@Param:
     *@return: com.dsk.common.core.domain.AjaxResult
     *@Author: Dgm
     *@date: 2023/5/18 10:29
     */
    @PostMapping("/statistics/regional")
    public AjaxResult statisticsRegional(@RequestBody OpRegionalEconomicDataV1Dto dto) {
//        return economicService.regional(dto);
        Map<String, Object> map = BeanUtil.beanToMap(new OpRegionalEconomicDataV1(), false, false);
        // 下属辖区
        map.put("subordinateJurisdiction", 38);
        // 城投平台
        map.put("urbanInvestmentPlatform", 365);
        // 城投平台授信余额
        map.put("creditBalance", 666.66);
        // 城投平台营收账款
        map.put("accountsReceivable", 888.88);
        return new AjaxResult(HttpStatus.OK.value(), "", map);
    }

    /***
     *@Description: 地区经济-主要指标列表
     *@Param:
     *@return: com.dsk.common.core.domain.AjaxResult
     *@Author: Dgm
     *@date: 2023/5/18 10:29
     */
    @PostMapping("/regional/list")
    public AjaxResult regionalList(@RequestBody OpRegionalEconomicDataV1Dto dto) {
//        return economicService.regionalList(dto);
        List<OpRegionalEconomicDataV1> opRegionalEconomicDataV1List= new ArrayList<>(5);

        OpRegionalEconomicDataV1 dataV1 = new OpRegionalEconomicDataV1();
        dataV1.setProvince("重庆");
        dataV1.setYear(2022);
        OpRegionalEconomicDataV1 dataV2 = new OpRegionalEconomicDataV1();
        dataV2.setProvince("重庆");
        dataV2.setYear(2021);
        OpRegionalEconomicDataV1 dataV3 = new OpRegionalEconomicDataV1();
        dataV3.setProvince("重庆");
        dataV3.setYear(2020);
        OpRegionalEconomicDataV1 dataV4 = new OpRegionalEconomicDataV1();
        dataV4.setProvince("重庆");
        dataV4.setYear(2019);
        OpRegionalEconomicDataV1 dataV5 = new OpRegionalEconomicDataV1();
        dataV5.setProvince("重庆");
        dataV5.setYear(2018);

        opRegionalEconomicDataV1List.add(dataV1);
        opRegionalEconomicDataV1List.add(dataV2);
        opRegionalEconomicDataV1List.add(dataV3);
        opRegionalEconomicDataV1List.add(dataV4);
        opRegionalEconomicDataV1List.add(dataV5);

        return new AjaxResult(HttpStatus.OK.value(), "", opRegionalEconomicDataV1List);
    }


}
