68 lines
2.4 KiB
C#
68 lines
2.4 KiB
C#
using System.Net.Http.Headers;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
using Dlhis.Basic.Organization.Request;
|
|
using Dlhis.Basic.Organization.Response;
|
|
using Dlhis.Basic.Organization.Services;
|
|
using HttpUtil;
|
|
using Kurisu.AspNetCore.Utils.Extensions;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Dlhis.Basic.Organization.Controllers;
|
|
|
|
/// <summary>
|
|
/// 档案人脸
|
|
/// </summary>
|
|
[Authorize]
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class GainfoFacesController : ControllerBase
|
|
{
|
|
private readonly IGainfoFaceService _gainfoFaceService;
|
|
private readonly IHttpClientFactory _httpClientFactory;
|
|
|
|
public GainfoFacesController(IGainfoFaceService gainfoFaceService, IHttpClientFactory httpClientFactory)
|
|
{
|
|
_gainfoFaceService = gainfoFaceService;
|
|
_httpClientFactory = httpClientFactory;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 人脸档案分页
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("page")]
|
|
public async Task<GainfoFacePageSummaryResponse> GetPageAsync([FromQuery] GainfoFacePageRequest request)
|
|
{
|
|
return await _gainfoFaceService.GetPageAsync(request);
|
|
}
|
|
|
|
[AllowAnonymous]
|
|
[HttpPost("test")]
|
|
public async Task<string> TestAsync(GainfoFaceValidateRequest request)
|
|
{
|
|
var client = _httpClientFactory.CreateClient("hik-openapi");
|
|
var body = request.ToJson(JsonExtensions.DefaultSetting);
|
|
var url = "/artemis/api/frs/v1/application/oneToOne";
|
|
var key = "27390082";
|
|
var secret = "MLl7Dv7p5Pgc9XYI3r4O";
|
|
|
|
HttpUtillib.SetPlatformInfo(key, secret, "10.32.0.10");
|
|
var r = HttpUtillib.HttpPost(url, body, 15);
|
|
return Encoding.UTF8.GetString(r) + "\r\n " + body;
|
|
|
|
// var headers = InitRequest(url, body, key, secret);
|
|
// client.DefaultRequestHeaders.Accept.Clear();
|
|
// client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(headers["Accept"]));
|
|
// var content = new StringContent(body, Encoding.UTF8, "application/json");
|
|
// foreach (var item in headers.Where(x => x.Key != "Accept").Where(x => x.Key != "Content-Type"))
|
|
// {
|
|
// content.Headers.Add(item.Key, item.Value);
|
|
// }
|
|
//
|
|
// var r = await client.PostAsync(url, content);
|
|
// return await r.Content.ReadAsStringAsync();
|
|
}
|
|
} |