All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hn.sms.chuangrui.domain.ChuangRuiParam Maven / Gradle / Ivy

There is a newer version: 1.0.18
Show newest version
package com.hn.sms.chuangrui.domain;

import cn.hutool.core.util.StrUtil;
import com.hn.sms.exception.SmsException;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashMap;

/**
 * 描述:
 * 创瑞短信配置
 *
 * @author fei
 *  2019-08-16 09:04
 */
public class ChuangRuiParam extends HashMap {

    private static final String ACCESS_KEY = "accesskey";
    private static final String SECRET = "secret";
    private static final String SIGN = "sign";
    private static final String TEMPLATE_ID = "templateId";
    private static final String MOBILE = "mobile";
    // "content", URLEncoder.encode("先生##9:40##快递公司##1234567", "utf-8")(示例模板:{1}您好,您的订单于{2}已通过{3}发货,运单号{4})
    private static final String CONTENT = "content";

    /**
     * 用户开发key
     *
     * @param accessKey 用户开发key
     */
    public void setAccessKey(String accessKey) {
        super.put(ACCESS_KEY, accessKey);
    }

    /**
     * 用户开发秘钥
     *
     * @param secret 用户开发秘钥
     */
    public void setSecret(String secret) {
        super.put(SECRET, secret);
    }

    /**
     * 签名
     *
     * @param sign 签名
     */
    public void setSign(String sign) {
        super.put(SIGN, sign);
    }

    /**
     * 模板id
     *
     * @param templateId 模板id
     */
    public void setTemplateId(String templateId) {
        super.put(TEMPLATE_ID, templateId);
    }

    /**
     * 手机号
     * @param mobile  手机号
     */
    public void setMobile(String mobile) {
        super.put(MOBILE, mobile);
    }

    /**
     * 验证码
     *
     * @param authCode 验证码
     */
    public void setAuthCode(String authCode) {
        if(StrUtil.isNotBlank(authCode)){
            try {
                authCode = URLEncoder.encode(authCode, "utf-8");
                super.put(CONTENT, authCode);
            } catch (UnsupportedEncodingException e) {
                throw new SmsException("【创瑞】短信内容转换异常");
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy