Browse Source

新增 post getbycodes

dev_DY_CC
郑勃旭 9 months ago
parent
commit
9fc76c281c
  1. 20
      be/Hosts/Auth.Host/src/Win_in.Sfs.Auth.Application/Bases/SfsAuthCrudAppServiceBase.cs
  2. 20
      be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Bases/SfsBaseDataWithCodeAppServiceBase.cs
  3. 2
      be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/Balances/BalanceAppService.cs
  4. 7
      be/Modules/Label/src/Win_in.Sfs.Label.Application/Bases/SfsLabelAppServiceWithCodeBase.cs
  5. 2
      be/Modules/Shared/src/Win_in.Sfs.Shared.Application.Contracts/ISfsGetByCodeAppService.cs
  6. 7
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Bases/SfsJobWithCodeAppServiceBase.cs

20
be/Hosts/Auth.Host/src/Win_in.Sfs.Auth.Application/Bases/SfsAuthCrudAppServiceBase.cs

@ -76,6 +76,26 @@ public abstract class SfsBaseDataWithCodeAppServiceBase<TEntity, TEntityDto, TRe
return dtoList;
}
[AllowAnonymous]
[HttpPost("by-codes-with-post")]
public virtual async Task<List<TEntityDto>> GetByCodesWithPostAsync(IEnumerable<string> codes)
{
var dtoList = new List<TEntityDto>();
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;
}
private async Task<TEntityDto> GetFromRepositoryAsync(string code)
{
// var entity = await _repository.FindAsync(p => p.Code == code);

20
be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Bases/SfsBaseDataWithCodeAppServiceBase.cs

@ -67,6 +67,26 @@ public abstract class SfsBaseDataWithCodeAppServiceBase<TEntity, TEntityDto, TRe
return dtoList;
}
[AllowAnonymous]
[HttpPost("by-codes-with-post")]
public virtual async Task<List<TEntityDto>> GetByCodesWithPostAsync(IEnumerable<string> codes)
{
var dtoList = new List<TEntityDto>();
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;
}
protected virtual async Task<TEntityDto> GetFromRepositoryAsync(string code)
{
// var entity = await _repository.FindAsync(p => p.Code == code);

2
be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/Balances/BalanceAppService.cs

@ -961,7 +961,7 @@ public class BalanceAppService
if (list.Count > 0)
{
var itemCodes = list.Select(t => t.ItemCode).Distinct();
var itemBasicDtos = await _itemBasicAppService.GetByCodesAsync(itemCodes).ConfigureAwait(false);
var itemBasicDtos = await _itemBasicAppService.GetByCodesWithPostAsync(itemCodes).ConfigureAwait(false);
if (itemBasicDtos.Count > 0)
{
list.ForEach(item =>

7
be/Modules/Label/src/Win_in.Sfs.Label.Application/Bases/SfsLabelAppServiceWithCodeBase.cs

@ -72,6 +72,13 @@ public class SfsLabelAppServiceWithCodeBase<TEntity, TEntityDto, TRequestDTO, TC
return dtoList;
}
public virtual async Task<List<TEntityDto>> GetByCodesWithPostAsync(IEnumerable<string> codes)
{
var entities = await _repository.GetListAsync(p => codes.Contains(p.Code)).ConfigureAwait(false);
var dtoList = ObjectMapper.Map<List<TEntity>, List<TEntityDto>>(entities);
return dtoList;
}
private async Task<TEntityDto> GetFromRepositoryAsync(string code)
{
// var entity = await _repository.FindAsync(p => p.Code == code);

2
be/Modules/Shared/src/Win_in.Sfs.Shared.Application.Contracts/ISfsGetByCodeAppService.cs

@ -20,4 +20,6 @@ public interface ISfsGetByCodeAppService<TEntityDto>
/// <param name="codes"></param>
/// <returns></returns>
Task<List<TEntityDto>> GetByCodesAsync(IEnumerable<string> codes);
Task<List<TEntityDto>> GetByCodesWithPostAsync(IEnumerable<string> codes);
}

7
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Bases/SfsJobWithCodeAppServiceBase.cs

@ -73,6 +73,13 @@ public abstract class SfsJobWithCodeAppServiceBase<TEntity, TEntityDto, TRequest
return dtoList;
}
public async Task<List<TEntityDto>> GetByCodesWithPostAsync(IEnumerable<string> codes)
{
var entities = await _repository.GetListAsync(p => codes.Contains(p.Code)).ConfigureAwait(false);
var dtoList = ObjectMapper.Map<List<TEntity>, List<TEntityDto>>(entities);
return dtoList;
}
protected virtual async Task<TEntityDto> GetFromRepositoryAsync(string code)
{
// var entity = await _repository.FindAsync(p => p.Code == code);

Loading…
Cancel
Save