package com.jsowell.common.enums.thirdparty;

import com.jsowell.common.util.StringUtils;

/**
 * 第三方平台 type operatorId 对应枚举
 *
 * @author Lemon
 * @Date 2023/11/8 9:11:55
 */
public enum ThirdPartyOperatorIdEnum {
    LIAN_LIAN_PLATFORM("1", "425010765"),
    ZHONG_DIAN_LIAN_PLATFORM("2", "14405899X"),
    JIANG_SU_PLATFORM("3", "726079387"),
    YONG_CHENG_BO_CHE("4", "330205020"),
    NING_XIA_JIAO_TOU("5", "MA771QENX"),
    XIN_DIAN_TU("6", "MA25CNM38"),
    HAI_NAN_1("7", "578725200"),
    HAI_NAN_2("8", "MAA9A0PP1"),
    HUA_WEI("9", "MA5GTQ528"),
    ;
    private String type;

    private String operatorId;

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getOperatorId() {
        return operatorId;
    }

    public void setOperatorId(String operatorId) {
        this.operatorId = operatorId;
    }

    ThirdPartyOperatorIdEnum(String type, String operatorId) {
        this.type = type;
        this.operatorId = operatorId;
    }

    /**
     * 根据 type 获取 operatorId
     *
     * @param type 编码
     * @return operatorId
     */
    public static String getOperatorIdByType(String type) {
        for (ThirdPartyOperatorIdEnum item : ThirdPartyOperatorIdEnum.values()) {
            if (StringUtils.equals(item.getType(), type)) {
                return item.getOperatorId();
            }
        }
        return null;
    }

    public static String getTypeByOperatorId(String operatorId) {
        for (ThirdPartyOperatorIdEnum item : ThirdPartyOperatorIdEnum.values()) {
            if (StringUtils.equals(item.getOperatorId(), operatorId)) {
                return item.getType();
            }
        }
        return null;
    }
}
