package com.dsk.jsk.service;

import cn.hutool.core.bean.BeanUtil;
import com.dsk.common.core.domain.R;
import com.dsk.common.core.page.TableDataInfo;
import com.dsk.jsk.domain.*;
import com.dsk.system.utils.DskOpenApiUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;
/**
 * @ClassName CompanyRelationTableV1Controller
 * @Description
 * @Author Dgm
 * @Date 2023/12/13 11:28
 * @Version
 */
@Slf4j
@Service
public class CompanyRelationTableV1Service {

    @Autowired
    private DskOpenApiUtil dskOpenApiUtil;

    public TableDataInfo page(JskCompanyRelationTableV1Dto dto) throws Exception {
        Map<String, Object> map = null;
        if (dto.getCompanyType().equals(3)) {
            map = dskOpenApiUtil.requestBody("/operate/consultancy/combinePage", BeanUtil.beanToMap(dto, false, false));
        } else {
            map = dskOpenApiUtil.requestBody("/operate/consultancy/page", BeanUtil.beanToMap(dto, false, false));
        }
        return dskOpenApiUtil.responsePage(map);
    }

    public TableDataInfo detailPage(JskCompanyRelationTableV1DetailPageDto dto) throws Exception {
        Map<String, Object> map = null;
        if (dto.getCompanyType().equals(3) || dto.getCompanyType().equals(4)) {
            map = dskOpenApiUtil.requestBody("/operate/consultancy/combineDetailPage", BeanUtil.beanToMap(dto, false, false));
        } else {
            map = dskOpenApiUtil.requestBody("/operate/consultancy/detailPage", BeanUtil.beanToMap(dto, false, false));
        }
        return dskOpenApiUtil.responsePage(map);
    }

    /***
     *@Description: -分页列表-下拉
     *@Param:
     *@return: com.dsk.common.core.domain.AjaxResult
     *@Author: Dgm
     *@date: 2023/5/18 10:29
     */
    public R pageSelect(JskCompanyRelationTableV1Dto dto) throws Exception{
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/consultancy/pageSelect", BeanUtil.beanToMap(dto, false, false));
        return BeanUtil.toBean(map, R.class);
    }

    /***
     *@Description: -分页列表-下拉
     *@Param:
     *@return: com.dsk.common.core.domain.AjaxResult
     *@Author: Dgm
     *@date: 2023/5/18 10:29
     */
    public R statistics(JskCompanyRelationTableV1DetailPageDto dto) throws Exception{
        Map<String, Object> map = null;
        if (dto.getCompanyType().equals(3) || dto.getCompanyType().equals(4)) {
            map = dskOpenApiUtil.requestBody("/operate/consultancy/combineDetail/statistics", BeanUtil.beanToMap(dto, false, false));
        } else {
            map = dskOpenApiUtil.requestBody("/operate/consultancy/statistics", BeanUtil.beanToMap(dto, false, false));
        }
        return BeanUtil.toBean(map, R.class);
    }

    public TableDataInfo combinePage(JskCompanyRelationTableV1Dto dto) throws Exception {
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/consultancy/combineMemberPage", BeanUtil.beanToMap(dto, false, false));
        return dskOpenApiUtil.responsePage(map);
    }
}
