package com.goafanti.common.enums;

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

public enum AttachmentType {
	DEMAND_PICTURE("demand_picture", "科技需求图片资料"),
	DEFAULT("attachment", "附件"),
	DEMAND_COVER_PICTURE("demand_cover_picture","科技需求封面图"),
	ACHIEVEMENT_PICTURE("achievement_picture", "科技成果技术图片"),
	ACHIEVEMENT_COVER_PICTURE("achievement_cover_picture","科技成果封面图"),
	DEMAND_TEMPLATE("demand_template", "科技需求批量导入模板"),
	ACHIEVEMENT_TEMPLATE("achievement_template", "科技成果批量导入模板"),
	BANNERS_PIC("banners", "广告图片"),
	NEWS_TITLE_PICTURE("news_title_picture", "新闻题图图片"),
	NEWS_CONTENT_PICTURE("news_content_picture", "新闻内容图片");
	
	private AttachmentType(String code, String desc) {
		this.code = code;
		this.desc = desc;
	}

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

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

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

	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;
	}
}
