package com.goafanti.common.enums;

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

import org.apache.commons.lang3.StringUtils;

public enum DemandAuditStatus {
	CREATE(0, "未提交审核草稿"),
	SUBMIT(1, "提交审核"),
	INAUDIT(2, "审核中"),
	AUDITED(3,"审核通过"),
	UNAUDITED(4,"审核未通过"),
	OTHER(5, "其他");

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

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

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

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

	public static DemandAuditStatus 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;
	}
}
