短信提交 2021-03-25,调整下短信发送 API

pull/2/head
YunaiV 2021-03-25 00:52:09 +08:00
parent 3acdec965d
commit df01bd6c79
16 changed files with 245 additions and 145 deletions

View File

@ -7,7 +7,7 @@ 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 cn.iocoder.dashboard.framework.sms.core.property.SmsChannelProperty; import cn.iocoder.dashboard.framework.sms.core.property.SmsChannelProperty;
import cn.iocoder.dashboard.modules.system.enums.sms.SmsSendStatusEnum; import cn.iocoder.dashboard.modules.system.enums.sms.SysSmsSendStatusEnum;
import cn.iocoder.dashboard.util.json.JsonUtils; import cn.iocoder.dashboard.util.json.JsonUtils;
import com.aliyuncs.DefaultAcsClient; import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient; import com.aliyuncs.IAcsClient;
@ -131,8 +131,8 @@ public class AliyunSmsClient extends AbstractSmsClient {
public Integer getSendStatus() { public Integer getSendStatus() {
return ((Boolean) sendResultParamMap.get(CallbackField.SUCCESS)) return ((Boolean) sendResultParamMap.get(CallbackField.SUCCESS))
? SmsSendStatusEnum.SEND_SUCCESS.getStatus() ? SysSmsSendStatusEnum.SEND_SUCCESS.getStatus()
: SmsSendStatusEnum.SEND_FAIL.getStatus(); : SysSmsSendStatusEnum.SEND_FAIL.getStatus();
} }
public String getBizId() { public String getBizId() {

View File

@ -9,7 +9,7 @@ import cn.iocoder.dashboard.framework.sms.core.SmsConstants;
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 cn.iocoder.dashboard.framework.sms.core.property.SmsChannelProperty; import cn.iocoder.dashboard.framework.sms.core.property.SmsChannelProperty;
import cn.iocoder.dashboard.modules.system.enums.sms.SmsSendStatusEnum; import cn.iocoder.dashboard.modules.system.enums.sms.SysSmsSendStatusEnum;
import cn.iocoder.dashboard.util.json.JsonUtils; import cn.iocoder.dashboard.util.json.JsonUtils;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.yunpian.sdk.YunpianClient; import com.yunpian.sdk.YunpianClient;
@ -155,8 +155,8 @@ public class YunpianSmsClient extends AbstractSmsClient {
private static int getSendStatus(Map<String, String> map) { private static int getSendStatus(Map<String, String> map) {
String reportStatus = map.get(REPORT_STATUS); String reportStatus = map.get(REPORT_STATUS);
return SmsConstants.SUCCESS.equals(reportStatus) return SmsConstants.SUCCESS.equals(reportStatus)
? SmsSendStatusEnum.SEND_SUCCESS.getStatus() ? SysSmsSendStatusEnum.SEND_SUCCESS.getStatus()
: SmsSendStatusEnum.SEND_FAIL.getStatus(); : SysSmsSendStatusEnum.SEND_FAIL.getStatus();
} }
public static SmsResultDetail getSmsResultDetailByParam(Map<String, String> map) { public static SmsResultDetail getSmsResultDetailByParam(Map<String, String> map) {

View File

@ -1,5 +1,6 @@
package cn.iocoder.dashboard.framework.sms.core; package cn.iocoder.dashboard.framework.sms.core;
import cn.iocoder.dashboard.modules.system.enums.sms.SysSmsSendStatusEnum;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
@ -17,7 +18,7 @@ public class SmsResultDetail implements Serializable {
private String apiId; private String apiId;
/** /**
* {@link cn.iocoder.dashboard.modules.system.enums.sms.SmsSendStatusEnum} * {@link SysSmsSendStatusEnum}
*/ */
private Integer sendStatus; private Integer sendStatus;

View File

@ -1,15 +1,20 @@
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.SysSmsTemplateTypeEnum;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; 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
@ -18,73 +23,118 @@ import java.util.Date;
@EqualsAndHashCode @EqualsAndHashCode
@Accessors(chain = true) @Accessors(chain = true)
@TableName(value = "sms_query_log", autoResultMap = true) @TableName(value = "sms_query_log", autoResultMap = true)
public class SysSmsQueryLogDO implements Serializable { public class SysSmsQueryLogDO extends BaseDO {
/** /**
* *
*/ */
private Long id; private Long id;
/** // ========= 渠道相关字段 =========
*
*/
private String apiId;
/** /**
* () *
*/ *
private String channelCode; * {@link SysSmsChannelDO#getId()}
/**
* id
*/ */
private Long channelId; private Long channelId;
/**
*
*
* {@link SysSmsChannelDO#getCode()}
*/
private String channelCode;
/**
*
*/
private String apiTemplateId;
// ========= 模板相关字段 =========
/** /**
* id *
*
* {@link}
*/ */
private String templateCode; private String templateCode;
/**
*
*
* {@link SysSmsTemplateTypeEnum}
*/
private Integer templateType;
/**
* {@link SysSmsTemplateDO#getContent()}
*/
private String templateContent;
/**
* {@link SysSmsTemplateDO#getParams()}
*/
private Map<String, Object> templateParams;
// ========= 手机相关字段 =========
/** /**
* *
*/ */
private String phone; private String mobile;
/** /**
* *
*/ */
private String content; private Integer userId;
/**
*
*
* {@link UserTypeEnum}
*/
private Integer userType;
// ========= 发送相关字段 =========
/** /**
* *
* *
* @see cn.iocoder.dashboard.modules.system.enums.sms.SmsSendStatusEnum * {@link SysSmsSendStatusEnum}
*/ */
private Integer sendStatus; 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] * [0 1]
*/ */
private Integer gotResult; private Integer gotResult;
/**
*
*/
private String remark;
/**
*
*/
private String createBy;
/**
*
*/
private Date createTime;
/**
*
*/
private Date sendTime;
} }

View File

@ -1,6 +1,6 @@
package cn.iocoder.dashboard.modules.system.dal.dataobject.sms; package cn.iocoder.dashboard.modules.system.dal.dataobject.sms;
import cn.iocoder.dashboard.modules.system.enums.sms.SmsSendStatusEnum; 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.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -54,7 +54,7 @@ public class SysSmsSendLogDO implements Serializable {
/** /**
* *
* *
* @see SmsSendStatusEnum * @see SysSmsSendStatusEnum
*/ */
private Integer sendStatus; private Integer sendStatus;

View File

@ -2,6 +2,7 @@ package cn.iocoder.dashboard.modules.system.dal.dataobject.sms;
import cn.iocoder.dashboard.common.enums.CommonStatusEnum; import cn.iocoder.dashboard.common.enums.CommonStatusEnum;
import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.dashboard.modules.system.enums.sms.SysSmsTemplateTypeEnum;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
@ -26,62 +27,59 @@ public class SysSmsTemplateDO extends BaseDO {
*/ */
private Long id; private Long id;
/** // ========= 模板相关字段 =========
* ()
*/
private String channelCode;
/** /**
* id () *
*/ *
private Long channelId; * {@link SysSmsTemplateTypeEnum}
/**
* [0 1 2广 3/]
*/ */
private Integer type; private Integer type;
/**
* (, )
*/
private String bizCode;
/**
*
*/
private String code;
/**
*
*/
private String name;
/**
*
*/
private String apiTemplateId;
/**
*
*/
private String content;
/**
* ()
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private List<String> params;
/**
*
*/
private String remark;
/** /**
* *
* *
* {@link CommonStatusEnum} * {@link CommonStatusEnum}
*/ */
private Integer status; private Integer status;
/**
*
*/
private String code;
/**
*
*/
private String name;
/**
*
*/
private String content;
/**
* ()
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private List<String> params;
/**
*
*/
private String remark;
// ========= 渠道相关字段 =========
/**
*
*
* {@link SysSmsChannelDO#getId()}
*/
private Long channelId;
/**
*
*
* {@link SysSmsChannelDO#getCode()}
*/
private String channelCode;
/**
* API
*/
private String apiTemplateId;
} }

View File

@ -2,7 +2,7 @@ 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.SysSmsQueryLogDO;
import cn.iocoder.dashboard.modules.system.enums.sms.SmsSendStatusEnum; 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;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -17,7 +17,7 @@ public interface SysSmsQueryLogMapper extends BaseMapper<SysSmsQueryLogDO> {
*/ */
default List<SysSmsQueryLogDO> selectNoResultQueryLogList() { default List<SysSmsQueryLogDO> selectNoResultQueryLogList() {
return this.selectList(new LambdaQueryWrapper<SysSmsQueryLogDO>() return this.selectList(new LambdaQueryWrapper<SysSmsQueryLogDO>()
.eq(SysSmsQueryLogDO::getSendStatus, SmsSendStatusEnum.QUERY_SUCCESS) .eq(SysSmsQueryLogDO::getSendStatus, SysSmsSendStatusEnum.QUERY_SUCCESS)
.eq(SysSmsQueryLogDO::getGotResult, DefaultBitFieldEnum.NO) .eq(SysSmsQueryLogDO::getGotResult, DefaultBitFieldEnum.NO)
); );
} }

View File

@ -84,6 +84,7 @@ public interface SysErrorCodeConstants {
// ========== 短信发送 1002011000 ========== // ========== 短信发送 1002011000 ==========
ErrorCode SMS_SEND_MOBILE_NOT_EXISTS = new ErrorCode(1002011000, "手机号不存在"); ErrorCode SMS_SEND_MOBILE_NOT_EXISTS = new ErrorCode(1002011000, "手机号不存在");
ErrorCode SMS_SEND_MOBILE_TEMPLATE_PARAM_MISS = new ErrorCode(1002011001, "模板参数({})缺失");
ErrorCode SMS_CHANNEL_NOT_INIT = new ErrorCode(1003001001, ErrorCode SMS_CHANNEL_NOT_INIT = new ErrorCode(1003001001,
"短信渠道没有初始化, 请调用SmsClientWrapper#initSmsClient()或SmsClientWrapper#addSmsClient"); "短信渠道没有初始化, 请调用SmsClientWrapper#initSmsClient()或SmsClientWrapper#addSmsClient");

View File

@ -1,39 +0,0 @@
package cn.iocoder.dashboard.modules.system.enums.sms;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
*
*
* @author zzf
* @date 2021/2/1 13:39
*/
@Getter
@AllArgsConstructor
public enum SmsSendStatusEnum {
//请求发送结果时失败
QUERY_SEND_FAIL(-3),
//短信发送失败
SEND_FAIL(-2),
//短信请求失败
QUERY_FAIL(-1),
//异步转发中
ASYNC(0),
//请求成功
QUERY_SUCCESS(1),
//短信成功
SEND_SUCCESS(2),
//等待回执
WAITING(3);
private final int status;
}

View File

@ -0,0 +1,19 @@
package cn.iocoder.dashboard.modules.system.enums.sms;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
*
*
* @author
*/
@Getter
@AllArgsConstructor
public enum SysSmsSendFailureTypeEnum {
;
private final int type;
}

View File

@ -0,0 +1,23 @@
package cn.iocoder.dashboard.modules.system.enums.sms;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
*
*
* @author zzf
* @date 2021/2/1 13:39
*/
@Getter
@AllArgsConstructor
public enum SysSmsSendStatusEnum {
INIT(0), // 初始化
SUCCESS(10), // 发送成功
FAILURE(20), // 发送失败
;
private final int status;
}

View File

@ -0,0 +1,25 @@
package cn.iocoder.dashboard.modules.system.enums.sms;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
*
*
* @author
*/
@Getter
@AllArgsConstructor
public enum SysSmsTemplateTypeEnum {
VERIFICATION_CODE(1), // 验证码
NOTICE(2), // 通知
PROMOTION(3), // 营销
;
/**
*
*/
private final int type;
}

View File

@ -19,6 +19,8 @@ public interface SysSmsService {
void sendBatchSms(List<String> mobiles, List<Long> userIds, Integer userType, void sendBatchSms(List<String> mobiles, List<Long> userIds, Integer userType,
String templateCode, Map<String, Object> templateParams); String templateCode, Map<String, Object> templateParams);
void doSendSms();
/** /**
* *
* *

View File

@ -7,7 +7,7 @@ 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.SysSmsQueryLogDO;
import cn.iocoder.dashboard.modules.system.enums.sms.SmsSendStatusEnum; 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;
@ -36,7 +36,7 @@ public class SysSmsQueryLogServiceImpl implements SysSmsQueryLogService {
.setPhone(targetPhone) .setPhone(targetPhone)
.setContent(smsBody.getParams().toString()); .setContent(smsBody.getParams().toString());
smsLog.setSendStatus(SmsSendStatusEnum.ASYNC.getStatus()); smsLog.setSendStatus(SysSmsSendStatusEnum.ASYNC.getStatus());
logMapper.insert(smsLog); logMapper.insert(smsLog);
smsBody.setSmsLogId(smsLog.getId()); smsBody.setSmsLogId(smsLog.getId());
} }
@ -46,7 +46,7 @@ public class SysSmsQueryLogServiceImpl implements SysSmsQueryLogService {
SysSmsQueryLogDO smsLog = new SysSmsQueryLogDO(); SysSmsQueryLogDO smsLog = new SysSmsQueryLogDO();
smsLog.setId(logId); smsLog.setId(logId);
smsLog.setApiId(result.getApiId()); smsLog.setApiId(result.getApiId());
smsLog.setSendStatus(SmsSendStatusEnum.QUERY_FAIL.getStatus()); smsLog.setSendStatus(SysSmsSendStatusEnum.QUERY_FAIL.getStatus());
smsLog.setRemark(result.getCode() + ": " + result.getMessage()); smsLog.setRemark(result.getCode() + ": " + result.getMessage());
logMapper.updateById(smsLog); logMapper.updateById(smsLog);
} }

View File

@ -6,7 +6,7 @@ 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.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.SmsSendStatusEnum; import cn.iocoder.dashboard.modules.system.enums.sms.SysSmsSendStatusEnum;
import cn.iocoder.dashboard.modules.system.service.sms.SysSmsChannelService; import cn.iocoder.dashboard.modules.system.service.sms.SysSmsChannelService;
import cn.iocoder.dashboard.modules.system.service.sms.SysSmsSendLogService; import cn.iocoder.dashboard.modules.system.service.sms.SysSmsSendLogService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -88,7 +88,7 @@ public class SysSmsSendLogServiceImpl implements SysSmsSendLogService {
updateQueryLog.setSendStatus(SmsSendStatusEnum.QUERY_SEND_FAIL.getStatus()); updateQueryLog.setSendStatus(SmsSendStatusEnum.QUERY_SEND_FAIL.getStatus());
smsQueryLogMapper.updateById(updateQueryLog); smsQueryLogMapper.updateById(updateQueryLog);
}*/ }*/
updateQueryLog.setSendStatus(SmsSendStatusEnum.SEND_SUCCESS.getStatus()); updateQueryLog.setSendStatus(SysSmsSendStatusEnum.SEND_SUCCESS.getStatus());
updateQueryLog.setRemark(String.format("日志(id = %s)对应的客户端没有继承NeedQuerySendResultSmsClient, 不能获取短信结果。", queryLog.getId())); updateQueryLog.setRemark(String.format("日志(id = %s)对应的客户端没有继承NeedQuerySendResultSmsClient, 不能获取短信结果。", queryLog.getId()));
smsQueryLogMapper.updateById(updateQueryLog); smsQueryLogMapper.updateById(updateQueryLog);
}); });

View File

@ -1,5 +1,7 @@
package cn.iocoder.dashboard.modules.system.service.sms.impl; package cn.iocoder.dashboard.modules.system.service.sms.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.iocoder.dashboard.common.enums.UserTypeEnum; import cn.iocoder.dashboard.common.enums.UserTypeEnum;
import cn.iocoder.dashboard.framework.sms.client.AbstractSmsClient; import cn.iocoder.dashboard.framework.sms.client.AbstractSmsClient;
@ -21,6 +23,8 @@ import javax.servlet.ServletRequest;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Predicate;
import static cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.*; import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.*;
@ -55,24 +59,40 @@ public class SysSmsServiceImpl implements SysSmsService {
@Override @Override
public void sendSingleSms(String mobile, Long userId, Integer userType, public void sendSingleSms(String mobile, Long userId, Integer userType,
String templateCode, Map<String, Object> templateParams) { String templateCode, Map<String, Object> templateParams) {
// 校验短信模板是否存在 // 校验短信模板是否合法
SysSmsTemplateDO template = this.checkSmsTemplateExists(templateCode); SysSmsTemplateDO template = this.checkSmsTemplateValid(templateCode, templateParams);
// 校验手机号码是否存在 // 校验手机号码是否存在
mobile = this.checkMobile(mobile, userId, userType); mobile = this.checkMobile(mobile, userId, userType);
//
} }
@Override @Override
public void sendBatchSms(List<String> mobiles, List<Long> userIds, Integer userType, public void sendBatchSms(List<String> mobiles, List<Long> userIds, Integer userType,
String templateCode, Map<String, Object> templateParams) { String templateCode, Map<String, Object> templateParams) {
// 校验短信模板是否存在 // 校验短信模板是否存在
SysSmsTemplateDO template = this.checkSmsTemplateExists(templateCode); SysSmsTemplateDO template = this.checkSmsTemplateValid(templateCode, templateParams);
} }
private SysSmsTemplateDO checkSmsTemplateExists(String templateCode) { private SysSmsTemplateDO checkSmsTemplateValid(String templateCode, Map<String, Object> templateParams) {
// 短信模板不存在
SysSmsTemplateDO template = smsTemplateService.getSmsTemplateByCode(templateCode); SysSmsTemplateDO template = smsTemplateService.getSmsTemplateByCode(templateCode);
if (template == null) { if (template == null) {
throw exception(SMS_TEMPLATE_NOT_EXISTS); throw exception(SMS_TEMPLATE_NOT_EXISTS);
} }
// 参数不够
if (CollUtil.isNotEmpty(template.getParams())) {
template.getParams().forEach(param -> {
if (!templateParams.containsKey(param)) {
throw exception(SMS_SEND_MOBILE_TEMPLATE_PARAM_MISS);
}
});
}
// 移除多余参数
if (CollUtil.isEmpty(template.getParams())) {
templateParams.clear();
} else {
templateParams.entrySet().removeIf(entry -> !template.getParams().contains(entry.getKey()));
}
return template; return template;
} }