package com.yuchen.saas.park.api.enums.inspect;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.nest.springwrap.core.log.exception.ServiceException;

/**
 * @author zhouhanwei
 * @create 2024/4/7 16:00
 */
@Getter
@AllArgsConstructor
public enum WeekEnum {

    /**
     * 周一
     */
    MONDAY("MONDAY", "周一"),
    /**
     * 周二
     */
    TUESDAY("TUESDAY", "周二"),
    /**
     * 周三
     */
    WEDNESDAY("WEDNESDAY", "周三"),
    /**
     * 周四
     */
    THURSDAY("THURSDAY", "周四"),
    /**
     * 周五
     */
    FRIDAY("FRIDAY", "周五"),
    /**
     * 周六
     */
    SATURDAY("SATURDAY", "周六"),
    /**
     * 周日
     */
    SUNDAY("SUNDAY", "周日"),

    ;
    private final String code;

    private final String desc;

    public static String getDescByCode(String code) {
        WeekEnum[] enums = WeekEnum.values();
        for (WeekEnum weekEnum : enums) {
            if (weekEnum.getCode().equals(code)) {
                return weekEnum.desc;
            }
        }
        throw new ServiceException("按每周传值不正确");
    }

    public static WeekEnum getEnumByCode(String code) {
        WeekEnum[] enums = WeekEnum.values();
        for (WeekEnum weekEnum : enums) {
            if (weekEnum.getCode().equals(code)) {
                return weekEnum;
            }
        }
        throw new ServiceException("日期不正确，无法锁定为周几");
    }
}
