package com.malk.server.fxiaoke;

import cn.hutool.core.util.ObjectUtil;
import com.malk.utils.UtilHttp;
import com.malk.server.common.McException;
import com.malk.server.common.VenR;
import lombok.Data;
import lombok.NoArgsConstructor;

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

/**
 * 返回值配置参考McR
 */
@Data
@NoArgsConstructor
public class FXXR extends VenR {

    private String errorCode;

    private String errorMessage;

    private String errorDescription;

    /**
     * token 接口
     */
    private String corpAccessToken;
    private int expiresIn;

    /**
     * 员工信息
     */
    private List<Map> empList;

    /**
     * 外勤数据
     */
    private List<Map> datas;

    // 成功状态标记
    private final static String SUC_CODE = "0";

    /**
     * 断言错误信息
     */
    @Override
    public void assertSuccess() {
        McException.assertException(ObjectUtil.isNotNull(errorCode) && !errorCode.equals(SUC_CODE), errorCode, errorDescription, "fxiaoke");
    }

    /**
     * 通用post请求
     */
    public static FXXR doPost(String url, Map header, Map param, Map body) {
        return (FXXR) UtilHttp.doPost(url, header, param, body, FXXR.class);
    }

    /**
     * 通用get请求
     */
    public static FXXR doGet(String url, Map header, Map param) {
        return (FXXR) UtilHttp.doGet(url, header, param, FXXR.class);
    }
}

