Merge pull request '修改缓存' (#43) from S01-轨迹中台 into dev
Reviewed-on: http://192.168.80.50:3000/Dotnet/SJZY.Track.Api/pulls/43
This commit is contained in:
commit
1a8158e6e0
@ -6,16 +6,17 @@ using Volo.Abp.DependencyInjection;
|
|||||||
|
|
||||||
namespace SJZY.Track.Application.Services.TrackPush;
|
namespace SJZY.Track.Application.Services.TrackPush;
|
||||||
|
|
||||||
public class TrackPushCacheService:ITrackPushCacheService, ITransientDependency
|
public class TrackPushCacheService : ITrackPushCacheService, ITransientDependency
|
||||||
{
|
{
|
||||||
private readonly IBasicQuery<TrackPushConfigEntity> _trackPushConfigQuery;
|
private readonly IBasicQuery<TrackPushConfigEntity> _trackPushConfigQuery;
|
||||||
|
|
||||||
private string RedisKey(int customId) => GlobalConst.TrackPushKeyPrefix + customId;
|
private string RedisKey(int customId) => GlobalConst.TrackPushKeyPrefix + customId;
|
||||||
|
|
||||||
public TrackPushCacheService(IBasicQuery<TrackPushConfigEntity> trackPushConfigQuery)
|
public TrackPushCacheService(IBasicQuery<TrackPushConfigEntity> trackPushConfigQuery)
|
||||||
{
|
{
|
||||||
_trackPushConfigQuery = trackPushConfigQuery;
|
_trackPushConfigQuery = trackPushConfigQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> IsPushAsync(int customId)
|
public async Task<bool> IsPushAsync(int customId)
|
||||||
{
|
{
|
||||||
var isPush =
|
var isPush =
|
||||||
@ -30,7 +31,7 @@ public class TrackPushCacheService:ITrackPushCacheService, ITransientDependency
|
|||||||
|
|
||||||
return (bool)isPush;
|
return (bool)isPush;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateAsync(int customId, bool isPush)
|
public async Task UpdateAsync(int customId, bool isPush)
|
||||||
{
|
{
|
||||||
await RedisHelper.Client.SetAsync(RedisKey(customId), isPush);
|
await RedisHelper.Client.SetAsync(RedisKey(customId), isPush);
|
||||||
|
|||||||
@ -3,6 +3,7 @@ using SJZY.Expand.ABP.Core;
|
|||||||
using SJZY.Expand.ABP.Core.Localization;
|
using SJZY.Expand.ABP.Core.Localization;
|
||||||
using SJZY.Expand.ABP.Core.PublicMethords;
|
using SJZY.Expand.ABP.Core.PublicMethords;
|
||||||
using SJZY.Track.Application.Contract.Dtos.TrackPush;
|
using SJZY.Track.Application.Contract.Dtos.TrackPush;
|
||||||
|
using SJZY.Track.Application.Contract.Services;
|
||||||
using SJZY.Track.Application.Localization;
|
using SJZY.Track.Application.Localization;
|
||||||
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
||||||
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
||||||
@ -26,17 +27,20 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
|||||||
private readonly ITrackPushConfigRepository _trackPushConfigRepository;
|
private readonly ITrackPushConfigRepository _trackPushConfigRepository;
|
||||||
private readonly ITrackTemplateRepository _trackTemplateRepository;
|
private readonly ITrackTemplateRepository _trackTemplateRepository;
|
||||||
private readonly ITrackPullConfigRepository _trackPullConfigRepository;
|
private readonly ITrackPullConfigRepository _trackPullConfigRepository;
|
||||||
|
private readonly ITrackPushCacheService _trackPushCacheService;
|
||||||
|
|
||||||
public TrackPushService(
|
public TrackPushService(
|
||||||
IStringLocalizer<TrackLocalizationResource> stringLocalizer,
|
IStringLocalizer<TrackLocalizationResource> stringLocalizer,
|
||||||
ITrackPushConfigRepository trackPushConfigRepository,
|
ITrackPushConfigRepository trackPushConfigRepository,
|
||||||
ITrackTemplateRepository trackTemplateRepository,
|
ITrackTemplateRepository trackTemplateRepository,
|
||||||
ITrackPullConfigRepository trackPullConfigRepository)
|
ITrackPullConfigRepository trackPullConfigRepository,
|
||||||
|
ITrackPushCacheService trackPushCacheService)
|
||||||
{
|
{
|
||||||
_stringLocalizer = stringLocalizer;
|
_stringLocalizer = stringLocalizer;
|
||||||
_trackPushConfigRepository = trackPushConfigRepository;
|
_trackPushConfigRepository = trackPushConfigRepository;
|
||||||
_trackTemplateRepository = trackTemplateRepository;
|
_trackTemplateRepository = trackTemplateRepository;
|
||||||
_trackPullConfigRepository = trackPullConfigRepository;
|
_trackPullConfigRepository = trackPullConfigRepository;
|
||||||
|
_trackPushCacheService = trackPushCacheService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -129,7 +133,7 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
|||||||
trackPushParamsEntity.PullOrPushConfigId = id;
|
trackPushParamsEntity.PullOrPushConfigId = id;
|
||||||
await _trackPullConfigRepository.InsertParamsAsync(trackPushParamsEntity);
|
await _trackPullConfigRepository.InsertParamsAsync(trackPushParamsEntity);
|
||||||
|
|
||||||
if (input.IsAutoPush) await RedisHelper.Client.SAddAsync(GlobalConst.AutoPushRosterRedisKey, input.CustomId);
|
if (input.IsAutoPush) await _trackPushCacheService.IsPushAsync(input.CustomId);
|
||||||
|
|
||||||
ts.Complete();
|
ts.Complete();
|
||||||
}
|
}
|
||||||
@ -154,8 +158,8 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
|||||||
await _trackPushConfigRepository.UpdateAsync(oldTrackPushEntity);
|
await _trackPushConfigRepository.UpdateAsync(oldTrackPushEntity);
|
||||||
await _trackPullConfigRepository.UpdateParamsAsync(oldTrackPushParamsEntity);
|
await _trackPullConfigRepository.UpdateParamsAsync(oldTrackPushParamsEntity);
|
||||||
|
|
||||||
await RedisHelper.Client.SRemAsync(GlobalConst.AutoPushRosterRedisKey, oldCustomId);
|
await _trackPushCacheService.UpdateAsync(oldCustomId, false);
|
||||||
if (input.IsAutoPush) await RedisHelper.Client.SAddAsync(GlobalConst.AutoPushRosterRedisKey, input.CustomId);
|
if (input.IsAutoPush) await _trackPushCacheService.IsPushAsync(input.CustomId);
|
||||||
|
|
||||||
ts.Complete();
|
ts.Complete();
|
||||||
}
|
}
|
||||||
@ -173,7 +177,7 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
|||||||
x.PullOrPushConfigId == input.Id && x.IsPush);
|
x.PullOrPushConfigId == input.Id && x.IsPush);
|
||||||
await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.TrackPushConfigId == input.Id);
|
await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.TrackPushConfigId == input.Id);
|
||||||
|
|
||||||
await RedisHelper.Client.SRemAsync(GlobalConst.AutoPushRosterRedisKey, oldTrackPushEntity.CustomId);
|
await _trackPushCacheService.UpdateAsync(oldTrackPushEntity.CustomId, false);
|
||||||
|
|
||||||
ts.Complete();
|
ts.Complete();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,9 +21,4 @@ public class GlobalConst
|
|||||||
/// 轨迹要推送的客户redis key前缀
|
/// 轨迹要推送的客户redis key前缀
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string TrackPushKeyPrefix = "TrackPush:";
|
public const string TrackPushKeyPrefix = "TrackPush:";
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 自动推送名单RedisKey
|
|
||||||
/// </summary>
|
|
||||||
public const string AutoPushRosterRedisKey = "AutoPushRoster";
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user