Bläddra i källkod

添加字典查询方法,可以通过禁用/启用状态进行查询下拉框集合

kenny 3 år sedan
förälder
incheckning
33b6dc8add

+ 14 - 0
Admin.NET/Admin.NET.Core/Service/Dict/Dto/DictDataInput.cs

@@ -110,4 +110,18 @@ public class ChageStatusDictDataInput : BaseIdInput
     /// 状态
     /// </summary>
     public int Status { get; set; }
+}
+
+public class QueryDictDataInput
+{
+    /// <summary>
+    /// 编码
+    /// </summary>
+    [Required(ErrorMessage = "字典唯一编码不能为空")]
+    public string Code { get; set; }
+
+    /// <summary>
+    /// 状态
+    /// </summary>
+    public int? Status { get; set; }
 }

+ 19 - 0
Admin.NET/Admin.NET.Core/Service/Dict/SysDictDataService.cs

@@ -151,4 +151,23 @@ public class SysDictDataService : IDynamicApiController, ITransient
                 Value = b.Code
             }).ToListAsync();
     }
+
+    /// <summary>
+    /// 根据条件查询字典获取下拉框集合
+    /// </summary>
+    /// <param name="input">查询参数</param>
+    /// <returns></returns>
+    [HttpGet("/sysDictData/queryDictDataDropdown")]
+    public async Task<dynamic> QueryDictDataDropdown([FromQuery] QueryDictDataInput input)
+    {
+        return await _sysDictDataRep.Context.Queryable<SysDictType, SysDictData>((a, b) =>
+            new JoinQueryInfos(JoinType.Left, a.Id == b.DictTypeId))
+            .Where((a, b) => a.Code == input.Code)
+            .WhereIF(input.Status.HasValue, (a, b) => b.Status == (StatusEnum)input.Status.Value)
+            .Select((a, b) => new
+            {
+                Label = b.Value,
+                Value = b.Code
+            }).ToListAsync();
+    }
 }