package com.goafanti.common.enums;

import java.util.HashMap;
import java.util.Map;

public enum KnowledgeBaseFields {
	
	TITLE("title", "标题"),
	PICURL("picUrl", "图片地址"),
	TYPE("type", "产品类型"),
	KEYWORD("keyword", "关键字"),
	SUMMARY("summary", "简介"),
	STATUS("status", "状态"),
	TOP("top", "热门"),
	recomment("recomment", "推荐"),
	OTHER("", "未知参数");

	private KnowledgeBaseFields(String code, String desc) {
		this.code = code;
		this.desc = desc;
	}

	private static Map<String, KnowledgeBaseFields> status = new HashMap<String, KnowledgeBaseFields>();

	static {
		for (KnowledgeBaseFields value : KnowledgeBaseFields.values()) {
			status.put(value.getCode(), value);
		}
	}

	public static KnowledgeBaseFields getField(String code) {
		if (containsType(code)) {
			return status.get(code);
		}
		return OTHER;
	}

	public static String getFieldDesc(String code) {
		return getField(code).getDesc();
	}

	public static boolean containsType(String code) {
		return status.containsKey(code);
	}

	private String	code;
	private String	desc;

	public String getCode() {
		return code;
	}

	public String getDesc() {
		return desc;
	}


}
