package cn.pluss.platform.enums;

import cn.pluss.platform.exception.MsgException;
import cn.pluss.platform.util.StringUtil;
import cn.pluss.platform.yt.YtStatusEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 设备操作类型枚举
 *
 * @author crystal
 * @date 2022/4/2 16:27
 */
@Getter
@AllArgsConstructor
public enum DeviceOperateType {

    IN("00","设备入库"),
    TRANSFER("01","设备划拨"),
    RECEIVE("02","设备接收"),
    BIND("03","设备绑定"),
    UNBIND("04","设备解绑"),
    BUY("05","设备购买");

    private String code;

    private String name;

    /**
     * code转换
     * @param code
     * @return
     */
    public static String getNameByCode(String code) {
        if(StringUtil.isEmpty(code)){
            MsgException.throwException("code为空,状态转换失败");
        }
        DeviceOperateType[] operateTypes = values();
        for (DeviceOperateType ot : operateTypes) {
            if (ot.code.equals(code)) {
                return ot.getName();
            }
        }
        return "";
    }
}
