|
@@ -25,7 +25,7 @@ public class PushDomainService : IPushDomainService, IScopeDependency
|
|
private readonly IMapper _mapper;
|
|
private readonly IMapper _mapper;
|
|
private readonly IHttpClientFactory _httpClientFactory;
|
|
private readonly IHttpClientFactory _httpClientFactory;
|
|
private readonly IConfiguration _config;
|
|
private readonly IConfiguration _config;
|
|
- private readonly SmsAccountInfo accountInfo = null;
|
|
|
|
|
|
+ private readonly SmsAccountInfo? accountInfo = null;
|
|
private readonly IMediator _mediator;
|
|
private readonly IMediator _mediator;
|
|
private readonly ITypedCache<CacheWaitSendId> _cacheWaitSendId;
|
|
private readonly ITypedCache<CacheWaitSendId> _cacheWaitSendId;
|
|
|
|
|
|
@@ -61,9 +61,10 @@ public class PushDomainService : IPushDomainService, IScopeDependency
|
|
public async Task PushAsync(MessageDto messageDto, CancellationToken cancellation)
|
|
public async Task PushAsync(MessageDto messageDto, CancellationToken cancellation)
|
|
{
|
|
{
|
|
if (messageDto == null)
|
|
if (messageDto == null)
|
|
- {
|
|
|
|
throw UserFriendlyException.SameMessage("消息不能为空!");
|
|
throw UserFriendlyException.SameMessage("消息不能为空!");
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ if (string.IsNullOrEmpty(messageDto.Template)&&string.IsNullOrEmpty(messageDto.Content))
|
|
|
|
+ throw UserFriendlyException.SameMessage("模板和内容不能同时为空!");
|
|
|
|
|
|
Message message = new();
|
|
Message message = new();
|
|
int WaitSendId = 0;
|
|
int WaitSendId = 0;
|
|
@@ -88,8 +89,8 @@ public class PushDomainService : IPushDomainService, IScopeDependency
|
|
var matches = regex.Matches(Template);
|
|
var matches = regex.Matches(Template);
|
|
if (matches != null && matches.Count != messageDto.Params.Count)
|
|
if (matches != null && matches.Count != messageDto.Params.Count)
|
|
//参数与需要替换的字符数不匹配
|
|
//参数与需要替换的字符数不匹配
|
|
- //throw UserFriendlyException.SameMessage("模板需要参数与实际传递参数个数不匹配!");
|
|
|
|
- reason = "模板需要参数与实际传递参数个数不匹配!";
|
|
|
|
|
|
+ throw UserFriendlyException.SameMessage("模板需要参数与实际传递参数个数不匹配!");
|
|
|
|
+ //reason = "模板需要参数与实际传递参数个数不匹配!";
|
|
|
|
|
|
//根据正则查询出来的匹配项替换内容
|
|
//根据正则查询出来的匹配项替换内容
|
|
for (int i = 0; i < matches.Count; i++)
|
|
for (int i = 0; i < matches.Count; i++)
|