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

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

/**
 * 曲目统计排序类型
 *
 * @author liujunchi
 * @date 2022-04-28
 */
public enum MusicCompareType implements BaseEnum<String, MusicCompareType> {
    TRAIN_DURATION("练习时长", "train_duration_"),
    TRAIN_FREQ("练习次数", "train_frequency_"),
    EVALUATE_DURATION("评测时长", "evaluate_duration_"),
    EVALUATE_FREQ("评测次数", "evaluate_frequency_"),
    ;
    @EnumValue
    private String code;
    private String msg;
    private String sortField;

    MusicCompareType(String msg, String field) {
        this.code = this.name();
        this.msg = msg;
        this.sortField = field;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public String getSortField() {
        return sortField;
    }

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

        MusicCompareType[] values = MusicCompareType.values();

        for (MusicCompareType item : values) {

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

        return true;
    }
}
