username@email.com
2024-04-30 d15481638e21ccc610f5e36577497cb6279839b9
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System.IO;
using AutoMapper;
using CoreCms.Net.Model.Entities;
using CoreCms.Net.Model.ViewModels.Basics;
using CoreCms.Net.Model.ViewModels.DTO;
using CoreCms.Net.Model.ViewModels.UI;
using Newtonsoft.Json;
 
namespace CoreCms.Net.Mapping
{
    /// <summary>
    /// AutoMapper的全局实体映射配置静态类
    /// </summary>
    public class AutoMapperConfiguration : Profile, AutoMapperIProfile
    {
        public AutoMapperConfiguration()
        {
            //CreateMap<Manager, ManagerDTO>().ReverseMap();
 
            CreateMap<SqlSugar.DbTableInfo, DbTableInfoTree>()
                .AfterMap((from, to, context) =>
                {
                    to.Label = from.Name + "[" + from.Description + "]";
                });
 
            //商品分类转前端json
            CreateMap<CoreCmsGoodsCategory, DTreeList>()
                .AfterMap((from, to, context) =>
                {
                    to.id = from.id.ToString();
                    to.title = from.name;
                    to.checkArr = "0";
                    to.parentId = from.parentId.ToString();
                });
 
            #region 小程序交互相关=======================================================================================
            //小程序首页获取页面布局信息数据转换
            CreateMap<CoreCmsPagesItems, PagesItemsDto>()
                .AfterMap((from, to, context) =>
                {
                    to.parameters = new JsonSerializer().Deserialize(new JsonTextReader(new StringReader(from.parameters)));
                });
            #endregion
 
        }
    }
}