package jnpf.enums.attendance;

import lombok.Getter;

import java.util.Objects;

/**
 * 出勤类型(1: 普班, 2: 休, 3: 假, 4: 加班)
 */
@Getter
public enum AttendanceTypeEnum {
    DEFAULT(-1, "default", "match_default"),
    CLEAR(0, "清空", "match_clear"),
    ORDINARY(1, "普班", "match_ordinary"),
    REST(2, "公休", "match_rest"),
    LEAVE(3, "请假", "match_leave"),
    WORKOVERTIME(4, "加班", "match_overtime"),
    HOLIDAYS(5, "假期", "match_holidays"),
    DEDUCTION_HOLIDAYS(6, "假(不计薪假)", "match_deduction"),
    EXCHANGE_HOLIDAYS(7, "假(计薪假)", "match_exchange"),
    SECONDMENT(8, "借调", "match_secondment"),
    BUSINESS_TRIP(9, "出差", "match_business_trip"),
    STEP_OUT(10, "外出", "match_step_out");

    @Getter
    final Integer code;
    final String msg;
    final String name;

    AttendanceTypeEnum(Integer code, String msg, String name) {
        this.code = code;
        this.msg = msg;
        this.name = name;
    }

    public static String getMsg(Integer code) {
        AttendanceTypeEnum[] values = AttendanceTypeEnum.values();
        for (AttendanceTypeEnum value : values) {
            if (Objects.equals(value.getCode(), code)) {
                return value.getMsg();
            }
        }
        return null;
    }

    public static AttendanceTypeEnum getEnum(int code) {
        AttendanceTypeEnum[] values = AttendanceTypeEnum.values();
        for (AttendanceTypeEnum value : values) {
            if (value.getCode() == code) {
                return value;
            }
        }
        return null;
    }
}
