Jelajahi Sumber

列表字段映射配置调整

lichunlei 8 bulan lalu
induk
melakukan
6c2b538c08
3 mengubah file dengan 19 tambahan dan 9 penghapusan
  1. 6 1
      Common/Tools.cs
  2. 2 2
      Model/Vo/Admin/GetProjectServiceQueryVo.cs
  3. 11 6
      Util/ModelVoAdapt.cs

+ 6 - 1
Common/Tools.cs

@@ -22,7 +22,12 @@ namespace Common
             return infoIdss;
         }
 
-        public static int[] SpitIntArrary(string str, char split = ',')
+        public static int[] SpitIntArrary(string str)
+        {
+            return SpitIntArrary(str, ',');
+        }
+
+        public static int[] SpitIntArrary(string str, char split)
         {
             if (string.IsNullOrEmpty(str)) { return Array.Empty<int>(); }
             string[] strIds = str.Split(split, (char)StringSplitOptions.RemoveEmptyEntries);

+ 2 - 2
Model/Vo/Admin/GetProjectServiceQueryVo.cs

@@ -34,13 +34,13 @@ namespace Vo.Admin
         /// <summary>
         /// 服务器
         /// </summary>
-        public string serverList { get; set; }
+        public int[] serverList { get; set; }
 
 
         /// <summary>
         /// 数据库
         /// </summary>
-        public string databaseList { get; set; }
+        public int[] databaseList { get; set; }
 
 
 

+ 11 - 6
Util/ModelVoAdapt.cs

@@ -1,4 +1,5 @@
-using Dto.Admin;
+using Common;
+using Dto.Admin;
 using Mapster;
 using Model;
 using Vo.Admin;
@@ -10,12 +11,16 @@ namespace Util
         public static void Map()
         {
             TypeAdapterConfig<AddProjectServiceDto, ProjectService>.NewConfig()
-                .Map(dest => dest.serverList, src => src.serverList.Length > 0
-                    ? "" : string.Join(',', src.serverList));
-
-            TypeAdapterConfig<AddProjectServiceDto, ProjectService>.NewConfig()
-                .Map(dest => dest.databaseList, src => src.databaseList.Length > 0
+                .Map(dest => dest.serverList, src => src.serverList.Length == 0
+                    ? "" : string.Join(',', src.serverList))
+                .Map(dest => dest.databaseList, src => src.databaseList.Length == 0
                     ? "" : string.Join(',', src.databaseList));
+
+            TypeAdapterConfig<ProjectService, GetProjectServiceQueryVo>.NewConfig()
+                .Map(dest => dest.serverList, src => string.IsNullOrEmpty(src.serverList)
+                    ? Array.Empty<int>() : Tools.SpitIntArrary(src.serverList))
+                .Map(dest => dest.databaseList, src => string.IsNullOrEmpty(src.databaseList)
+                    ? Array.Empty<int>() : Tools.SpitIntArrary(src.databaseList));
         }
 
     }