package cn.teammodel.common;

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

/**
 * @author winter
 * @create 2024-02-01 15:30
 */

public enum ChatAppScopeEnum {
    PUBLIC("public", "公共"),
    SCHOOL("school", "学校"),
    PRIVATE("private", "私人");
    private final String code;
    private final String name;
    public static List<String> codes() {
        return Arrays.stream(values()).map(ChatAppScopeEnum::getCode).collect(Collectors.toList());
    }

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

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

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }
}
