package com.lz.modules.app.enums;

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

/**
 * 短信渠道枚举类
 * Created by wutao on 2018/10/30.
 */
public enum SmsChannelEnum {
	SMS_CHANNEL_DHST("SMS_CHANNEL_DHST", "大汉短信通道", "dhstSmsUtil"),
	SMS_CHANNEL_BABO("SMS_CHANNEL_BABO", "巴卜短信通道", "baBoSmsUtil"),
	SMS_CHANNEL_HXIN("SMS_CHANNEL_HXIN", "华信短信通道", "hXinSmsUtil"),
	SMS_CHANNEL_UNICOM("SMS_CHANNEL_UNICOM", "10018短信通道", "unicomSmsUtil"),
	SMS_CHANNEL_MONITOR("SMS_CHANNEL_MONITOR", "大汉预警短信通道", ""),
	SMS_CHANNEL_XYT("SMS_CHANNEL_XYT", "校验通短信通道", "xytSmsUtil");

	private String code;
	private String name;
	private String utilName;

	private static Map<String,SmsChannelEnum> codeRoleTypeMap = null;

	SmsChannelEnum(String code, String name, String utilName) {
		this.code = code;
		this.name = name;
		this.utilName = utilName;
	}

	public static String findNameByCode(String code) {
		for (SmsChannelEnum roleType : SmsChannelEnum.values()) {
			if (roleType.getCode().equals(code)) {
				return roleType.getName();
			}
		}

		return null;
	}


	public static String findCodeByName(String name) {
		for (SmsChannelEnum roleType : SmsChannelEnum.values()) {
			if (roleType.getName().equals(name)) {
				return roleType.getCode();
			}
		}
		return null;
	}


	public static Map<String,SmsChannelEnum> getCodeRoleTypeMap(){
		if(codeRoleTypeMap != null && codeRoleTypeMap.size() > 0){
			return codeRoleTypeMap;
		}
		codeRoleTypeMap = new HashMap<String, SmsChannelEnum>();
		for(SmsChannelEnum item: SmsChannelEnum.values()){
			codeRoleTypeMap.put(item.getCode(), item);
		}
		return codeRoleTypeMap;
	}

	public static String findUtilNameByCode(String code) {
		for (SmsChannelEnum roleType : SmsChannelEnum.values()) {
			if (roleType.getCode().equals(code)) {
				return roleType.getUtilName();
			}
		}

		return null;
	}


	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUtilName() {
		return utilName;
	}

	public void setUtilName(String utilName) {
		this.utilName = utilName;
	}
}
