package org.springblade.common.enums;

import lombok.Getter;
import org.springblade.core.log.exception.ServiceException;

/**
 * 订单类型枚举类
 */
@Getter
public enum OrderTypeEnum {
	NORMAL("拼团订单", 1, "grouponOrderServiceImpl");

	private String name;
	private Integer value;
	private String instance;

	OrderTypeEnum(String name, Integer value, String instance) {
		this.name = name;
		this.value = value;
		this.instance = instance;
	}

	public static String getNameByValue(Integer value) {
		for (OrderTypeEnum orderTypeEnum : OrderTypeEnum.values()) {
			if (orderTypeEnum.value.equals(value)) {
				return orderTypeEnum.getName();
			}
		}
		return "未知";
	}

	public static String getInstanceByValue(Integer value) {
		for (OrderTypeEnum orderTypeEnum : OrderTypeEnum.values()) {
			if (orderTypeEnum.value.equals(value)) {
				return orderTypeEnum.getInstance();
			}
		}
		throw new ServiceException("未找到实体对象");
	}
}
