feat(sms): 更新短信模板占位符替换逻辑

- 移除了不再使用的 ArrayList 导入- 从生日短信模板中移除 {称呼} 占位符替换
- 将主题日短信模板中的 {称呼} 替换为 {地址}
- 更新 Specialist 实体类,将 title 字段重命名为 address
- 修改数据库表结构,将 TITLE 字段改为 ADDRESS 并更新注释
- 调整失败短信日志记录中的内容生成逻辑,使用 address 替代 title
master
李一帆 2025-09-25 11:47:01 +08:00
parent a7d890843e
commit 6a82179473
4 changed files with 7 additions and 10 deletions

View File

@ -6,7 +6,7 @@ CREATE TABLE SPECIALIST (
NAME VARCHAR(50) NOT NULL COMMENT '姓名',
POSITION VARCHAR(100) COMMENT '职务',
BIRTHDAY DATE COMMENT '生日',
TITLE VARCHAR(20) COMMENT '称呼',
ADDRESS VARCHAR(20) COMMENT '区域',
PHONE VARCHAR(20) COMMENT '电话号码',
STATUS INT DEFAULT 1 COMMENT '生效状态 1:有效 0:无效',
CREATE_TM DATETIME DEFAULT CURRENT_TIME COMMENT '创建日期'

View File

@ -58,9 +58,9 @@ public class Specialist implements Serializable {
/**
*
*/
@TableField("TITLE")
@ApiModelProperty(value = "称呼")
private String title;
@TableField("ADDRESS")
@ApiModelProperty(value = "区域")
private String address;
/**
*

View File

@ -18,7 +18,6 @@ import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
@ -90,8 +89,7 @@ public class SmsBirthdayServiceImpl extends ServiceImpl<SmsBirthdayMapper, SmsBi
for (Specialist specialist : specialists) {
try {
// 替换模板中的占位符
String content = template.replace("{姓名}", specialist.getName())
.replace("{称呼}", specialist.getTitle() != null ? specialist.getTitle() : "");
String content = template.replace("{姓名}", specialist.getName());
// 创建短信日志记录
SmsLog smsLog = new SmsLog();
@ -125,7 +123,7 @@ public class SmsBirthdayServiceImpl extends ServiceImpl<SmsBirthdayMapper, SmsBi
failedSmsLog.setName(specialist.getName())
.setPhone(specialist.getPhone())
.setContent(template.replace("{name}", specialist.getName())
.replace("{title}", specialist.getTitle() != null ? specialist.getTitle() : ""))
.replace("{title}", specialist.getAddress() != null ? specialist.getAddress() : ""))
.setRemark("生日短信-发送异常: " + e.getMessage())
.setSendTm(new java.util.Date());
smsLogMapper.insert(failedSmsLog);

View File

@ -142,7 +142,6 @@ public class SmsTaskServiceImpl extends ServiceImpl<SmsTaskMapper, SmsTask> impl
try {
// 替换模板中的占位符
String content = template.replace("{姓名}", specialist.getName())
.replace("{称呼}", specialist.getTitle() != null ? specialist.getTitle() : "")
.replace("{主题}", smsTask.getSubjectName());
// 创建短信日志记录
@ -177,7 +176,7 @@ public class SmsTaskServiceImpl extends ServiceImpl<SmsTaskMapper, SmsTask> impl
failedSmsLog.setName(specialist.getName())
.setPhone(specialist.getPhone())
.setContent(template.replace("{姓名}", specialist.getName())
.replace("{称呼}", specialist.getTitle() != null ? specialist.getTitle() : "")
.replace("{称呼}", specialist.getAddress() != null ? specialist.getAddress() : "")
.replace("{主题}", smsTask.getSubjectName()))
.setRemark("主题日短信-" + smsTask.getSubjectName() + "-发送异常: " + e.getMessage())
.setSendTm(new java.util.Date());