短信,support包中对接了阿里云、腾讯云的短信
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;
}
support包中默认提供 AliyunSMSClient、QCloudSMSClient、MockSMSClient。
mock就相当于只在控制台打印。
FwSMSProperties 在Properties中,选择实现类 enable=aliyun 或 qcloud 或 mock
@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());
}