From 4de480ec624d3b79ca690dc906e10cd2fbdc9be7 Mon Sep 17 00:00:00 2001 From: duheng <2286773002@qq.com> Date: 星期四, 24 四月 2025 15:00:02 +0800 Subject: [PATCH] 升级dev,添加水量预测注释 --- DAL/IStation.DAL.Paras/Pump/Product.cs | 22 +++++++++++++++++----- 1 files changed, 17 insertions(+), 5 deletions(-) diff --git a/DAL/IStation.DAL.Paras/Pump/Product.cs b/DAL/IStation.DAL.Paras/Pump/Product.cs index bd572f1..ac90dfb 100644 --- a/DAL/IStation.DAL.Paras/Pump/Product.cs +++ b/DAL/IStation.DAL.Paras/Pump/Product.cs @@ -1,4 +1,6 @@ -锘縰sing System; +锘縰sing AutoMapper; +using IStation.Untity; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -52,13 +54,23 @@ return default; - return JsonHelper.Json2Object<List<Model.Product>>(str); + return Entity2Models(JsonHelper.Json2Object<List<Entity.Product>>(str)); } - - - + private static List<Model.Product> Entity2Models(List<Entity.Product> entities) + { + if (entities == null || entities.Count() < 1) + return default; + var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.Product, Model.Product>() + .ForMember(d => d.ParentIds, opt => opt.MapFrom(src => TreeParentIdsHelper.ToList(src.ParentIds))) + .ForMember(d => d.Flags, opt => opt.MapFrom(src => FlagsHelper.ToList(src.Flags))) + ).CreateMapper(); + var models = mapper.Map<List<Entity.Product>, List<Model.Product>>(entities); + return models; + } + + } } \ No newline at end of file -- Gitblit v1.9.3