package com.ruoyi.bst.suit.domain.enums;

import com.ruoyi.common.utils.StringUtils;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum SuitRentalUnit {

    MINUTE("minutes", "分钟", 60),
    HOUR("hours", "小时", 3600),
    DAY("day", "天", 86400);

    private String code;
    private String name;
    private long seconds;

    public static SuitRentalUnit parse(String code) {
        if (StringUtils.isBlank(code )) {
            return null;
        }

        for (SuitRentalUnit unit : SuitRentalUnit.values()) {
            if (unit.getCode().equals(code)) {
                return unit;
            }
        }
        return null;
    }
}
