update 新增获取字典数据合并接口
This commit is contained in:
@@ -75,6 +75,15 @@ namespace Ewide.Core.Service
|
||||
public string Code { get; set; }
|
||||
}
|
||||
|
||||
public class DropDownDictTypesInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 编码
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "字典类型编码不能为空")]
|
||||
public string[] Code { get; set; }
|
||||
}
|
||||
|
||||
public class QueryDictTypeInfoInput : DeleteDictTypeInput
|
||||
{
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace Ewide.Core.Service
|
||||
Task<dynamic> GetDictData([FromQuery] QueryDictDataInput input);
|
||||
Task<dynamic> GetDictDataList([FromQuery] QueryDictDataListInput input);
|
||||
Task<dynamic> GetDictDataListByDictTypeId(string dictTypeId);
|
||||
Task<dynamic> GetDictDataListByDictTypeIds(SysDictType[] dictTypes);
|
||||
Task<dynamic> QueryDictDataPageList([FromQuery] DictDataInput input);
|
||||
Task UpdateDictData(UpdateDictDataInput input);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace Ewide.Core.Service
|
||||
Task<List<DictTreeOutput>> GetDictTree();
|
||||
Task<dynamic> GetDictType([FromQuery] QueryDictTypeInfoInput input);
|
||||
Task<dynamic> GetDictTypeDropDown([FromQuery] DropDownDictTypeInput input);
|
||||
Task<dynamic> GetDictTypeDropDowns([FromQuery] DropDownDictTypesInput input);
|
||||
Task<dynamic> GetDictTypeList();
|
||||
Task<dynamic> QueryDictTypePageList([FromQuery] DictTypeInput input);
|
||||
Task UpdateDictType(UpdateDictTypeInput input);
|
||||
|
||||
@@ -10,6 +10,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ewide.Core.Service
|
||||
{
|
||||
@@ -150,6 +151,27 @@ namespace Ewide.Core.Service
|
||||
}).ToListAsync();
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
public async Task<dynamic> GetDictDataListByDictTypeIds(SysDictType[] dictTypes)
|
||||
{
|
||||
var dictTypeIds = dictTypes.Select(u => u.Id);
|
||||
var dictData = await _sysDictDataRep.DetachedEntities.Where(u => dictTypeIds.Contains(u.SysDictType.Id))
|
||||
.Where(u => u.Status != CommonStatus.DELETED).OrderBy(u => u.Sort)
|
||||
.ToListAsync();
|
||||
var result = new Dictionary<string, dynamic>();
|
||||
foreach (var dictType in dictTypes)
|
||||
{
|
||||
result.Add(dictType.Code, dictData.Where(u => u.TypeId == dictType.Id)
|
||||
.Select(u => new
|
||||
{
|
||||
u.Code,
|
||||
u.Value,
|
||||
u.Remark
|
||||
}));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除字典下所有值
|
||||
/// </summary>
|
||||
|
||||
@@ -64,7 +64,6 @@ namespace Ewide.Core.Service
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("/sysDictType/dropDown")]
|
||||
public async Task<dynamic> GetDictTypeDropDown([FromQuery] DropDownDictTypeInput input)
|
||||
{
|
||||
@@ -73,6 +72,19 @@ namespace Ewide.Core.Service
|
||||
return await _sysDictDataService.GetDictDataListByDictTypeId(dictType.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("/sysDictType/dropDowns")]
|
||||
public async Task<dynamic> GetDictTypeDropDowns([FromQuery] DropDownDictTypesInput input)
|
||||
{
|
||||
var dictTypes = await _sysDictTypeRep.Where(u => input.Code.Contains(u.Code), false).ToArrayAsync();
|
||||
if (dictTypes.Length == 0) throw Oops.Oh(ErrorCode.D3000);
|
||||
return await _sysDictDataService.GetDictDataListByDictTypeIds(dictTypes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加字典类型
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user