You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.6 KiB
C#

1 year ago
using AutoMapper;
using Admin.Core.Model;
using Admin.Core.Model.Sys;
namespace Admin.Core.Extensions
{
public class CustomProfile : Profile
{
/// <summary>
/// 配置构造函数,用来创建关系映射
/// </summary>
public CustomProfile()
{
CreateMap<SysUser, UserModel>();
CreateMap<UserModel, SysUser>();
CreateMap<PageModel<SysUser>, PageModel<UserModel>>();
CreateMap<PageModel<UserModel>, PageModel<SysUser>>();
CreateMap<SysMenu, MenuView>();
CreateMap<MenuView, SysMenu>();
CreateMap<MenuView, TreeSelect>()
.ForMember(a => a.id, b => b.MapFrom(x => x.MenuID))
.ForMember(a => a.label, b => b.MapFrom(x => x.MenuName));
CreateMap<TreeSelect, MenuView>()
.ForMember(a => a.MenuID, b => b.MapFrom(x => x.id))
.ForMember(a => a.MenuName, b => b.MapFrom(x => x.label));
CreateMap<SysDept, DeptView>();
CreateMap<DeptView, SysDept>();
CreateMap<PageModel<SysDept>, PageModel<DeptView>>();
CreateMap<PageModel<DeptView>, PageModel<SysDept>>();
CreateMap<DeptView, TreeSelect>()
.ForMember(a => a.id, b => b.MapFrom(x => x.DeptID))
.ForMember(a => a.label, b => b.MapFrom(x => x.DeptName));
CreateMap<TreeSelect, DeptView>()
.ForMember(a => a.DeptID, b => b.MapFrom(x => x.id))
.ForMember(a => a.DeptName, b => b.MapFrom(x => x.label));
CreateMap<SysRole, RoleModel>();
CreateMap<RoleModel, SysRole>();
CreateMap<SysJobLog, JobLogView>();
CreateMap<JobLogView, SysJobLog>();
CreateMap<PageModel<SysJobLog>, PageModel<JobLogView>>();
CreateMap<PageModel<JobLogView>, PageModel<SysJobLog>>();
//业务类
// CreateMap<PageModel<EEquipmentCategory>, PageModel<EEquipmentCategoryView>>();
// CreateMap<PageModel<EEquipmentCategoryView>, PageModel<EEquipmentCategory>>();
// CreateMap<EEquipmentCategory, EEquipmentCategoryView>();
// CreateMap<EEquipmentCategoryView, EEquipmentCategory>();
// CreateMap<EEquipmentCategoryView, TreeSelect>()
//.ForMember(a => a.id, b => b.MapFrom(x => x.ID))
//.ForMember(a => a.label, b => b.MapFrom(x => x.Name));
// CreateMap<TreeSelect, EEquipmentCategoryView>()
// .ForMember(a => a.ID, b => b.MapFrom(x => x.id))
// .ForMember(a => a.Name, b => b.MapFrom(x => x.label));
}
}
}