package com.kingdee.eas.custom.integration.mdm.enums;

import com.kingdee.eas.custom.integration.mdm.exception.MdmErrorCodes;
import com.kingdee.eas.custom.integration.mdm.exception.MdmIntegrationException;

/**
 * MDM 实体枚举，封装 BOS 类型标识。新增实体只需加一个枚举值。
 */
public enum MdmEntityEnum {

    COST_CENTER("CostCenter", "579A1746"),
    DEV_PROJECT("DevProject", "99390A08"),
    ACCOUNT_ENTITY("AccountEntity", "8F1D98AA");

    /** 实体标识（用于日志） */
    public final String entityType;
    /** BOS 类型标识 */
    public final String bosType;

    MdmEntityEnum(String entityType, String bosType) {
        this.entityType = entityType;
        this.bosType = bosType;
    }

    /** 根据 bosType 查找枚举值。 */
    public static MdmEntityEnum fromBosType(String bosType) {
        for (MdmEntityEnum e : values()) {
            if (e.bosType.equals(bosType)) {
                return e;
            }
        }
        throw new MdmIntegrationException(MdmErrorCodes.UNSUPPORTED_ENTITY,
                "不支持的 BOS 类型: " + bosType);
    }
}
