package com.ruoyi.ibs.enumertion;

import com.fasterxml.jackson.annotation.JsonValue;

public enum CustTypeEnum {
    PERSONAL("个人", "0"),
    ENTERPRISE("企业", "2"),
    MERCHANT("商户", "1");

    private String name;
    private String code;

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

    @JsonValue
    public String getName() {
        return name;
    }

    public String getCode() {
        return code;
    }

    public static CustTypeEnum getByCode(String code) {
        if (code == null) {
            return null;
        }
        for (CustTypeEnum type : CustTypeEnum.values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return null;
    }

    public static CustTypeEnum getByName(String name) {
        if (name == null) {
            return null;
        }
        for (CustTypeEnum type : CustTypeEnum.values()) {
            if (type.getName().equals(name)) {
                return type;
            }
        }
        return null;
    }
}
