短信提交 2021-03-26,增加发送日志

pull/2/head
YunaiV 2021-03-26 01:08:17 +08:00
parent df01bd6c79
commit f3b6783cc3
12 changed files with 256 additions and 195 deletions

View File

@ -1,140 +0,0 @@
package cn.iocoder.dashboard.modules.system.dal.dataobject.sms;
import cn.iocoder.dashboard.common.enums.UserTypeEnum;
import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.dashboard.modules.system.enums.sms.SysSmsSendFailureTypeEnum;
import cn.iocoder.dashboard.modules.system.enums.sms.SysSmsSendStatusEnum;
import cn.iocoder.dashboard.modules.system.enums.sms.SysSmsTemplateTypeEnum;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
import java.util.Map;
/**
*
*
* @author zzf
* @since 2021-01-25
*/
@Data
@EqualsAndHashCode
@Accessors(chain = true)
@TableName(value = "sms_query_log", autoResultMap = true)
public class SysSmsQueryLogDO extends BaseDO {
/**
*
*/
private Long id;
// ========= 渠道相关字段 =========
/**
*
*
* {@link SysSmsChannelDO#getId()}
*/
private Long channelId;
/**
*
*
* {@link SysSmsChannelDO#getCode()}
*/
private String channelCode;
/**
*
*/
private String apiTemplateId;
// ========= 模板相关字段 =========
/**
*
*
* {@link}
*/
private String templateCode;
/**
*
*
* {@link SysSmsTemplateTypeEnum}
*/
private Integer templateType;
/**
* {@link SysSmsTemplateDO#getContent()}
*/
private String templateContent;
/**
* {@link SysSmsTemplateDO#getParams()}
*/
private Map<String, Object> templateParams;
// ========= 手机相关字段 =========
/**
*
*/
private String mobile;
/**
*
*/
private Integer userId;
/**
*
*
* {@link UserTypeEnum}
*/
private Integer userType;
// ========= 发送相关字段 =========
/**
*
*
* {@link SysSmsSendStatusEnum}
*/
private Integer sendStatus;
/**
*
*
* {@link SysSmsSendFailureTypeEnum}
*/
private Integer sendFailureType;
/**
*
*/
private Date sendTime;
/**
* API
*
* 使 String
*/
private String apiSendFailureType;
/**
* API
*/
private String apiSendFailureMsg;
/**
* API ID
*
* API
*/
private String apiRequestId;
/**
* API
*
* API
*/
private String apiSerialNo;
// ========= 接收相关字段 =========
/**
* [0 1]
*/
private Integer gotResult;
}

View File

@ -1,66 +1,148 @@
package cn.iocoder.dashboard.modules.system.dal.dataobject.sms; package cn.iocoder.dashboard.modules.system.dal.dataobject.sms;
import cn.iocoder.dashboard.common.enums.UserTypeEnum;
import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.dashboard.modules.system.enums.sms.SysSmsSendFailureTypeEnum;
import cn.iocoder.dashboard.modules.system.enums.sms.SysSmsSendStatusEnum; import cn.iocoder.dashboard.modules.system.enums.sms.SysSmsSendStatusEnum;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.*;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.Map;
/** /**
* *
* *
* @author zzf * @author zzf
* @since 2021-01-25 * @since 2021-01-25
*/ */
@Data
@EqualsAndHashCode
@Accessors(chain = true)
@TableName(value = "sms_send_log", autoResultMap = true) @TableName(value = "sms_send_log", autoResultMap = true)
public class SysSmsSendLogDO implements Serializable { @Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class SysSmsSendLogDO extends BaseDO {
/** /**
* *
*/ */
private Long id; private Long id;
// ========= 渠道相关字段 =========
/** /**
* () *
*
* {@link SysSmsChannelDO#getId()}
*/
private Long channelId;
/**
*
*
* {@link SysSmsChannelDO#getCode()}
*/ */
private String channelCode; private String channelCode;
/** // ========= 模板相关字段 =========
* id
*/
private Long channelId;
/** /**
* id *
*
* {@link SysSmsTemplateDO#getId()}
*/
private Long templateId;
/**
*
*
* {@link SysSmsTemplateDO#getCode()}
*/ */
private String templateCode; private String templateCode;
/**
*
*
* {@link SysSmsTemplateDO#getType()}
*/
private Integer templateType;
/**
* {@link SysSmsTemplateDO#getContent()}
*/
private String templateContent;
/**
* {@link SysSmsTemplateDO#getParams()}
*/
private Map<String, Object> templateParams;
/**
* API
*
* {@link SysSmsTemplateDO#getApiTemplateId()}
*/
private String apiTemplateId;
// ========= 手机相关字段 =========
/** /**
* *
*/ */
private String phone; private String mobile;
/** /**
* *
*/ */
private String remark; private Long userId;
/**
*
*
* {@link UserTypeEnum}
*/
private Integer userType;
// ========= 发送相关字段 =========
/** /**
* *
* *
* @see SysSmsSendStatusEnum * {@link SysSmsSendStatusEnum}
*/ */
private Integer sendStatus; private Integer sendStatus;
/** /**
* *
*
* {@link SysSmsSendFailureTypeEnum}
*/
private Integer sendFailureType;
/**
*
*/ */
private Date sendTime; private Date sendTime;
/**
* API
*
* 使 String
*/
private String apiSendFailureType;
/**
* API
*/
private String apiSendFailureMsg;
/**
* API ID
*
* API
*/
private String apiRequestId;
/**
* API
*
* API
*/
private String apiSerialNo;
// ========= 接收相关字段 =========
/**
* [0 1]
*/
private Integer gotResult;
} }

View File

@ -0,0 +1,66 @@
package cn.iocoder.dashboard.modules.system.dal.dataobject.sms;
import cn.iocoder.dashboard.modules.system.enums.sms.SysSmsSendStatusEnum;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
*
*
* @author zzf
* @since 2021-01-25
*/
@Data
@EqualsAndHashCode
@Accessors(chain = true)
@TableName(value = "sms_send_log", autoResultMap = true)
public class SysSmsSendLogDOX implements Serializable {
/**
*
*/
private Long id;
/**
* ()
*/
private String channelCode;
/**
* id
*/
private Long channelId;
/**
* id
*/
private String templateCode;
/**
*
*/
private String phone;
/**
*
*/
private String remark;
/**
*
*
* @see SysSmsSendStatusEnum
*/
private Integer sendStatus;
/**
*
*/
private Date sendTime;
}

View File

@ -51,6 +51,8 @@ public class SysSmsTemplateDO extends BaseDO {
private String name; private String name;
/** /**
* *
*
* 使 {} {name}
*/ */
private String content; private String content;
/** /**
@ -62,6 +64,10 @@ public class SysSmsTemplateDO extends BaseDO {
* *
*/ */
private String remark; private String remark;
/**
* API
*/
private String apiTemplateId;
// ========= 渠道相关字段 ========= // ========= 渠道相关字段 =========
@ -77,9 +83,5 @@ public class SysSmsTemplateDO extends BaseDO {
* {@link SysSmsChannelDO#getCode()} * {@link SysSmsChannelDO#getCode()}
*/ */
private String channelCode; private String channelCode;
/**
* API
*/
private String apiTemplateId;
} }

View File

@ -1,7 +1,7 @@
package cn.iocoder.dashboard.modules.system.dal.mysql.sms; package cn.iocoder.dashboard.modules.system.dal.mysql.sms;
import cn.iocoder.dashboard.common.enums.DefaultBitFieldEnum; import cn.iocoder.dashboard.common.enums.DefaultBitFieldEnum;
import cn.iocoder.dashboard.modules.system.dal.dataobject.sms.SysSmsQueryLogDO; import cn.iocoder.dashboard.modules.system.dal.dataobject.sms.SysSmsSendLogDO;
import cn.iocoder.dashboard.modules.system.enums.sms.SysSmsSendStatusEnum; import cn.iocoder.dashboard.modules.system.enums.sms.SysSmsSendStatusEnum;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@ -10,15 +10,15 @@ import org.apache.ibatis.annotations.Mapper;
import java.util.List; import java.util.List;
@Mapper @Mapper
public interface SysSmsQueryLogMapper extends BaseMapper<SysSmsQueryLogDO> { public interface SysSmsQueryLogMapper extends BaseMapper<SysSmsSendLogDO> {
/** /**
* *
*/ */
default List<SysSmsQueryLogDO> selectNoResultQueryLogList() { default List<SysSmsSendLogDO> selectNoResultQueryLogList() {
return this.selectList(new LambdaQueryWrapper<SysSmsQueryLogDO>() return this.selectList(new LambdaQueryWrapper<SysSmsSendLogDO>()
.eq(SysSmsQueryLogDO::getSendStatus, SysSmsSendStatusEnum.QUERY_SUCCESS) .eq(SysSmsSendLogDO::getSendStatus, SysSmsSendStatusEnum.QUERY_SUCCESS)
.eq(SysSmsQueryLogDO::getGotResult, DefaultBitFieldEnum.NO) .eq(SysSmsSendLogDO::getGotResult, DefaultBitFieldEnum.NO)
); );
} }
@ -26,9 +26,9 @@ public interface SysSmsQueryLogMapper extends BaseMapper<SysSmsQueryLogDO> {
/** /**
* APIId * APIId
*/ */
default boolean updateByApiId(SysSmsQueryLogDO queryLogDO, String apiId) { default boolean updateByApiId(SysSmsSendLogDO queryLogDO, String apiId) {
return update(queryLogDO, new LambdaQueryWrapper<SysSmsQueryLogDO>() return update(queryLogDO, new LambdaQueryWrapper<SysSmsSendLogDO>()
.eq(SysSmsQueryLogDO::getApiId, apiId) .eq(SysSmsSendLogDO::getApiId, apiId)
) > 0; ) > 0;
} }
} }

View File

@ -5,8 +5,6 @@ import cn.iocoder.dashboard.framework.sms.core.SmsBody;
import cn.iocoder.dashboard.framework.sms.core.SmsResult; import cn.iocoder.dashboard.framework.sms.core.SmsResult;
import cn.iocoder.dashboard.framework.sms.core.SmsResultDetail; import cn.iocoder.dashboard.framework.sms.core.SmsResultDetail;
import java.util.List;
/** /**
* *
* *
@ -14,6 +12,7 @@ import java.util.List;
* @date 2021/1/25 9:24 * @date 2021/1/25 9:24
*/ */
public interface SysSmsQueryLogService { public interface SysSmsQueryLogService {
/** /**
* *
* *
@ -22,10 +21,6 @@ public interface SysSmsQueryLogService {
* @param client * @param client
* @return id * @return id
*/ */
// TODO FROM 芋艿 to ZZF: async 是针对发送的方式,对于日志不一定需要关心。这样,短信日志,实际就发送前插入,发送后更新结果.
// 这里只用于记录状态,毕竟异步可能推送失败,此时日志可记录该状态。
// TODO FROM 芋艿 to ZZF短信日志群发的情况应该是每个手机一条哈。虽然是群发但是可能部分成功部分失败对应到短信平台实际也是多条。
void beforeSendLog(SmsBody smsBody, String targetPhone, AbstractSmsClient client); void beforeSendLog(SmsBody smsBody, String targetPhone, AbstractSmsClient client);
/** /**

View File

@ -1,5 +1,9 @@
package cn.iocoder.dashboard.modules.system.service.sms; package cn.iocoder.dashboard.modules.system.service.sms;
import cn.iocoder.dashboard.modules.system.dal.dataobject.sms.SysSmsTemplateDO;
import java.util.Map;
/** /**
* *
* *
@ -8,6 +12,9 @@ package cn.iocoder.dashboard.modules.system.service.sms;
*/ */
public interface SysSmsSendLogService { public interface SysSmsSendLogService {
Long createSmsSendLog(String mobile, Long userId, Integer userType,
SysSmsTemplateDO template, String templateContent, Map<String, Object> templateParams);
void getAndSaveSmsSendLog(); void getAndSaveSmsSendLog();
} }

View File

@ -2,6 +2,8 @@ package cn.iocoder.dashboard.modules.system.service.sms;
import cn.iocoder.dashboard.modules.system.dal.dataobject.sms.SysSmsTemplateDO; import cn.iocoder.dashboard.modules.system.dal.dataobject.sms.SysSmsTemplateDO;
import java.util.Map;
/** /**
* Service * Service
* *
@ -18,4 +20,13 @@ public interface SysSmsTemplateService {
*/ */
SysSmsTemplateDO getSmsTemplateByCode(String code); SysSmsTemplateDO getSmsTemplateByCode(String code);
/**
*
*
* @param content
* @param params
* @return
*/
String formatSmsTemplateContent(String content, Map<String, Object> params);
} }

View File

@ -6,7 +6,7 @@ import cn.iocoder.dashboard.framework.sms.core.SmsResult;
import cn.iocoder.dashboard.framework.sms.core.SmsResultDetail; import cn.iocoder.dashboard.framework.sms.core.SmsResultDetail;
import cn.iocoder.dashboard.framework.sms.core.property.SmsChannelProperty; import cn.iocoder.dashboard.framework.sms.core.property.SmsChannelProperty;
import cn.iocoder.dashboard.modules.system.dal.mysql.dao.sms.SysSmsQueryLogMapper; import cn.iocoder.dashboard.modules.system.dal.mysql.dao.sms.SysSmsQueryLogMapper;
import cn.iocoder.dashboard.modules.system.dal.dataobject.sms.SysSmsQueryLogDO; import cn.iocoder.dashboard.modules.system.dal.dataobject.sms.SysSmsSendLogDO;
import cn.iocoder.dashboard.modules.system.enums.sms.SysSmsSendStatusEnum; import cn.iocoder.dashboard.modules.system.enums.sms.SysSmsSendStatusEnum;
import cn.iocoder.dashboard.modules.system.service.sms.SysSmsQueryLogService; import cn.iocoder.dashboard.modules.system.service.sms.SysSmsQueryLogService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -27,7 +27,7 @@ public class SysSmsQueryLogServiceImpl implements SysSmsQueryLogService {
@Override @Override
public void beforeSendLog(SmsBody smsBody, String targetPhone, AbstractSmsClient client) { public void beforeSendLog(SmsBody smsBody, String targetPhone, AbstractSmsClient client) {
SysSmsQueryLogDO smsLog = new SysSmsQueryLogDO(); SysSmsSendLogDO smsLog = new SysSmsSendLogDO();
SmsChannelProperty property = client.getProperty(); SmsChannelProperty property = client.getProperty();
smsLog.setChannelCode(property.getCode()) smsLog.setChannelCode(property.getCode())
@ -43,7 +43,7 @@ public class SysSmsQueryLogServiceImpl implements SysSmsQueryLogService {
@Override @Override
public void afterSendLog(Long logId, SmsResult result) { public void afterSendLog(Long logId, SmsResult result) {
SysSmsQueryLogDO smsLog = new SysSmsQueryLogDO(); SysSmsSendLogDO smsLog = new SysSmsSendLogDO();
smsLog.setId(logId); smsLog.setId(logId);
smsLog.setApiId(result.getApiId()); smsLog.setApiId(result.getApiId());
smsLog.setSendStatus(SysSmsSendStatusEnum.QUERY_FAIL.getStatus()); smsLog.setSendStatus(SysSmsSendStatusEnum.QUERY_FAIL.getStatus());
@ -53,7 +53,7 @@ public class SysSmsQueryLogServiceImpl implements SysSmsQueryLogService {
@Override @Override
public void updateSendLogByResultDetail(SmsResultDetail smsResultDetail) { public void updateSendLogByResultDetail(SmsResultDetail smsResultDetail) {
SysSmsQueryLogDO queryLogDO = new SysSmsQueryLogDO(); SysSmsSendLogDO queryLogDO = new SysSmsSendLogDO();
queryLogDO.setSendStatus(smsResultDetail.getSendStatus()); queryLogDO.setSendStatus(smsResultDetail.getSendStatus());
queryLogDO.setSendTime(smsResultDetail.getSendTime()); queryLogDO.setSendTime(smsResultDetail.getSendTime());
queryLogDO.setRemark(smsResultDetail.getMessage()); queryLogDO.setRemark(smsResultDetail.getMessage());

View File

@ -2,8 +2,9 @@ package cn.iocoder.dashboard.modules.system.service.sms.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.dashboard.framework.sms.client.AbstractSmsClient; import cn.iocoder.dashboard.framework.sms.client.AbstractSmsClient;
import cn.iocoder.dashboard.modules.system.dal.dataobject.sms.SysSmsQueryLogDO;
import cn.iocoder.dashboard.modules.system.dal.dataobject.sms.SysSmsSendLogDO; import cn.iocoder.dashboard.modules.system.dal.dataobject.sms.SysSmsSendLogDO;
import cn.iocoder.dashboard.modules.system.dal.dataobject.sms.SysSmsSendLogDOX;
import cn.iocoder.dashboard.modules.system.dal.dataobject.sms.SysSmsTemplateDO;
import cn.iocoder.dashboard.modules.system.dal.mysql.sms.SysSmsQueryLogMapper; import cn.iocoder.dashboard.modules.system.dal.mysql.sms.SysSmsQueryLogMapper;
import cn.iocoder.dashboard.modules.system.dal.mysql.sms.SysSmsSendLogMapper; import cn.iocoder.dashboard.modules.system.dal.mysql.sms.SysSmsSendLogMapper;
import cn.iocoder.dashboard.modules.system.enums.sms.SysSmsSendStatusEnum; import cn.iocoder.dashboard.modules.system.enums.sms.SysSmsSendStatusEnum;
@ -15,6 +16,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* *
@ -41,18 +43,36 @@ public class SysSmsSendLogServiceImpl implements SysSmsSendLogService {
private static final long SCHEDULER_PERIOD = 5 * 60 * 1000L; private static final long SCHEDULER_PERIOD = 5 * 60 * 1000L;
@Override
public Long createSmsSendLog(String mobile, Long userId, Integer userType,
SysSmsTemplateDO template, String templateContent, Map<String, Object> templateParams) {
SysSmsSendLogDO.SysSmsSendLogDOBuilder logBuilder = SysSmsSendLogDO.builder();
// 设置手机相关字段
logBuilder.mobile(mobile).userId(userId).userType(userType);
// 设置模板相关字段
logBuilder.templateId(template.getId()).templateCode(template.getCode()).templateType(template.getType());
logBuilder.templateContent(templateContent).templateParams(templateParams).apiTemplateId(template.getApiTemplateId());
// 设置渠道相关字段
logBuilder.channelId(template.getChannelId()).channelCode(template.getChannelCode());
// 插入数据库
SysSmsSendLogDO logDO = logBuilder.build();
smsSendLogMapper.insert(logDO);
return logDO.getId();
}
@Override @Override
public void getAndSaveSmsSendLog() { public void getAndSaveSmsSendLog() {
List<SysSmsQueryLogDO> noResultQueryLogList = smsQueryLogMapper.selectNoResultQueryLogList(); List<SysSmsSendLogDO> noResultQueryLogList = smsQueryLogMapper.selectNoResultQueryLogList();
if (CollectionUtil.isEmpty(noResultQueryLogList)) { if (CollectionUtil.isEmpty(noResultQueryLogList)) {
return; return;
} }
//用于添加的发送日志对象 //用于添加的发送日志对象
SysSmsSendLogDO insertSendLog = new SysSmsSendLogDO(); SysSmsSendLogDOX insertSendLog = new SysSmsSendLogDOX();
//用于修改状态的请求日志对象 //用于修改状态的请求日志对象
SysSmsQueryLogDO updateQueryLog = new SysSmsQueryLogDO(); SysSmsSendLogDO updateQueryLog = new SysSmsSendLogDO();
noResultQueryLogList.forEach(queryLog -> { noResultQueryLogList.forEach(queryLog -> {
AbstractSmsClient smsClient = smsChannelService.getSmsClient(queryLog.getTemplateCode()); AbstractSmsClient smsClient = smsChannelService.getSmsClient(queryLog.getTemplateCode());
@ -94,7 +114,7 @@ public class SysSmsSendLogServiceImpl implements SysSmsSendLogService {
}); });
} }
private void queryLog2SendLong(SysSmsSendLogDO insertSendLog, SysSmsQueryLogDO queryLog) { private void queryLog2SendLong(SysSmsSendLogDOX insertSendLog, SysSmsSendLogDO queryLog) {
insertSendLog.setChannelCode(queryLog.getChannelCode()); insertSendLog.setChannelCode(queryLog.getChannelCode());
insertSendLog.setChannelId(queryLog.getChannelId()); insertSendLog.setChannelId(queryLog.getChannelId());
insertSendLog.setTemplateCode(queryLog.getTemplateCode()); insertSendLog.setTemplateCode(queryLog.getTemplateCode());

View File

@ -11,10 +11,7 @@ import cn.iocoder.dashboard.framework.sms.core.SmsResultDetail;
import cn.iocoder.dashboard.modules.system.dal.dataobject.sms.SysSmsTemplateDO; import cn.iocoder.dashboard.modules.system.dal.dataobject.sms.SysSmsTemplateDO;
import cn.iocoder.dashboard.modules.system.dal.dataobject.user.SysUserDO; import cn.iocoder.dashboard.modules.system.dal.dataobject.user.SysUserDO;
import cn.iocoder.dashboard.modules.system.mq.producer.sms.SmsSendStreamProducer; import cn.iocoder.dashboard.modules.system.mq.producer.sms.SmsSendStreamProducer;
import cn.iocoder.dashboard.modules.system.service.sms.SysSmsChannelService; import cn.iocoder.dashboard.modules.system.service.sms.*;
import cn.iocoder.dashboard.modules.system.service.sms.SysSmsQueryLogService;
import cn.iocoder.dashboard.modules.system.service.sms.SysSmsService;
import cn.iocoder.dashboard.modules.system.service.sms.SysSmsTemplateService;
import cn.iocoder.dashboard.modules.system.service.user.SysUserService; import cn.iocoder.dashboard.modules.system.service.user.SysUserService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -40,6 +37,9 @@ public class SysSmsServiceImpl implements SysSmsService {
@Resource @Resource
private SysSmsTemplateService smsTemplateService; private SysSmsTemplateService smsTemplateService;
@Resource
private SysSmsSendLogService smsSendLogService;
@Resource @Resource
private SysUserService userService; private SysUserService userService;
@ -63,7 +63,13 @@ public class SysSmsServiceImpl implements SysSmsService {
SysSmsTemplateDO template = this.checkSmsTemplateValid(templateCode, templateParams); SysSmsTemplateDO template = this.checkSmsTemplateValid(templateCode, templateParams);
// 校验手机号码是否存在 // 校验手机号码是否存在
mobile = this.checkMobile(mobile, userId, userType); mobile = this.checkMobile(mobile, userId, userType);
//
// 创建发送日志
String content = smsTemplateService.formatSmsTemplateContent(template.getContent(), templateParams);
Long sendLogId = smsSendLogService.createSmsSendLog(mobile, userId, userType, template, content, templateParams);
// 发送 MQ 消息
} }
@Override @Override
@ -73,6 +79,11 @@ public class SysSmsServiceImpl implements SysSmsService {
SysSmsTemplateDO template = this.checkSmsTemplateValid(templateCode, templateParams); SysSmsTemplateDO template = this.checkSmsTemplateValid(templateCode, templateParams);
} }
@Override
public void doSendSms() {
}
private SysSmsTemplateDO checkSmsTemplateValid(String templateCode, Map<String, Object> templateParams) { private SysSmsTemplateDO checkSmsTemplateValid(String templateCode, Map<String, Object> templateParams) {
// 短信模板不存在 // 短信模板不存在
SysSmsTemplateDO template = smsTemplateService.getSmsTemplateByCode(templateCode); SysSmsTemplateDO template = smsTemplateService.getSmsTemplateByCode(templateCode);

View File

@ -1,11 +1,13 @@
package cn.iocoder.dashboard.modules.system.service.sms.impl; package cn.iocoder.dashboard.modules.system.service.sms.impl;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.dashboard.modules.system.dal.dataobject.sms.SysSmsTemplateDO; import cn.iocoder.dashboard.modules.system.dal.dataobject.sms.SysSmsTemplateDO;
import cn.iocoder.dashboard.modules.system.dal.mysql.sms.SysSmsTemplateMapper; import cn.iocoder.dashboard.modules.system.dal.mysql.sms.SysSmsTemplateMapper;
import cn.iocoder.dashboard.modules.system.service.sms.SysSmsTemplateService; import cn.iocoder.dashboard.modules.system.service.sms.SysSmsTemplateService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Map;
/** /**
* Service * Service
@ -24,4 +26,9 @@ public class SysSmsTemplateServiceImpl implements SysSmsTemplateService {
return smsTemplateMapper.selectOneByCode(code); return smsTemplateMapper.selectOneByCode(code);
} }
@Override
public String formatSmsTemplateContent(String content, Map<String, Object> params) {
return StrUtil.format(content, params);
}
} }