Blame view

美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/ObjectMapping/RbacMapsterRegister.cs 1.01 KB
c2e3194d   李曜臣   登陆优化;产品-门店绑定优化
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  using Mapster;
  using Yi.Framework.Rbac.Application.Contracts.Dtos.Menu;
  using Yi.Framework.Rbac.Domain.Entities;
  using Yi.Framework.Rbac.Domain.Shared;
  using Yi.Framework.Rbac.Domain.Shared.Dtos;
  
  namespace Yi.Framework.Rbac.Application.ObjectMapping;
  
  /// <summary>
  /// <c>Menu.ParentId</c> 实体为字符串,对外 DTO 仍为 <see cref="Guid"/>
  /// </summary>
  public class RbacMapsterRegister : IRegister
  {
      public void Register(TypeAdapterConfig config)
      {
          config.NewConfig<MenuAggregateRoot, MenuGetOutputDto>()
              .Map(d => d.ParentId, s => MenuParentIdConverter.ToGuid(s.ParentId));
  
          config.NewConfig<MenuAggregateRoot, MenuGetListOutputDto>()
              .Map(d => d.ParentId, s => MenuParentIdConverter.ToGuid(s.ParentId));
  
          // 登录组装用户信息时使用;库中 ParentId 可能为 "0",不能交给 Mapster 默认 stringGuid
          config.NewConfig<MenuAggregateRoot, MenuDto>()
              .Map(d => d.ParentId, s => MenuParentIdConverter.ToGuid(s.ParentId));
      }
  }