package com.dsk.system.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.dsk.common.core.domain.AjaxResult;
import com.dsk.common.dtos.OpRegionalEconomicDataV1Dto;
import com.dsk.common.dtos.OpRegionalEconomicDataV1PageDto;
import com.dsk.common.utils.DskOpenApiUtil;
import com.dsk.system.service.EconomicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName EconomicServiceImpl
 * @Description 经济大全实现
 * @Author Dgm
 * @Date 2023/5/18 10:23
 * @Version
 */
@Service
public class EconomicServiceImpl implements EconomicService {

    @Autowired
    private DskOpenApiUtil dskOpenApiUtil;

    @Override
    public AjaxResult nationalPage(OpRegionalEconomicDataV1PageDto dto) {
        Map<String, Object> map = dskOpenApiUtil.requestBody("/economic/national/nationalPage",  BeanUtil.beanToMap(dto, false, false));
        return BeanUtil.toBean(map, AjaxResult.class);
    }

    @Override
    public AjaxResult details(Integer id) {
        Map<String, Object> bodyMap = new HashMap<>(1);
        bodyMap.put("id", id);
        Map<String, Object> map = dskOpenApiUtil.requestBody("/economic/details", bodyMap);
        return BeanUtil.toBean(map, AjaxResult.class);
    }

    @Override
    public AjaxResult statisticsRegional(OpRegionalEconomicDataV1Dto dto) {
        Map<String, Object> map = dskOpenApiUtil.requestBody("/economic/statistics/regional",  BeanUtil.beanToMap(dto, false, false));
        return BeanUtil.toBean(map, AjaxResult.class);
    }

    @Override
    public AjaxResult regionalList(OpRegionalEconomicDataV1Dto dto) {
        Map<String, Object> map = dskOpenApiUtil.requestBody("/economic/regional/list",  BeanUtil.beanToMap(dto, false, false));
        return BeanUtil.toBean(map, AjaxResult.class);
    }

    @Override
    public AjaxResult regionalComparison(OpRegionalEconomicDataV1Dto dto) {
        Map<String, Object> map = dskOpenApiUtil.requestBody("/economic/xx",  BeanUtil.beanToMap(dto, false, false));
        return BeanUtil.toBean(map, AjaxResult.class);
    }

}
