package com.fs.hisStore.enums;

/**
 * 统计类型枚举
 **/
public enum StatTypeEnum {
    DAY(1, "日统计"),
    MONTH(2, "月统计"),
    YEAR(3, "年统计"),
    DATE(4, "日期");

    private final Integer code;
    private final String desc;

    StatTypeEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static boolean isValid(Integer code) {
        if (code == null) {
            return false;
        }
        for (StatTypeEnum type : values()) {
            if (type.code.equals(code)) {
                return true;
            }
        }
        return false;
    }

    public static String getAllValidTypes() {
        StringBuilder sb = new StringBuilder();
        for (StatTypeEnum type : values()) {
            sb.append(type.code).append("(").append(type.desc).append(")、");
        }
        return sb.deleteCharAt(sb.length() - 1).toString();
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }
}
