using TakeoutSaaS.Application.App.Merchants.Dto;
using TakeoutSaaS.Domain.Merchants.Entities;
namespace TakeoutSaaS.Application.App.Merchants;
///
/// 商户 DTO 映射工具。
///
internal static class MerchantMapping
{
///
/// 将商户实体映射为 DTO。
///
/// 商户实体。
/// 商户 DTO。
public static MerchantDto ToDto(Merchant merchant) => new()
{
Id = merchant.Id,
TenantId = merchant.TenantId,
BrandName = merchant.BrandName,
BrandAlias = merchant.BrandAlias,
LogoUrl = merchant.LogoUrl,
Category = merchant.Category,
ContactPhone = merchant.ContactPhone,
ContactEmail = merchant.ContactEmail,
Status = merchant.Status,
JoinedAt = merchant.JoinedAt,
CreatedAt = merchant.CreatedAt
};
///
/// 将商户证照实体映射为 DTO。
///
/// 证照实体。
/// 证照 DTO。
public static MerchantDocumentDto ToDto(MerchantDocument document) => new()
{
Id = document.Id,
MerchantId = document.MerchantId,
DocumentType = document.DocumentType,
Status = document.Status,
FileUrl = document.FileUrl,
DocumentNumber = document.DocumentNumber,
IssuedAt = document.IssuedAt,
ExpiresAt = document.ExpiresAt,
Remarks = document.Remarks,
CreatedAt = document.CreatedAt
};
///
/// 将商户合同实体映射为 DTO。
///
/// 合同实体。
/// 合同 DTO。
public static MerchantContractDto ToDto(MerchantContract contract) => new()
{
Id = contract.Id,
MerchantId = contract.MerchantId,
ContractNumber = contract.ContractNumber,
Status = contract.Status,
StartDate = contract.StartDate,
EndDate = contract.EndDate,
FileUrl = contract.FileUrl,
SignedAt = contract.SignedAt,
TerminatedAt = contract.TerminatedAt,
TerminationReason = contract.TerminationReason
};
///
/// 将商户审核日志实体映射为 DTO。
///
/// 审核日志实体。
/// 审核日志 DTO。
public static MerchantAuditLogDto ToDto(MerchantAuditLog log) => new()
{
Id = log.Id,
MerchantId = log.MerchantId,
Action = log.Action,
Title = log.Title,
Description = log.Description,
OperatorName = log.OperatorName,
CreatedAt = log.CreatedAt
};
///
/// 将商户分类实体映射为 DTO。
///
/// 分类实体。
/// 分类 DTO。
public static MerchantCategoryDto ToDto(MerchantCategory category) => new()
{
Id = category.Id,
Name = category.Name,
DisplayOrder = category.DisplayOrder,
IsActive = category.IsActive,
CreatedAt = category.CreatedAt
};
///
/// 将证照集合映射为 DTO 集合。
///
/// 证照集合。
/// 证照 DTO 列表。
public static IReadOnlyList ToDocumentDtos(IEnumerable documents)
=> documents.Select(ToDto).ToList();
///
/// 将合同集合映射为 DTO 集合。
///
/// 合同集合。
/// 合同 DTO 列表。
public static IReadOnlyList ToContractDtos(IEnumerable contracts)
=> contracts.Select(ToDto).ToList();
///
/// 将分类集合映射为 DTO 集合。
///
/// 分类集合。
/// 分类 DTO 列表。
public static IReadOnlyList ToCategoryDtos(IEnumerable categories)
=> categories.Select(ToDto).ToList();
}