diff --git a/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs b/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs index a4a57bc0..ab34ac01 100644 --- a/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs +++ b/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs @@ -19,7 +19,7 @@ public interface ITrackPushCacheService /// 服务商id /// /// - Task GetPushContentConfigAsync(int subSystemId, int customId, int trackContentId); + Task GetPushContentConfigAsync(int subSystemId, int customId, int trackContentId); /// /// 根据轨迹代码推断下一个(升序)要推送的内容,如果找不到或者已经是最后一个了,返回null diff --git a/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs index 208b3a85..7410c881 100644 --- a/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs +++ b/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs @@ -162,7 +162,7 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe { config = await _trackPushCacheService.GetPushContentConfigAsync( @event.SubSystemId, @event.CustomId, track.TrackContentId); - if (!config.IsCanUpdate) return; + if (config == null || !config.IsCanUpdate) return; } else { diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs index 46155e2e..5dc319f8 100644 --- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs +++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs @@ -28,12 +28,12 @@ public class TrackPushCacheService : ApplicationService, ITrackPushCacheService } [NonAction] - public async Task GetPushContentConfigAsync(int subSystemId, int customId, + public async Task GetPushContentConfigAsync(int subSystemId, int customId, int trackContentId) { var data = await GetPushContentConfigsAsync(subSystemId, customId); - return data.Single(x => x.TrackContentId == trackContentId); + return data?.FirstOrDefault(x => x.TrackContentId == trackContentId); } [NonAction]