package com.dsk.system.dskService;

import cn.hutool.core.bean.BeanUtil;
import com.dsk.common.core.domain.R;
import com.dsk.common.core.domain.model.*;
import com.dsk.common.utils.DskOpenApiUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

/**
 * @ClassName enterpriseService
 * @Description TODO
 * @Author zhangyi
 * @Date 2023/5/15 12:00
 * @Version 1.0
 */
@Service
public class EnterpriseService {

    private static final Logger log = LoggerFactory.getLogger(EnterpriseService.class);

    @Autowired
    private DskOpenApiUtil dskOpenApiUtil;

    public R infoHeader(EnterpriseInfoHeaderBody body) throws Exception {
        Map<String, Object> map = dskOpenApiUtil.requestBody("/api/jsk/enterprise/infoHeader", BeanUtil.beanToMap(body, false, false));
        return BeanUtil.toBean(map, R.class);
    }

    public R statistic(EnterpriseStatisticBody body) throws Exception {
        Map<String, Object> map = dskOpenApiUtil.requestBody("/api/jsk/enterprise/statistic", BeanUtil.beanToMap(body, false, false));
        return BeanUtil.toBean(map, R.class);
    }

    public R bidDataGroup(EnterpriseBidDataGroupBody body) throws Exception {
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterprise/bidDataGroup", BeanUtil.beanToMap(body, false, false));
        return BeanUtil.toBean(map, R.class);
    }

    public R supplierPage(EnterpriseSupplierPageBody body) throws Exception {
        Map<String, String> headerMap = new HashMap<>();
        headerMap.put("Api-Version", "1.0");
        Map<String, Object> map = dskOpenApiUtil.requestBodyWithHeader("/api/jsk/enterpriseBusiness/selectPageSupplierInfo", BeanUtil.beanToMap(body, false, false), headerMap);
        return BeanUtil.toBean(map, R.class);
    }

    public R projectTenderDataGroup(EnterpriseProjectTenderDataGroupBody body) throws Exception {
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterprise/projectTenderDataGroup", BeanUtil.beanToMap(body, false, false));
        return BeanUtil.toBean(map, R.class);
    }

    //todo 新数据，待入库
    public R partners(EnterprisePartnersBody body) throws Exception {
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterprise/partners", BeanUtil.beanToMap(body, false, false));
        return BeanUtil.toBean(map, R.class);
    }

    public R investment(EnterpriseInvestmentBody body) throws Exception {
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterprise/investment", BeanUtil.beanToMap(body, false, false));
        return BeanUtil.toBean(map, R.class);
    }

    public R affiliates(EnterpriseAffiliatesBody body) throws Exception {
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterprise/affiliates", BeanUtil.beanToMap(body, false, false));
        return BeanUtil.toBean(map, R.class);
    }

    public R bidNoticePage(EnterpriseBidNoticePageBody body) throws Exception {
        Map<String, String> headerMap = new HashMap<>();
        headerMap.put("Api-Version", "1.0");
        Map<String, Object> map = dskOpenApiUtil.requestBodyWithHeader("/api/jsk/enterpriseBusiness/selectPageBidNoticeInfo", BeanUtil.beanToMap(body, false, false), headerMap);
        return BeanUtil.toBean(map, R.class);
    }

    public R dynamicPage(EnterpriseDynamicPageBody body) throws Exception {
        Map<String, Object> map = dskOpenApiUtil.requestBody("/api/jsk/enterprise/dynamic", BeanUtil.beanToMap(body, false, false));
        return BeanUtil.toBean(map, R.class);
    }

    public R icInfo(EnterpriseIcInfoBody body) throws Exception {
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterprise/icInfo", BeanUtil.beanToMap(body, false, false));
        return BeanUtil.toBean(map, R.class);
    }

    public R changeInfo(EnterpriseChangeInfoBody body) throws Exception {
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterprise/changeInfo", BeanUtil.beanToMap(body, false, false));
        return BeanUtil.toBean(map, R.class);
    }

    public R keymembers(EnterpriseKeymembersBody body) throws Exception {
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterprise/keymembers", BeanUtil.beanToMap(body, false, false));
        return BeanUtil.toBean(map, R.class);
    }
}
