package com.lz.modules.app.enums;

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

/**
 * 短信类型枚举类
 * Created by fumeiai on 2018/10/30.
 */
public enum SmsTypeEnum {

    LZ_LOGIN_VERIFICATION(1, "登陆短信验证码", "LZ_LOGIN_VERIFICATION");

    private Integer code;
    private String name;
    private String templateType;

    private static Map<Integer, SmsTypeEnum> codeRoleTypeMap = null;

    SmsTypeEnum(Integer code, String name, String templateType) {
        this.code = code;
        this.name = name;
        this.templateType = templateType;
    }

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


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


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


    public Integer getCode() {
        return code;
    }

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

    public String getName() {
        return name;
    }

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

	public String getTemplateType() {
		return templateType;
	}

	public void setTemplateType(String templateType) {
		this.templateType = templateType;
	}

}
