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.
 
 
 

114 lines
3.3 KiB

using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using AutoMapper;
using Volo.Abp.AutoMapper;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Timing;
using Win_in.Sfs.Scp.WebApi.Asns;
namespace Win_in.Sfs.Scp.WebApi
{
public class WebApiApplicationAutoMapperProfile : Profile
{
public WebApiApplicationAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
CreateMapPart();
CreateMapSupplier();
CreateMapReceipt();
CreateMapPurchaseOrder();
CreateMapPurchaseOrderDetail();
CreateMapUnplannedReceipt();
CreateMapX12Asn();
}
/// <summary>
/// 零件实体与Dto映射
/// </summary>
private void CreateMapPart()
{
CreateMap<Part, PartDTO>();
CreateMap<PartCreateDto, Part>()
.Ignore(p => p.Id)
.Ignore(p => p.CreatorId)
.Ignore(p => p.CreationTime);
}
/// <summary>
/// 供应商实体与Dto相互映射
/// </summary>
private void CreateMapSupplier()
{
CreateMap<Supplier, SupplierDTO>();
CreateMap<SupplierCreateDTO, Supplier>()
.Ignore(p => p.Id)
.Ignore(p => p.CreatorId)
.Ignore(p => p.CreationTime);
}
/// <summary>
/// 收货单与退货单明细实体与Dto映射
/// </summary>
private void CreateMapReceipt()
{
CreateMap<Receipt, ReceiptDTO>();
CreateMap<ReceiptCreateDTO, Receipt>()
.Ignore(p => p.Id)
.Ignore(p => p.CreatorId)
.Ignore(p => p.CreationTime);
}
/// <summary>
/// 采购订单主表映射
/// </summary>
private void CreateMapPurchaseOrder()
{
CreateMap<PurchaseOrder, PurchaseOrderDTO>();
CreateMap<PurchaseOrderCreateDTO, PurchaseOrder>()
.Ignore(p => p.Id)
.Ignore(p => p.CreatorId)
.Ignore(p => p.CreationTime);
}
/// <summary>
/// 采购订单明细表映射
/// </summary>
private void CreateMapPurchaseOrderDetail()
{
CreateMap<PurchaseOrderDetail, PurchaseOrderDetailDTO>();
CreateMap<PurchaseOrderDetailCreateDTO, PurchaseOrderDetail>()
.Ignore(p => p.Id)
.Ignore(p => p.CreatorId)
.Ignore(p => p.CreationTime);
}
private void CreateMapUnplannedReceipt()
{
CreateMap<UnplannedReceipt, UnplannedReceiptDTO>();
CreateMap<UnplannedReceiptCreateDTO, UnplannedReceipt>()
.Ignore(p => p.Id)
.Ignore(p => p.CreatorId)
.Ignore(p => p.CreationTime);
}
private void CreateMapX12Asn()
{
CreateMap<X12Asn, X12AsnDTO>()
.Ignore(p => p.Scpedi)
.AfterMap((src, dto) => dto.Scpedi = src.EdiString?.Split("\r\n").ToList())
;
}
}
}