fix 任务图片连接处理
This commit is contained in:
52
Src/Dlhis.Middle/Controllers/GainfosController.cs
Normal file
52
Src/Dlhis.Middle/Controllers/GainfosController.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Dlhis.Middle.Filters;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.Middle.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// sap档案表
|
||||
/// </summary>
|
||||
[Route("api/basic/[controller]")]
|
||||
[ApiController]
|
||||
public class GainfosController : ControllerBase
|
||||
{
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public GainfosController(IHttpClientFactory httpClientFactory, IConfiguration configuration)
|
||||
{
|
||||
_httpClientFactory = httpClientFactory;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过token获取人脸照片,失效或者找不到返回HttpStatus404状态码
|
||||
/// </summary>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
[NotFound]
|
||||
[AllowAnonymous]
|
||||
[HttpGet("face")]
|
||||
public async Task<IActionResult> GetFaceAsync(string token)
|
||||
{
|
||||
var hostName = _configuration.GetSection("HostName").Value;
|
||||
var httpClient = _httpClientFactory.CreateClient();
|
||||
|
||||
try
|
||||
{
|
||||
var faceBytes = await httpClient.GetByteArrayAsync($"https://{hostName}/api/basic/gainfos/face?token={token}");
|
||||
|
||||
if (faceBytes.Length == 0)
|
||||
{
|
||||
return new NotFoundResult();
|
||||
}
|
||||
|
||||
return new FileContentResult(faceBytes, "image/png");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return new NotFoundResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user