package org.dromara.common.core.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.dromara.common.core.constant.GlobalConstants;
import org.dromara.common.core.constant.UserConstants;

/**
 * @author sunzexing
 * @version 1.0
 * @title SmsType
 * @description 短信发送类型
 * @create 2024-03-27 10:47
 */
@Getter
@AllArgsConstructor
public enum SmsType {

    MP(1,"公众号登录验证码",2,"temp_dlyzm"),

    SERVICE(2,"服务商登录验证码",2,"temp_dlyzm"),

    AGENT(3,"代理商登录验证码",2,"temp_dlyzm"),

    MERCHANT(4,"商户登录验证码",2,"temp_dlyzm"),

    OPERATORS(5,"运营商登录验证码",2,"temp_dlyzm"),

    PLATFORM(6,"平台登录验证码",2,"temp_dlyzm"),

    RESET_PWD(7,"重置登录密码",2,"temp_czdlmm"),

    RESET_PAY_PWD(8,"重置支付密码",2,"temp_czzfmm"),

    UNIT_OPEN(9,"账号开通",2,"temp_zhkt"),

    PAY(10,"结算支付",2,"temp_zfjs");

    private int iType;

    private String desc;

    private int expireTime;

    private String tempId;

    /**
     * 获取相应角色的登录短信类型
     * @param roleId 角色id
     * @return
     */
    public static SmsType getSmsTypeByRole(long roleId){
        SmsType smsType = null;
        if(roleId == BusRole.MERCHANT.getId()){
            smsType = SmsType.MERCHANT;
        }else if(roleId == BusRole.AGENT.getId()){
            smsType = SmsType.AGENT;
        }else if(roleId== BusRole.PLATFORM.getId()){
            smsType = SmsType.PLATFORM;
        }else if(roleId == BusRole.SERVICE.getId()){
            smsType = SmsType.SERVICE;
        }else if(roleId == BusRole.OPERATOR.getId()){
            smsType = SmsType.OPERATORS;
        }
        return smsType;
    }

    /**
     * 获取缓存key
     * @param phone 手机号
     * @return
     */
    public String getCacheKey(String phone){
        return GlobalConstants.CAPTCHA_CODE_KEY + ":" + getIType() + ":" + phone;
    }
}
