You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.5 KiB
41 lines
1.5 KiB
using AX.WebDrillServer.Dtos; |
|
using AX.WebDrillServer.EntityConfigurations; |
|
using AX.WebDrillServer.Extensions; |
|
using AX.WebDrillServer.Models; |
|
using Mapster; |
|
using System.Linq.Expressions; |
|
|
|
namespace AX.WebDrillServer.EntityMappers |
|
{ |
|
internal static partial class EntityMapperConfig |
|
{ |
|
public static void Initialize() |
|
{ |
|
#if DEBUG |
|
// 如需开启 mapper 内的步进调试, 需安装 ExpressionDebugger 并启用此行; |
|
TypeAdapterConfig.GlobalSettings.Compiler = exp => exp.CompileWithDebugInfo(); |
|
#endif |
|
|
|
TypeAdapterConfig.GlobalSettings.Default.IgnoreNullValues(true); |
|
// 允许 Mapster 把 目标类型的 映射配置 应用到 目标类型的子类。 |
|
TypeAdapterConfig.GlobalSettings.AllowImplicitDestinationInheritance = true; |
|
|
|
TypeAdapterConfig<DtoBase, EntityBase> |
|
.ForType() |
|
.Ignore(dest => dest.CreationTime) |
|
.Map(dest => dest.LastModificationTime, |
|
src => src.LastModificationTime.ToUtc()); |
|
|
|
TypeAdapterConfig<EntityBase, DtoBase> |
|
.ForType() |
|
.Map(dest => dest.CreationTime, |
|
src => src.CreationTime.ToLocalTime()) |
|
.Map(dest => dest.LastModificationTime, |
|
src => src.LastModificationTime.ToLocal()); |
|
|
|
//映射配置 |
|
UserMapperConfig.Initialize(); |
|
OrginzationConfig.Initialize(); |
|
} |
|
} |
|
} |