package cn.teammodel.common;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 五育枚举
 * @author winter
 * @create 2023-12-14 12:19
 */
public enum FiveEducations {
    VIRTUE("virtue", "德育"),
    INTELLIGENCE("intelligence","智育"),
    SPORTS("sports", "体育"),
    ART("art", "美育"),
    LABOUR("labour", "劳育");

    private final String code;
    private final String name;

    public static List<String> codes() {
        return Arrays.stream(values()).map(FiveEducations::getCode).collect(Collectors.toList());
    }

    /**
    * 根据 name 获取 code
    */
    public static String getCodeByName(String name) {
        FiveEducations fiveEducation = Arrays.stream(values()).filter(item -> item.getName().equals(name)).findFirst().orElse(null);
        String res = null;
        if (fiveEducation != null) {
            res = fiveEducation.getCode();
        }
        return res;
    }

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

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }
}
