diff --git a/be/Modules/Label/src/Win_in.Sfs.Label.Application/Bases/SfsLabelAppServiceWithCodeBase.cs b/be/Modules/Label/src/Win_in.Sfs.Label.Application/Bases/SfsLabelAppServiceWithCodeBase.cs index 312404b9c..033bb43b3 100644 --- a/be/Modules/Label/src/Win_in.Sfs.Label.Application/Bases/SfsLabelAppServiceWithCodeBase.cs +++ b/be/Modules/Label/src/Win_in.Sfs.Label.Application/Bases/SfsLabelAppServiceWithCodeBase.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -38,10 +39,12 @@ public class SfsLabelAppServiceWithCodeBase GetByCodeAsync(string code) { - var dto = await Cache.GetOrAddItemAsync( - $"{typeof(TEntityDto).Name}:{code}".ToString(), - async () => await GetFromRepositoryAsync(code).ConfigureAwait(false), - SfsCacheConst.SeveralMinutes).ConfigureAwait(false); + // var dto = await Cache.GetOrAddItemAsync( + // $"{typeof(TEntityDto).Name}:{code}".ToString(), + // async () => await GetFromRepositoryAsync(code).ConfigureAwait(false), + // SfsCacheConst.SeveralMinutes).ConfigureAwait(false); + + var dto = await GetFromRepositoryAsync(code).ConfigureAwait(false); return dto; } @@ -50,18 +53,22 @@ public class SfsLabelAppServiceWithCodeBase> GetByCodesAsync(IEnumerable codes) { - var dtoList = new List(); - foreach (var code in codes) - { - var dto = await Cache.GetOrAddItemAsync( - $"{typeof(TEntityDto).Name}:{code}".ToString(), - async () => await GetFromRepositoryAsync(code).ConfigureAwait(false), - SfsCacheConst.SeveralMinutes).ConfigureAwait(false); - if (dto != null) - { - dtoList.Add(dto); - } - } + // var dtoList = new List(); + // foreach (var code in codes) + // { + // var dto = await Cache.GetOrAddItemAsync( + // $"{typeof(TEntityDto).Name}:{code}".ToString(), + // async () => await GetFromRepositoryAsync(code).ConfigureAwait(false), + // SfsCacheConst.SeveralMinutes).ConfigureAwait(false); + // if (dto != null) + // { + // dtoList.Add(dto); + // } + // } + // return dtoList; + + var entities = await _repository.GetListAsync(p => codes.Contains(p.Code)).ConfigureAwait(false); + var dtoList = ObjectMapper.Map, List>(entities); return dtoList; } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Bases/SfsJobWithCodeAppServiceBase.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Bases/SfsJobWithCodeAppServiceBase.cs index d1493e856..6102ed5d2 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Bases/SfsJobWithCodeAppServiceBase.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Bases/SfsJobWithCodeAppServiceBase.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; @@ -37,10 +38,12 @@ public abstract class SfsJobWithCodeAppServiceBase GetByCodeAsync(string code) { - var dto = await Cache.GetOrAddItemAsync( - $"{typeof(TEntityDto).Name}:{code}".ToString(), - async () => await GetFromRepositoryAsync(code).ConfigureAwait(false), - SfsCacheConst.SeveralMinutes).ConfigureAwait(false); + // var dto = await Cache.GetOrAddItemAsync( + // $"{typeof(TEntityDto).Name}:{code}".ToString(), + // async () => await GetFromRepositoryAsync(code).ConfigureAwait(false), + // SfsCacheConst.SeveralMinutes).ConfigureAwait(false); + + var dto = await GetFromRepositoryAsync(code).ConfigureAwait(false); return dto; @@ -51,18 +54,22 @@ public abstract class SfsJobWithCodeAppServiceBase> GetByCodesAsync(IEnumerable codes) { - var dtoList = new List(); - foreach (var code in codes) - { - var dto = await Cache.GetOrAddItemAsync( - $"{typeof(TEntityDto).Name}:{code}".ToString(), - async () => await GetFromRepositoryAsync(code).ConfigureAwait(false), - SfsCacheConst.SeveralMinutes).ConfigureAwait(false); - if (dto != null) - { - dtoList.Add(dto); - } - } + // var dtoList = new List(); + // foreach (var code in codes) + // { + // var dto = await Cache.GetOrAddItemAsync( + // $"{typeof(TEntityDto).Name}:{code}".ToString(), + // async () => await GetFromRepositoryAsync(code).ConfigureAwait(false), + // SfsCacheConst.SeveralMinutes).ConfigureAwait(false); + // if (dto != null) + // { + // dtoList.Add(dto); + // } + // } + // return dtoList; + + var entities = await _repository.GetListAsync(p => codes.Contains(p.Code)).ConfigureAwait(false); + var dtoList = ObjectMapper.Map, List>(entities); return dtoList; }