注释默认短信
This commit is contained in:
1 parent
5138684ba1
commit
a16ba88d4a
1 file changed
+36
-36
+36
-36
@@ -295,47 +295,47 @@ public class SysMessageServiceImpl extends ServiceImpl<SysMessageMapper, SysMess
|
||||
public R sendSms(MessageSmsDTO messageSmsDTO) {
|
||||
|
||||
// 根据业务编码获取短信通道配置
|
||||
List<SysSystemConfigEntity> configEntityList = sysSystemConfigMapper.selectList(Wrappers.<SysSystemConfigEntity>lambdaQuery().eq(SysSystemConfigEntity::getConfigType, SystemConfigTypeEnum.SMS.getValue()).eq(SysSystemConfigEntity::getConfigStatus, YesNoEnum.YES.getCode()).eq(SysSystemConfigEntity::getConfigKey, messageSmsDTO.getBizCode()));
|
||||
if (CollUtil.isEmpty(configEntityList)) {
|
||||
return R.failed("发送失败,短信通道配置不存在");
|
||||
}
|
||||
// List<SysSystemConfigEntity> configEntityList = sysSystemConfigMapper.selectList(Wrappers.<SysSystemConfigEntity>lambdaQuery().eq(SysSystemConfigEntity::getConfigType, SystemConfigTypeEnum.SMS.getValue()).eq(SysSystemConfigEntity::getConfigStatus, YesNoEnum.YES.getCode()).eq(SysSystemConfigEntity::getConfigKey, messageSmsDTO.getBizCode()));
|
||||
// if (CollUtil.isEmpty(configEntityList)) {
|
||||
// return R.failed("发送失败,短信通道配置不存在");
|
||||
// }
|
||||
|
||||
SysSystemConfigEntity configEntity = configEntityList.get(0);
|
||||
JSONObject configMap = JSONUtil.parseObj(configEntity.getConfigValue());
|
||||
// SysSystemConfigEntity configEntity = configEntityList.get(0);
|
||||
// JSONObject configMap = JSONUtil.parseObj(configEntity.getConfigValue());
|
||||
|
||||
// 组装SMS4J 的发送对象
|
||||
SmsBlend smsBlend = SmsFactory.getSmsBlend(messageSmsDTO.getBizCode());
|
||||
if (Objects.isNull(smsBlend)) {
|
||||
Class targetClass = Arrays.stream(SUPPORT_CONFIG_CLAZZ).filter(config -> config.getSimpleName().toLowerCase().contains(configMap.getStr(MessageSmsDTO.Fields.supplier))).findFirst().orElseThrow(() -> new CheckedException("发送失败,短信通道配置不存在"));
|
||||
BaseConfig baseConfig = (BaseConfig) JSONUtil.toBean(configEntity.getConfigValue(), targetClass);
|
||||
|
||||
// 如果渠道扩展参数不为空则增加特性化参数
|
||||
if (StrUtil.isNotBlank(configMap.getStr(MessageSmsDTO.Fields.extParams))) {
|
||||
JSONObject extParams = configMap.getJSONObject(MessageSmsDTO.Fields.extParams);
|
||||
BeanUtil.copyProperties(extParams, baseConfig);
|
||||
}
|
||||
|
||||
baseConfig.setConfigId(configEntity.getConfigKey());
|
||||
SmsFactory.createSmsBlend(baseConfig);
|
||||
smsBlend = SmsFactory.getSmsBlend(messageSmsDTO.getBizCode());
|
||||
}
|
||||
// SmsBlend smsBlend = SmsFactory.getSmsBlend(messageSmsDTO.getBizCode());
|
||||
// if (Objects.isNull(smsBlend)) {
|
||||
// Class targetClass = Arrays.stream(SUPPORT_CONFIG_CLAZZ).filter(config -> config.getSimpleName().toLowerCase().contains(configMap.getStr(MessageSmsDTO.Fields.supplier))).findFirst().orElseThrow(() -> new CheckedException("发送失败,短信通道配置不存在"));
|
||||
// BaseConfig baseConfig = (BaseConfig) JSONUtil.toBean(configEntity.getConfigValue(), targetClass);
|
||||
//
|
||||
// // 如果渠道扩展参数不为空则增加特性化参数
|
||||
// if (StrUtil.isNotBlank(configMap.getStr(MessageSmsDTO.Fields.extParams))) {
|
||||
// JSONObject extParams = configMap.getJSONObject(MessageSmsDTO.Fields.extParams);
|
||||
// BeanUtil.copyProperties(extParams, baseConfig);
|
||||
// }
|
||||
//
|
||||
// baseConfig.setConfigId(configEntity.getConfigKey());
|
||||
// SmsFactory.createSmsBlend(baseConfig);
|
||||
// smsBlend = SmsFactory.getSmsBlend(messageSmsDTO.getBizCode());
|
||||
// }
|
||||
|
||||
// 异步发送短信
|
||||
SysLogDTO sysLog = SysLogUtils.getSysLog();
|
||||
Long start = System.currentTimeMillis();
|
||||
sysLog.setTenantId(TenantContextHolder.getTenantId());
|
||||
for (String mobile : messageSmsDTO.getMobiles()) {
|
||||
smsBlend.sendMessageAsync(mobile, configMap.getStr(MessageSmsDTO.Fields.templateId), messageSmsDTO.getParams(), smsResponse -> {
|
||||
log.info("发送短信结果:{}", smsResponse);
|
||||
sysLog.setTitle(String.format("发送短信 %s", mobile));
|
||||
sysLog.setLogType(LogTypeEnum.NORMAL.getType());
|
||||
sysLog.setServiceId(SystemConfigTypeEnum.SMS.getValue());
|
||||
sysLog.setParams(JacksonSensitiveFieldUtil.writeValueAsString(smsResponse));
|
||||
sysLog.setTime(System.currentTimeMillis() - start);
|
||||
sysLog.setException(JacksonSensitiveFieldUtil.writeValueAsString(smsResponse));
|
||||
remoteLogService.saveLog(sysLog);
|
||||
});
|
||||
}
|
||||
// SysLogDTO sysLog = SysLogUtils.getSysLog();
|
||||
// Long start = System.currentTimeMillis();
|
||||
// sysLog.setTenantId(TenantContextHolder.getTenantId());
|
||||
// for (String mobile : messageSmsDTO.getMobiles()) {
|
||||
// smsBlend.sendMessageAsync(mobile, configMap.getStr(MessageSmsDTO.Fields.templateId), messageSmsDTO.getParams(), smsResponse -> {
|
||||
// log.info("发送短信结果:{}", smsResponse);
|
||||
// sysLog.setTitle(String.format("发送短信 %s", mobile));
|
||||
// sysLog.setLogType(LogTypeEnum.NORMAL.getType());
|
||||
// sysLog.setServiceId(SystemConfigTypeEnum.SMS.getValue());
|
||||
// sysLog.setParams(JacksonSensitiveFieldUtil.writeValueAsString(smsResponse));
|
||||
// sysLog.setTime(System.currentTimeMillis() - start);
|
||||
// sysLog.setException(JacksonSensitiveFieldUtil.writeValueAsString(smsResponse));
|
||||
// remoteLogService.saveLog(sysLog);
|
||||
// });
|
||||
// }
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user