Эх сурвалжийг харах

字典服务新增根据字典类型名称列表查询字典列表接口

zhontai 2 жил өмнө
parent
commit
918bebd59b

+ 25 - 1
src/platform/ZhonTai.Admin/Services/Dict/DictService.cs

@@ -69,7 +69,7 @@ public class DictService : BaseService, IDictService, IDynamicApi
     /// <summary>
     /// 查询列表
     /// </summary>
-    /// <param name="codes">编码列表</param>
+    /// <param name="codes">字典类型编码列表</param>
     /// <returns></returns>
     [AllowAnonymous]
     [HttpPost]
@@ -90,6 +90,30 @@ public class DictService : BaseService, IDictService, IDynamicApi
         return dicts;
     }
 
+    /// <summary>
+    /// 根据字典类型名称列表查询字典列表
+    /// </summary>
+    /// <param name="names">字典类型名称列表</param>
+    /// <returns></returns>
+    [AllowAnonymous]
+    [HttpPost]
+    public async Task<Dictionary<string, List<DictGetListDto>>> GetListByNamesAsync(string[] names)
+    {
+        var list = await _dictRepository.Select
+        .Where(a => names.Contains(a.DictType.Name) && a.DictType.Enabled == true && a.Enabled == true)
+        .OrderBy(a => a.Sort)
+        .ToListAsync(a => new DictGetListDto { DictTypeName = a.DictType.Name });
+
+        var dicts = new Dictionary<string, List<DictGetListDto>>();
+        foreach (var name in names)
+        {
+            if (name.NotNull())
+                dicts[name] = list.Where(a => a.DictTypeName == name).ToList();
+        }
+
+        return dicts;
+    }
+
     /// <summary>
     /// 新增
     /// </summary>

+ 6 - 0
src/platform/ZhonTai.Admin/Services/Dict/Dto/DictGetListDto.cs

@@ -10,6 +10,12 @@ public class DictGetListDto
     [JsonIgnore]
     public string DictTypeCode { get; set; }
 
+    /// <summary>
+    /// 字典类型名称
+    /// </summary>
+    [JsonIgnore]
+    public string DictTypeName { get; set; }
+
     /// <summary>
     /// 主键Id
     /// </summary>

+ 13 - 1
src/platform/ZhonTai.Admin/ZhonTai.Admin.xml

@@ -4342,7 +4342,14 @@
             <summary>
             查询列表
             </summary>
-            <param name="codes">编码列表</param>
+            <param name="codes">字典类型编码列表</param>
+            <returns></returns>
+        </member>
+        <member name="M:ZhonTai.Admin.Services.Dict.DictService.GetListByNamesAsync(System.String[])">
+            <summary>
+            根据字典类型名称列表查询列表
+            </summary>
+            <param name="names">字典类型名称列表</param>
             <returns></returns>
         </member>
         <member name="M:ZhonTai.Admin.Services.Dict.DictService.AddAsync(ZhonTai.Admin.Services.Dict.Dto.DictAddInput)">
@@ -4432,6 +4439,11 @@
             字典类型编码
             </summary>
         </member>
+        <member name="P:ZhonTai.Admin.Services.Dict.Dto.DictGetListDto.DictTypeName">
+            <summary>
+            字典类型名称
+            </summary>
+        </member>
         <member name="P:ZhonTai.Admin.Services.Dict.Dto.DictGetListDto.Id">
             <summary>
             主键Id