package com.xjrsoft.common.enums;

public enum WeekEnum {
    /**
     * 周一
     */
    Monday(1, "周一"),

    /**
     * 周二
     */
    Tuesday(2, "周二"),
    /**
     * 周三
     */
    Wednesday(3, "周三"),
    /**
     * 周四
     */
    Thursday(4, "周四"),
    /**
     * 周五
     */
    Friday(5, "周五"),
    /**
     * 周六
     */
    Saturday(6, "周六"),
    /**
     * 周日
     */
    Sunday(0, "周日");

    final int code;
    final String value;

    public int getCode() {
        return this.code;
    }

    public String getValue() {
        return this.value;
    }

    WeekEnum(final int code, final String message) {
        this.code = code;
        this.value = message;
    }

    public static int getCode(String value) {
        for (WeekEnum c : WeekEnum.values()) {
            if (c.getValue().equals(value)) {
                return c.getCode();
            }
        }
        return 0;
    }
}
