31 lines
1.4 KiB
C#
31 lines
1.4 KiB
C#
using AgriculturalPlatform.Api.Models;
|
|
|
|
namespace AgriculturalPlatform.Api.Dtos;
|
|
|
|
public record FarmerDto(
|
|
int Id, string Name, string PinyinInitials, string IdCard, string Gender, string FarmerType, string Phone,
|
|
string Province, string County, string Township, string Village, string GroupName,
|
|
string Address, string BankName, string BankAccount, int CreditScore,
|
|
string IdCardFrontUrl, string IdCardBackUrl, string AvatarUrl,
|
|
string Status, string Notes, DateTime CreatedAt);
|
|
|
|
public record FarmerSaveRequest(
|
|
string Name, string IdCard, string Gender, string Phone,
|
|
string Province, string County, string Township, string Village, string GroupName,
|
|
string Address, string BankName, string BankAccount, int CreditScore = 80,
|
|
string FarmerType = "农户",
|
|
string IdCardFrontUrl = "", string IdCardBackUrl = "", string AvatarUrl = "",
|
|
string Status = "Active", string Notes = "", string PinyinInitials = "");
|
|
|
|
public static class FarmerMappers
|
|
{
|
|
public static FarmerDto ToDto(this Farmer f) => new(
|
|
f.Id, f.Name, f.PinyinInitials, f.IdCard, f.Gender, f.FarmerType, f.Phone,
|
|
f.Province, f.County, f.Township, f.Village, f.GroupName,
|
|
f.Address, f.BankName, f.BankAccount, f.CreditScore,
|
|
f.IdCardFrontUrl, f.IdCardBackUrl, f.AvatarUrl,
|
|
f.Status.ToString(), f.Notes, f.CreatedAt);
|
|
|
|
public static FarmerDto[] ToDtos(this IEnumerable<Farmer> items) => items.Select(ToDto).ToArray();
|
|
}
|