Jelajahi Sumber

sys dic data

dss 2 tahun lalu
induk
melakukan
ea1d1614aa

+ 11 - 10
src/Hotline.Api/Controllers/SysController.cs

@@ -274,18 +274,19 @@ namespace Hotline.Api.Controllers
         /// <returns></returns>
         [Permission(EPermission.GetSysDicData)]
         [HttpGet("dictdata-type")]
-        public async Task<PagedDto<SysDicData>> GetSysDicData([FromQuery] GetSysDicDataDto dto)
+        public async Task<List<SysDicData>> GetSysDicData([FromQuery] GetSysDicDataDto dto)
         {
-            var (total, items) = await _sysDicDataRepository.QueryPagedAsync(
-                x=> true,
-                x=>x.OrderByDescending(d=>d.CreationTime),
-                dto.PageIndex,
-                dto.PageSize,
-                false,
-                whereIfs: (true, x => x.DicTypeId == dto.typeid)
-                );
+            //var (total, items) = await _sysDicDataRepository.QueryPagedAsync(
+            //    x=> true,
+            //    x=>x.OrderByDescending(d=>d.CreationTime),
+            //    dto.PageIndex,
+            //    dto.PageSize,
+            //    false,
+            //    whereIfs: (true, x => x.DicTypeId == dto.typeid)
+            //    );
+            return await _sysDicDataRepository.Queryable().Where(x => x.DicTypeId == dto.typeid).WhereIF(!string.IsNullOrEmpty(dto.datavalue),x=>x.DicDataValue.Contains(dto.datavalue)).ToTreeAsync(x=>x.children,x=>x.ParentId,"");
             //return await _sysDicDataRepository.Queryable().Where(x => x.DicTypeId == typeid).ToListAsync();
-            return new PagedDto<SysDicData> { Total = total, Items = items };
+            //return new PagedDto<SysDicData> { Total = total, Items = items };
         }
 
         /// <summary>

+ 4 - 0
src/Hotline.Share/Dtos/Dic/DicDto.cs

@@ -12,6 +12,8 @@ namespace Hotline.Share.Dtos.Dic
         public string DicTypeId { get; set; }
         public string DicDataName { get; set; }
         public string DicDataValue { get; set; }
+
+        public string? ParentId { get; set; }
     }
     public record UpdateDicDataDto: AddDicDataDto
     {
@@ -21,5 +23,7 @@ namespace Hotline.Share.Dtos.Dic
     public record GetSysDicDataDto:PagedRequest
     {
         public string typeid { get; set; }
+
+        public string datavalue { get; set; }
     }
 }

+ 10 - 1
src/Hotline/Settings/SysDicData.cs

@@ -1,4 +1,5 @@
-using System.ComponentModel;
+using SqlSugar;
+using System.ComponentModel;
 using XF.Domain.Repository;
 
 namespace Hotline.Settings
@@ -25,5 +26,13 @@ namespace Hotline.Settings
         /// 字典值
         /// </summary>
         public string DicDataValue { get; set; }
+
+        /// <summary>
+        /// 上级ID
+        /// </summary>
+        public string ParentId { get; set; }
+
+        [SugarColumn(IsIgnore = true)]
+        public List<SysDicData> children { get; set; }
     }
 }