编辑 | blame | 历史 | 原始文档

1. 简介

短信,support包中对接了阿里云、腾讯云的短信

2. 接口

public interface SMSClient {

    public SMSResult sendRegisterVerify(String phone, String verifyCode) throws ServiceException;

    public SMSResult sendBindPhoneVerify(String phone, String verifyCode) throws ServiceException;

    public SMSResult sendResetPasswordVerify(String phone, String verifyCode) throws ServiceException;

    public SMSResult sendAdminLoginVerify(String phone, String verifyCode) throws ServiceException;

}

3. 默认实现

support包中默认提供 AliyunSMSClient、QCloudSMSClient、MockSMSClient。

mock就相当于只在控制台打印。

4. 使用方法

4.1. 开启

FwSMSProperties 在Properties中,选择实现类 enable=aliyun 或 qcloud 或 mock

4.2. 业务中使用

@Autowired
private SMSClient smsClient;
SMSResult smsResult = smsClient.sendRegisterVerify(phone, code);
if (!smsResult.isSucc()) {
    throw new ThirdPartServiceException(smsResult.getMsg(), ExceptionDefinition.ADMIN_VERIFY_CODE_SEND_FAIL.getCode());
}