package com.dsk.system.dskService;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.dsk.common.core.domain.R;
import com.dsk.common.core.domain.model.*;
import com.dsk.common.core.page.TableDataInfo;
import com.dsk.common.dtos.Page;
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.ArrayList;
import java.util.List;
import java.util.Map;

import static com.dsk.common.utils.PageUtils.startPage;

@Service
public class EnterpriseCreditService {

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

    @Autowired
    private DskOpenApiUtil dskOpenApiUtil;


    public TableDataInfo penalizePage(EnterpriseCreditPenalizePageBody body) throws Exception {
        if (body.isVaildCid()) return new TableDataInfo(new ArrayList<>(), 0);
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterpriseCredit/penalizePage", BeanUtil.beanToMap(body, false, false));
        return dskOpenApiUtil.responsePage(map);
    }


    public R penalizeReasonType(EnterpriseCreditPenalizeReasonTypeBody body) throws Exception {
        if (body.isVaildCid()) return R.ok();
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterpriseCredit/penalizeReasonType", BeanUtil.beanToMap(body, false, false));
        return BeanUtil.toBean(map, R.class);
    }


    public TableDataInfo abnormalPage(EnterpriseCreditAbnormalPageBody body) throws Exception {
        if (body.isVaildCid()) return new TableDataInfo(new ArrayList<>(), 0);
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterpriseCredit/abnormalPage", BeanUtil.beanToMap(body, false, false));
        return dskOpenApiUtil.responsePage(map);
    }


    public R abnormalYears(EnterpriseCreditAbnormalYearsBody body) throws Exception {
        if (body.isVaildCid()) return R.ok();
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterpriseCredit/abnormalYears", BeanUtil.beanToMap(body, false, false));
        return BeanUtil.toBean(map, R.class);
    }


    public TableDataInfo executedPersonsPage(EnterpriseCreditExecutedPersonsPageBody body) throws Exception {
        if (body.isVaildCid()) return new TableDataInfo(new ArrayList<>(), 0);
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterpriseCredit/executedPersonsPage", BeanUtil.beanToMap(body, false, false));
        return dskOpenApiUtil.responsePage(map);
    }


    public TableDataInfo executedPage(EnterpriseCreditExecutedPageBody body) throws Exception {
        if (body.isVaildCid()) return new TableDataInfo(new ArrayList<>(), 0);
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterpriseCredit/executedPage", BeanUtil.beanToMap(body, false, false));
        return dskOpenApiUtil.responsePage(map);
    }


    public TableDataInfo lawsuitsPage(EnterpriseCreditLawsuitsPageBody body) throws Exception {
        if (body.isVaildCid()) return new TableDataInfo(new ArrayList<>(), 0);
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterpriseCredit/lawsuitsPage", BeanUtil.beanToMap(body, false, false));
        return dskOpenApiUtil.responsePage(map);
    }


    public R lawsuitsCauseAction(EnterpriseCreditLawsuitsCauseActionBody body) throws Exception {
        if (body.isVaildCid()) return R.ok();
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterpriseCredit/lawsuitsCauseAction", BeanUtil.beanToMap(body, false, false));
        return BeanUtil.toBean(map, R.class);
    }


    public R lawsuitsRole(EnterpriseCreditLawsuitsRoleBody body) throws Exception {
        if (body.isVaildCid()) return R.ok();
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterpriseCredit/lawsuitsRole", BeanUtil.beanToMap(body, false, false));
        return BeanUtil.toBean(map, R.class);
    }


    public TableDataInfo noticesPage(EnterpriseCreditNoticePageBody body) throws Exception {
        if (body.isVaildCid()) return new TableDataInfo(new ArrayList<>(), 0);
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterpriseCredit/noticesPage", BeanUtil.beanToMap(body, false, false));
        return dskOpenApiUtil.responsePage(map);
    }


    public R noticesType(EnterpriseCreditNoticeTypeBody body) throws Exception {
        if (body.isVaildCid()) return R.ok();
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterpriseCredit/noticesType", BeanUtil.beanToMap(body, false, false));
        return BeanUtil.toBean(map, R.class);
    }


    public R noticesRole(EnterpriseCreditNoticeRoleBody body) throws Exception {
        if (body.isVaildCid()) return R.ok();
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterpriseCredit/noticesRole", BeanUtil.beanToMap(body, false, false));
        return BeanUtil.toBean(map, R.class);
    }


    public R noticesCaseReason(EnterpriseCreditNoticeCaseReasonBody body) throws Exception {
        if (body.isVaildCid()) return R.ok();
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterpriseCredit/noticesCaseReason", BeanUtil.beanToMap(body, false, false));
        return BeanUtil.toBean(map, R.class);
    }


    public TableDataInfo kaitingPage(EnterpriseCreditKaitingPageBody body) throws Exception {
        if (body.isVaildCid()) return new TableDataInfo(new ArrayList<>(), 0);
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterpriseCredit/kaitingPage", BeanUtil.beanToMap(body, false, false));
        return dskOpenApiUtil.responsePage(map);
    }


    public R kaitingCauseAction(EnterpriseCreditKaitingCauseActionBody body) throws Exception {
        if (body.isVaildCid()) return R.ok();
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterpriseCredit/kaitingCauseAction", BeanUtil.beanToMap(body, false, false));
        return BeanUtil.toBean(map, R.class);
    }


    public R kaitingPureRole(EnterpriseCreditKaitingPureRoleBody body) throws Exception {
        if (body.isVaildCid()) return R.ok();
        Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterpriseCredit/kaitingPureRole", BeanUtil.beanToMap(body, false, false));
        return BeanUtil.toBean(map, R.class);
    }
}
