package com.ruoyi.common.constant;

import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;

public class ApplicantType {
	private String typeId;
	private String typeName;
	private String typeCode;

	public static Map<String,ApplicantType>ALL=new LinkedHashMap<String,ApplicantType>();
//	let types = [{
//	    id: '1',
//	    name: '高等院校',
//	    code:'UC'
//	  },{
//	    id: '2',
//	    name: '科研机构',
//	    code:'SRI'
//	  },{
//	      id: '3',
//	      name: '企业',
//	      code:'IME'
//	    },
//	    {
//	      id: '4',
//	      name: '事业单位',
//	      code:'OT'
//	    },
//	    {
//	      id: '5',
//	      name: '个人',
//	      code:'PE'
//	    }];
	
	//原：高等院校--改 ：大专院校
	//原：科研院所--改：科研机构
	//原：事业单位--改：机关团体

	public static ApplicantType UNIVERSITIES=new ApplicantType("1","大专院校","UC");
	public static ApplicantType SCIENTIFIC =new ApplicantType("2","科研机构","SRI");
	public static ApplicantType ENTERPRISE=new ApplicantType("3","企业","IME");
	public static ApplicantType GOVERNMENT=new ApplicantType("4","机关团体","OT");
	public static ApplicantType PERSONAL=new ApplicantType("5","个人","PE");
	
	public static String getAllApplicantTypeIdStr() {
		return "1,2,3,4,5";
	}
	
	public ApplicantType(String typeId, String typeName,String typeCode) {
		this.typeId = typeId;
		this.typeName = typeName;
		this.typeCode=typeCode;
		ALL.put(typeId, this);
	}
	

	public static Collection<ApplicantType>getAll(){
		return ALL.values();
	}
	
	public static ApplicantType getByName(String typeName) {
		if(StringUtils.isBlank(typeName)) {
			return null;
		}
		for(ApplicantType type:ALL.values()) {
			if(type.getTypeName().equals(typeName)) {
				return type;
			}
		}
		return null;
	}
	
	
	public static ApplicantType getByCode(String typeCode) {
		if(StringUtils.isBlank(typeCode)) {
			return null;
		}
		for(ApplicantType type:ALL.values()) {
			if(type.getTypeCode().equals(typeCode)) {
				return type;
			}
		}
		return null;
	}
	
	public static ApplicantType valueOf(String typeId) {
		return ALL.get(typeId);
	}

	public String getTypeCode() {
		return typeCode;
	}

	public void setTypeCode(String typeCode) {
		this.typeCode = typeCode;
	}

	public String getTypeId() {
		return typeId;
	}

	public void setTypeId(String typeId) {
		this.typeId = typeId;
	}

	public String getTypeName() {
		return typeName;
	}

	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}


}
