package com.goafanti.common.enums;

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

import org.apache.commons.lang3.StringUtils;

public enum IdentityProcess {
	
	UNCOMMITTED(0, "未提交审核"),
	COMMITTED(1, "提交审核"),
	UNPAY(2, "审核未打款"),
	PAY(3, "审核已打款"),
	FAIL(4, "审核未通过"),
	SUCCESS(5, "审核通过"),
	OTHER(6, "其他");

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

	private static Map<Integer, IdentityProcess> status = new HashMap<Integer, IdentityProcess>();

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

	public static IdentityProcess getStatus(Integer code) {
		if (containsType(code)) {
			return status.get(code);
		}
		return OTHER;
	}

	public static IdentityProcess getStatus(String code) {
		if (StringUtils.isNumeric(code)) {
			return getStatus(Integer.parseInt(code));
		}
		return OTHER;
	}

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

	private Integer	code;
	private String	desc;

	public Integer getCode() {
		return code;
	}

	public String getDesc() {
		return desc;
	}

}
