package com.njcn.gather.system.dictionary.pojo.enums;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import static com.njcn.gather.system.pojo.constant.DictConst.REG_RES_CONTRAST_CODE;
import static com.njcn.gather.system.pojo.constant.DictConst.REG_RES_DIGITAL_CODE;
import static com.njcn.gather.system.pojo.constant.DictConst.REG_RES_SIMULATE_CODE;

/**
 * @author caozehui
 * @data 2024-12-12
 */
@Getter
public enum DictDataEnum {

    /**
     * Key cleanup point: only keep registration-related platform capability
     * types that are still referenced by the retained activation flow.
     */
    DIGITAL("数字式", REG_RES_DIGITAL_CODE),
    SIMULATE("模拟式", REG_RES_SIMULATE_CODE),
    CONTRAST("比对式", REG_RES_CONTRAST_CODE);

    private final String name;
    private final String code;

    DictDataEnum(String name, String code) {
        this.name = name;
        this.code = code;
    }

    public static String getMsgByValue(Integer name) {
        for (DictDataEnum state : DictDataEnum.values()) {
            if (state.getName().equals(name)) {
                return state.getCode();
            }
        }
        return null;
    }

    public static DictDataEnum getDictDataEnumByCode(String code) {
        for (DictDataEnum steadyIndicatorEnum : DictDataEnum.values()) {
            if (StringUtils.equals(code, steadyIndicatorEnum.getCode())) {
                return steadyIndicatorEnum;
            }
        }
        return null;
    }
}
