增加同时获取多个字典类型数据接口
This commit is contained in:
@@ -16,6 +16,12 @@ public interface IDictionaryTypeService
|
||||
/// <returns></returns>
|
||||
Task<List<DictionaryTypeEntity>> GetList();
|
||||
|
||||
/// <summary>
|
||||
/// 获取部分列表.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<DictionaryTypeEntity>> GetListMany(string[] ids);
|
||||
|
||||
/// <summary>
|
||||
/// 信息.
|
||||
/// </summary>
|
||||
|
||||
@@ -95,6 +95,26 @@ public class DictionaryDataService : IDictionaryDataService, IDynamicApiControll
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取部分数据字典列表(多个分类).
|
||||
/// </summary>
|
||||
[HttpGet("Many")]
|
||||
public async Task<dynamic> GetListMany(string[] dictionaryTypeIds)
|
||||
{
|
||||
var dictionaryData = await _repository.AsQueryable().Where(d => d.DeleteMark == null && d.EnabledMark == 1 && dictionaryTypeIds.Contains(d.DictionaryTypeId))
|
||||
.OrderBy(o => o.SortCode).OrderBy(o => o.CreatorTime, OrderByType.Desc).OrderBy(o => o.LastModifyTime, OrderByType.Desc).ToListAsync();
|
||||
var dictionaryType = await _dictionaryTypeService.GetListMany(dictionaryTypeIds);
|
||||
var data = dictionaryType.Adapt<List<DictionaryDataAllListOutput>>();
|
||||
data.ForEach(dataall =>
|
||||
{
|
||||
if (dataall.isTree == 1)
|
||||
dataall.dictionaryList = dictionaryData.FindAll(d => d.DictionaryTypeId == dataall.id).Adapt<List<DictionaryDataTreeOutput>>().ToTree();
|
||||
else
|
||||
dataall.dictionaryList = dictionaryData.FindAll(d => d.DictionaryTypeId == dataall.id).Adapt<List<DictionaryDataListOutput>>();
|
||||
});
|
||||
return new { list = data };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有数据字典列表(分类+内容).
|
||||
/// </summary>
|
||||
|
||||
@@ -165,13 +165,22 @@ public class DictionaryTypeService : IDictionaryTypeService, IDynamicApiControll
|
||||
/// <summary>
|
||||
/// 列表.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[NonAction]
|
||||
public async Task<List<DictionaryTypeEntity>> GetList()
|
||||
{
|
||||
return await _repository.AsQueryable().Where(x => x.DeleteMark == null).OrderBy(x => x.SortCode).OrderBy(x => x.CreatorTime, OrderByType.Desc).ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 列表.
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public async Task<List<DictionaryTypeEntity>> GetListMany(string[] ids)
|
||||
{
|
||||
return await _repository.AsQueryable().Where(x => x.DeleteMark == null && ids.Contains(x.Id)).OrderBy(x => x.SortCode).OrderBy(x => x.CreatorTime, OrderByType.Desc).ToListAsync();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 递归获取所有分类.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user