feat: 商户类目数据库化并增加权限种子
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TakeoutSaaS.Application.App.Merchants.Dto;
|
||||
using TakeoutSaaS.Domain.Merchants.Entities;
|
||||
|
||||
namespace TakeoutSaaS.Application.App.Merchants;
|
||||
|
||||
/// <summary>
|
||||
/// 商户 DTO 映射工具。
|
||||
/// </summary>
|
||||
internal static class MerchantMapping
|
||||
{
|
||||
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
|
||||
};
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
public static MerchantCategoryDto ToDto(MerchantCategory category) => new()
|
||||
{
|
||||
Id = category.Id,
|
||||
Name = category.Name,
|
||||
DisplayOrder = category.DisplayOrder,
|
||||
IsActive = category.IsActive,
|
||||
CreatedAt = category.CreatedAt
|
||||
};
|
||||
|
||||
public static IReadOnlyList<MerchantDocumentDto> ToDocumentDtos(IEnumerable<MerchantDocument> documents)
|
||||
=> documents.Select(ToDto).ToList();
|
||||
|
||||
public static IReadOnlyList<MerchantContractDto> ToContractDtos(IEnumerable<MerchantContract> contracts)
|
||||
=> contracts.Select(ToDto).ToList();
|
||||
|
||||
public static IReadOnlyList<MerchantCategoryDto> ToCategoryDtos(IEnumerable<MerchantCategory> categories)
|
||||
=> categories.Select(ToDto).ToList();
|
||||
}
|
||||
Reference in New Issue
Block a user