Commit 04624d3d by 段启岩

短信发送代码更新

parent 5a20fa1b
......@@ -29,13 +29,13 @@ public class OssHelperImpl implements IOssHelper {
}
@Override
public String upload(InputStream ins, String path) throws OssException {
public String upload(InputStream ins, String uploadTo) throws OssException {
try {
PutObjectRequest putObjectRequest = new PutObjectRequest(aliyunProperties.getOss().getBucket(), path, ins);
PutObjectRequest putObjectRequest = new PutObjectRequest(aliyunProperties.getOss().getBucket(), uploadTo, ins);
PutObjectResult result = ossClient.putObject(putObjectRequest);
String baseUrl = aliyunProperties.getOss().getBaseUrl();
String downloadUrl = baseUrl.endsWith("/") ? baseUrl + path : baseUrl + "/" + path;
String downloadUrl = baseUrl.endsWith("/") ? baseUrl + uploadTo : baseUrl + "/" + uploadTo;
return downloadUrl;
} catch (Exception e) {
throw new OssException("文件上传失败", e);
......
......@@ -44,7 +44,7 @@ public class SmsHelperImpl implements ISmsHelper {
@Override
public void sendSms(String templateCode, Map<String, String> templateParam, String... mobiles) throws SmsException {
Assert.notEmpty(mobiles, "请至少传入一个手机号!");
// 将数组形式的手机号列表转换为用逗号分割的手机号字符串
String mobilesStr = Arrays.stream(mobiles).map(mobile -> mobile + ",").collect(Collectors.joining());
mobilesStr = mobilesStr.substring(0, mobilesStr.length() - 1);
......@@ -74,6 +74,10 @@ public class SmsHelperImpl implements ISmsHelper {
}
}
public static void main(String[] args) throws SmsException {
new SmsHelperImpl().sendSms("", Map.of());
}
@Override
public Map<String, String> getTemplateCodeMap() {
return aliyunProperties.getSms().getTemplateCodeMap();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment