修复短信发送问题,使用正确的模板参数格式

This commit is contained in:
wangzhiwei 2026-01-26 15:05:54 +08:00
parent 9d53c5e2de
commit 3f59744aab
1 changed files with 3 additions and 2 deletions

View File

@ -25,6 +25,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.security.NoSuchAlgorithmException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Objects;
import java.util.Random;
@ -635,13 +636,13 @@ public class SysUserServiceImpl implements SysUserService {
log.info("获取短信发送器成功");
// 发送验证码 - 使用模板方式发送避免直接文本发送可能导致的参数缺失
java.util.Map<String, String> params = new java.util.HashMap<>();
LinkedHashMap<String, String> params = new LinkedHashMap<>();
params.put("code", code); // 参数名需要与阿里云模板中的变量名匹配
// 发送短信使用配置文件中定义的模板
// 根据API文档和用户需求使用单个手机号发送的方法sendMessage(String phone, Map<String, String> params)
// 系统会自动从配置中读取template-id
sms.sendMessage(phone, code);
sms.sendMessage(phone, params);
log.info("向手机号 {} 发送验证码:{}", phone, code);
return true;