Package com.bytedesk.core.sms
Class SmsSendService
java.lang.Object
com.bytedesk.core.sms.SmsSendService
短信发送服务
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate StringformatPhoneNumber(String mobile, String country) 格式化手机号码,处理国家代码private StringgetChineseErrorMessage(String code, String originalMessage) 根据阿里云错误代码返回中文错误信息voidinit()初始化时处理配置项编码问题private StringnormalizeAndValidateMobile(String mobile) private SmsSendResultparseAliyunSmsResponse(String responseData) 解析阿里云短信服务响应booleansendSms(String mobile, String country, String content, jakarta.servlet.http.HttpServletRequest request) 发送短信sendSmsWithResult(String mobile, String country, String content, jakarta.servlet.http.HttpServletRequest request) 发送短信并返回详细结果sendValidateCode(String mobile, String country, String code) 发送验证码
-
Field Details
-
regionId
-
accessKeyId
-
accessKeySecret
-
signName
-
templateCode
-
bytedeskProperties
-
objectMapper
private final com.fasterxml.jackson.databind.ObjectMapper objectMapper
-
-
Constructor Details
-
SmsSendService
public SmsSendService()
-
-
Method Details
-
init
@Autowired public void init()初始化时处理配置项编码问题 -
sendSms
public boolean sendSms(String mobile, String country, String content, jakarta.servlet.http.HttpServletRequest request) 发送短信- Parameters:
mobile- 手机号country- 国家代码content- 短信内容request- HTTP请求- Returns:
- 是否发送成功
-
sendSmsWithResult
public SmsSendResult sendSmsWithResult(String mobile, String country, String content, jakarta.servlet.http.HttpServletRequest request) 发送短信并返回详细结果- Parameters:
mobile- 手机号country- 国家代码content- 短信内容request- HTTP请求- Returns:
- SmsSendResult 发送结果
-
sendValidateCode
发送验证码- Parameters:
mobile- 手机号country- 国家代码code- 验证码- Returns:
- SmsSendResult 发送结果
-
normalizeAndValidateMobile
-
formatPhoneNumber
格式化手机号码,处理国家代码- Parameters:
mobile- 手机号country- 国家代码- Returns:
- 格式化后的手机号
-
parseAliyunSmsResponse
解析阿里云短信服务响应- Parameters:
responseData- 响应JSON数据- Returns:
- SmsSendResult
-
getChineseErrorMessage
根据阿里云错误代码返回中文错误信息- Parameters:
code- 错误代码originalMessage- 原始错误信息- Returns:
- 中文错误信息
-