统一返回认证地址和号码

This commit is contained in:
马梓彭 2026-06-21 15:07:35 +08:00
parent b7b7709e0c
commit b7440c99ab
2 changed files with 50 additions and 3 deletions

View File

@ -51,7 +51,36 @@ public class AppUserService : BaseService<AppUserEntity>, ITransient
.WhereIF(input.EndTime.HasValue, u => u.CreatedTime <= input.EndTime)
.OrderByDescending(u => u.CreatedTime);
return await query.Select<AppUserOutput>().ToPagedListAsync(input);
var result = await query.Select<AppUserOutput>().ToPagedListAsync(input);
// 根据认证类型填充统一的 CertImageUrl 和 CertNumber 字段
foreach (var item in result.Rows)
{
FillCertFields(item);
}
return result;
}
/// <summary>
/// 根据认证类型填充统一的认证证件字段(CertImageUrl, CertNumber)
/// </summary>
private static void FillCertFields(AppUserOutput output)
{
output.CertImageUrl = output.AuthType switch
{
1 => output.IdCardImageUrl,
2 => output.PassportPhotoUrl,
3 => output.HouseholdPhotoUrl,
_ => output.IdCardImageUrl ?? output.HouseholdPhotoUrl ?? output.PassportPhotoUrl
};
output.CertNumber = output.AuthType switch
{
1 or 3 => output.IdCardNumber,
2 => output.PassportNumber,
_ => output.IdCardNumber ?? output.PassportNumber
};
}
/// <summary>
@ -63,10 +92,15 @@ public class AppUserService : BaseService<AppUserEntity>, ITransient
[HttpGet("{id}")]
public async Task<AppUserOutput> Detail([FromRoute] long id)
{
return await _appUserRep.AsQueryable()
var output = await _appUserRep.AsQueryable()
.Where(u => u.Id == id)
.Select<AppUserOutput>()
.FirstAsync();
// 根据认证类型填充统一的 CertImageUrl 和 CertNumber 字段
FillCertFields(output);
return output;
}
/// <summary>

View File

@ -313,10 +313,23 @@ public class AppUserOutput
public string? HouseholdPhotoUrl { get; set; }
/// <summary>
/// 认证类型:1-身份证,2-护照,3-户口本
/// 认证类型:0-未认证,1-身份证,2-护照,3-户口本
/// </summary>
public int AuthType { get; set; }
/// <summary>
/// 认证证件图片URL(根据AuthType返回对应证件的图片URL)
/// AuthType=1 → IdCardImageUrl
/// AuthType=2 → PassportPhotoUrl
/// AuthType=3 → HouseholdPhotoUrl
/// </summary>
public string? CertImageUrl { get; set; }
/// <summary>
/// 证件号码(根据AuthType返回:身份证号或护照号)
/// </summary>
public string? CertNumber { get; set; }
/// <summary>
/// 审核状态
/// </summary>