package com.upyuns.platform.rs.website.type;

/**
 * @ClassName : ItemTypeEnum
 * @Description : 商品类型
 * @Author : jiaoruizhen
 * @Date: 2020-12-24 14:32
 */
public enum  ItemTypeEnum {

	STANDARD_DATA(1, "标准数据"),
	INDUSTRY_INFO(3, "行业应用"),
	IMAGE_STORAGE(2, "影像图库");
	private Integer type;
	private String msg;

	ItemTypeEnum(Integer type, String msg) {
		this.type = type;
		this.msg = msg;
	}

	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}


	public static <T extends ItemTypeEnum> String getType(Integer code, Class<T> t) {
		for (T item : t.getEnumConstants()) {
			if (item.getType().equals(code)) {
				return item.getMsg();
			}
		}
		return "";
	}

	public static ItemTypeEnum getByCode(Integer code) {
		for (ItemTypeEnum v : values()) {
			if (v.getType() == code) {
				return v;
			}
		}
		return null;
	}

	public static String getProductStatusEnum(Integer code) {
		return getType(code, ItemTypeEnum.class);
	}

}
