feat 批量获取人口post
This commit is contained in:
@@ -127,12 +127,12 @@ public class GainfosController : ControllerBase
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 批量获取人脸照片
|
/// 批量获取人脸照片
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userCodes"></param>
|
/// <param name="request"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("faces")]
|
[HttpPost("faces")]
|
||||||
public async Task<Dictionary<string, string>> GetFaceByUserCodesAsync([FromQuery] List<string> userCodes)
|
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<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)
|
public async Task<string> GetFaceByUserCodeAsync(string userCode)
|
||||||
{
|
{
|
||||||
var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.Code == userCode).SingleAsync();
|
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) =>
|
return await Scoped.Request.Value.CreateAsync<string>(async (sp) =>
|
||||||
{
|
{
|
||||||
@@ -328,16 +328,15 @@ public class GainfoService : IGainfoService
|
|||||||
return faceUrl + token;
|
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>();
|
var faceDictionary = new Dictionary<string, string>();
|
||||||
|
|
||||||
foreach (var userCode in userCodes)
|
foreach (var userCode in request.UserCodes)
|
||||||
{
|
{
|
||||||
var faceUrl = await GetFaceByUserCodeAsync(userCode);
|
var faceUrl = await GetFaceByUserCodeAsync(userCode);
|
||||||
faceDictionary.Add(userCode, faceUrl);
|
faceDictionary.Add(userCode, faceUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
return faceDictionary;
|
return faceDictionary;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user