package com.yonge.cooleshow.biz.dal.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.yonge.toolset.base.enums.BaseEnum;

/**
 * Description
 *
 * @author liujunchi
 * @date 2022-04-28
 */
public enum ClientEnum implements BaseEnum<String, ClientEnum> {
    TEACHER("平台老师"),
    STUDENT("平台学生"),
    TENANT_STUDENT("机构学生"),
    TENANT_TEACHER("机构老师"),
    ORGANIZATION("机构-小程序"),
    SYSTEM("平台端"),
    WEBSITE("官网"),
    TENANT("机构端"),
    QR_TEACHER("机构老师扫码"),
    ;
    @EnumValue
    private String code;
    private String msg;

    ClientEnum( String msg) {
        this.code = this.name();
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    /**
     * 校验客户端类型合法性
     * @param clientType 客户端类型
     * @return boolean
     */
    public static boolean invalid(String clientType) {

        ClientEnum[] values = ClientEnum.values();

        for (ClientEnum item : values) {

            if (item.getCode().equals(clientType)) {
                return false;
            }
        }

        return true;
    }

    /**
     * 客户端类型匹配
     * @param dataType 数据类型
     * @return boolean
     */
    public boolean match(String dataType) {
        return getCode().equals(dataType);
    }
}
