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

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

/***
 * 老师类型枚举
 * @author liweifan
 * @updateTime 2022/3/23 17:01
 */

public enum TeacherTypeEnum implements BaseEnum<String, TeacherTypeEnum> {
    TOURIST("游客"), ENTRY("认证老师"), MUSICIAN("平台音乐人");
    @EnumValue
    private String code;
    private String msg;

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

    @Override
    public String getCode() {
        return this.name();
    }

    public String getMsg() {
        return msg;
    }

    /***
     * 字符串teacherType判断是否包含
     * @author liweifan
     * @param: teacherType
     * @updateTime 2022/4/7 9:41
     * @return: com.yonge.cooleshow.biz.dal.enums.YesOrNoEnum
     */
    public YesOrNoEnum hasTeacherType(String teacherType) {
        if (StringUtil.isEmpty(teacherType)) {
            return YesOrNoEnum.NO;
        }
        if (teacherType.indexOf(this.getCode()) < 0) {
            return YesOrNoEnum.NO;
        }
        return YesOrNoEnum.YES;
    }

    /***
     * teacherType转字符串
     * @author liweifan
     * @param: entryFlag
     * @param: musicianFlag
     * @updateTime 2022/4/7 9:41
     * @return: java.lang.String
     */
    public static String getTeacherType(YesOrNoEnum entryFlag, YesOrNoEnum musicianFlag) {
        String teacherType = "";
        if (YesOrNoEnum.YES.equals(entryFlag)) {
            teacherType += "," + TeacherTypeEnum.ENTRY.getCode();
        }
        if (YesOrNoEnum.YES.equals(musicianFlag)) {
            teacherType += "," + TeacherTypeEnum.MUSICIAN.getCode();
        }
        if (teacherType.length() > 0) {
            teacherType = teacherType.substring(1);
        }
        return teacherType;
    }
}
