package com.ruoyi.common.enums;

import com.ruoyi.common.exception.ServiceErrorException;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author jubs
 */

@Getter
@AllArgsConstructor
public enum LanguageEnum {
    /**
     * 中文
     */
    CHINESE("chinese", "中文"),
    /**
     * 英文
     */
    ENGLISH("english", "英文"),
    /**
     * 西班牙语
     */
    SPANISH("spanish", "西班牙语"),
    /**
     * 俄语
     */
    RUSSIAN("russia", "俄语"),
    ;

    private final String code;

    private final String name;

    public static LanguageEnum getByLabel(String label) {
        for (LanguageEnum logicOperation : values()) {
            if (logicOperation.getCode().equals(label)) {
                return logicOperation;
            }
        }
        throw new ServiceErrorException("非法的语言:" + label);
    }
}
