package jnpf.enums.attendance.v2;

import lombok.Getter;

/**
 * 是否上班边界覆盖枚举
 * 0未覆盖 1加班覆盖 2借调覆盖 3请假覆盖
 */
@Getter
public enum WorkBoundaryCoverageEnum {

    /**
     * 未覆盖
     */
    NOT_COVERED(0, "未覆盖"),

    /**
     * 加班覆盖
     */
    OVERTIME_COVERED(1, "加班覆盖"),

    /**
     * 借调覆盖
     */
    SECONDMENT_COVERED(2, "借调覆盖"),

    /**
     * 请假覆盖
     */
    LEAVE_COVERED(3, "请假覆盖"),

    /** 晚走晚到 */
    LATE_LEAVE_LATE_ARRIVE(4, "晚走晚到");

    private final int code;
    private final String description;

    WorkBoundaryCoverageEnum(int code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 根据code获取枚举值
     *
     * @param code 状态码
     * @return 对应的枚举值，如果未找到返回null
     */
    public static WorkBoundaryCoverageEnum getByCode(int code) {
        for (WorkBoundaryCoverageEnum value : values()) {
            if (value.getCode() == code) {
                return value;
            }
        }
        return null;
    }
}