8 changed files with 98 additions and 10 deletions
-
3src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisFunctionAppService.cs
-
50src/Shentun.Peis.Application/PacsBusiness/PacsBusinessAppService.cs
-
2src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs
-
4src/Shentun.Peis.DbMigrator/appsettings.json
-
44src/Shentun.Peis.Domain/IDuplicateRequestService.cs
-
2src/Shentun.Peis.Domain/RegisterChecks/RegisterCheckManager.cs
-
1src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs
-
2src/Shentun.Peis.HttpApi.Host/appsettings.json
@ -0,0 +1,44 @@ |
|||||
|
using Microsoft.Extensions.Caching.Distributed; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Caching; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace Shentun.Peis |
||||
|
{ |
||||
|
public interface IDuplicateRequestService |
||||
|
{ |
||||
|
Task<bool> IsDuplicateAsync(string key, TimeSpan expiration); |
||||
|
} |
||||
|
|
||||
|
public class DuplicateRequestService : IDuplicateRequestService, ITransientDependency |
||||
|
{ |
||||
|
private readonly IDistributedCache<string> _cache; |
||||
|
|
||||
|
public DuplicateRequestService(IDistributedCache<string> cache) |
||||
|
{ |
||||
|
_cache = cache; |
||||
|
} |
||||
|
|
||||
|
public async Task<bool> IsDuplicateAsync(string key, TimeSpan expiration) |
||||
|
{ |
||||
|
var cacheKey = $"DuplicateRequest:{key}"; |
||||
|
var existing = await _cache.GetAsync(cacheKey); |
||||
|
|
||||
|
if (existing != null) |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
await _cache.SetAsync(cacheKey, DateTime.UtcNow.ToString(), new DistributedCacheEntryOptions |
||||
|
{ |
||||
|
AbsoluteExpirationRelativeToNow = expiration |
||||
|
}); |
||||
|
|
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue