package com.goafanti.order.enums;

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

public enum ApprovalNewState {
	/** 非特批 **/
	FTP(0,"非特批"),
	/** 待审核 **/
	DSH(1,"待审核"),
	/** 通过 **/
	TG(2,"通过"),
	/** 驳回 **/
	BH(3,"驳回"),
	/** 无效 **/
	INVALID(10, "INVALID");
	
	private ApprovalNewState(Integer code, String desc) {
		this.code = code;
		this.desc = desc;
	}

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

	static {
		for (ApprovalNewState value : ApprovalNewState.values()) {
			status.put(value.getCode(), value);
		}
	}
	public static String getValueByCode(Integer code){
        for(ApprovalNewState approvalNewState:ApprovalNewState.values()){
            if(code.equals(approvalNewState.getCode())){
                return approvalNewState.getDesc();
            }
        }
        return  null;
    }
	public static ApprovalNewState getStatus(Integer code) {
		if (containsType(code)) {
			return status.get(code);
		}
		return INVALID;
	}
	public static boolean containsType(Integer code) {
		return status.containsKey(code);
	}
	private Integer	code;
	private String	desc;
	public Integer getCode() {
		return code;
	}
	public void setCode(Integer code) {
		this.code = code;
	}
	public String getDesc() {
		return desc;
	}
	public void setDesc(String desc) {
		this.desc = desc;
	}
}
