feat 批量获取人口post
This commit is contained in:
@@ -127,12 +127,12 @@ public class GainfosController : ControllerBase
|
||||
/// <summary>
|
||||
/// 批量获取人脸照片
|
||||
/// </summary>
|
||||
/// <param name="userCodes"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("faces")]
|
||||
public async Task<Dictionary<string, string>> GetFaceByUserCodesAsync([FromQuery] List<string> userCodes)
|
||||
[HttpPost("faces")]
|
||||
public async Task<Dictionary<string, string>> GetFaceByUserCodesAsync(GetFaceByUserCodesRequest request)
|
||||
{
|
||||
return await _gainfoService.GetFaceByUserCodesAsync(userCodes);
|
||||
return await _gainfoService.GetFaceByUserCodesAsync(request);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Dlhis.Basic.Organization.Request
|
||||
{
|
||||
public class GetFaceByUserCodesRequest
|
||||
{
|
||||
public List<string> UserCodes { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -25,5 +25,5 @@ public interface IGainfoService : IScopeDependency
|
||||
|
||||
Task<string> GetFaceByUserCodeAsync(string userCode);
|
||||
|
||||
Task<Dictionary<string, string>> GetFaceByUserCodesAsync(List<string> userCodes);
|
||||
Task<Dictionary<string, string>> GetFaceByUserCodesAsync(GetFaceByUserCodesRequest request);
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ public class GainfoService : IGainfoService
|
||||
public async Task<string> GetFaceByUserCodeAsync(string userCode)
|
||||
{
|
||||
var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.Code == userCode).SingleAsync();
|
||||
gainfo.ThrowIfNull("人员信息不存在");
|
||||
gainfo.ThrowIfNull($"{userCode}人员信息不存在");
|
||||
|
||||
return await Scoped.Request.Value.CreateAsync<string>(async (sp) =>
|
||||
{
|
||||
@@ -328,16 +328,15 @@ public class GainfoService : IGainfoService
|
||||
return faceUrl + token;
|
||||
});
|
||||
}
|
||||
public async Task<Dictionary<string, string>> GetFaceByUserCodesAsync(List<string> userCodes)
|
||||
public async Task<Dictionary<string, string>> GetFaceByUserCodesAsync(GetFaceByUserCodesRequest request)
|
||||
{
|
||||
var faceDictionary = new Dictionary<string, string>();
|
||||
|
||||
foreach (var userCode in userCodes)
|
||||
foreach (var userCode in request.UserCodes)
|
||||
{
|
||||
var faceUrl = await GetFaceByUserCodeAsync(userCode);
|
||||
faceDictionary.Add(userCode, faceUrl);
|
||||
}
|
||||
|
||||
return faceDictionary;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user