package com.goafanti.common.enums;

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

public enum AdminFields {
	MOBILE("mobile", "登录帐号"),
	NAME("name", " 用户名"),
	PASSWORD("password", "密码"),
	EMAIL("email", "邮箱"),
	PROVINCE("province", "所在省份"),
	OTHER("", "未知参数");
	
	private String	code;
	private String	desc;
	
	private static Map<String, AdminFields> status = new HashMap<String, AdminFields>();
	
	private AdminFields(String code, String desc) {
		this.code = code;
		this.desc = desc;
	}
	
	static {
		for (AdminFields value : AdminFields.values()) {
			status.put(value.getCode(), value);
		}
	}
	
	public static AdminFields 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);
	}
	
	public String getCode() {
		return code;
	}

	public String getDesc() {
		return desc;
	}

}
