fix 多钱包调整

This commit is contained in:
2024-11-08 16:36:10 +08:00
parent 36bfd2e8f6
commit 1a0ba28249
36 changed files with 418 additions and 434 deletions

View File

@@ -1,5 +1,5 @@
using Dlhis.Entity.Device.Enums;
using Dlhis.Middle.Api;
using Dlhis.Middle.Apis;
using Dlhis.Middle.Request;
using Dlhis.Middle.Response;
using Dlhis.Middle.Services;

View File

@@ -1,4 +1,4 @@
using Dlhis.Middle.Api;
using Dlhis.Middle.Apis;
using Dlhis.Middle.Request;
using Dlhis.Middle.Response;
using Dlhis.Middle.Services;

View File

@@ -1,4 +1,5 @@
using Dlhis.Middle.Filters;
using Dlhis.Middle.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -12,14 +13,13 @@ namespace Dlhis.Middle.Controllers;
public class GainfosController : ControllerBase
{
private readonly IHttpClientFactory _httpClientFactory;
private readonly IConfiguration _configuration;
private readonly ILogger<GainfosController> _logger;
private readonly ISettingService _settingService;
public GainfosController(IHttpClientFactory httpClientFactory, IConfiguration configuration, ILogger<GainfosController> logger)
public GainfosController(IHttpClientFactory httpClientFactory,
ISettingService settingService)
{
_httpClientFactory = httpClientFactory;
_configuration = configuration;
_logger = logger;
_settingService = settingService;
}
/// <summary>
@@ -32,14 +32,11 @@ public class GainfosController : ControllerBase
[HttpGet("face")]
public async Task<IActionResult> GetFaceAsync(string token)
{
var hostName = _configuration.GetSection("HostName").Value;
var httpClient = _httpClientFactory.CreateClient("face");
_logger.LogInformation("token:{token}", token);
var httpClient = _httpClientFactory.CreateClient();
try
{
var faceBytes = await httpClient.GetByteArrayAsync($"https://{hostName}/api/basic/gainfos/face?token={token}");
var faceBytes = await httpClient.GetByteArrayAsync($"{_settingService.GetBaseUrl()}/api/basic/gainfos/face?token={token}");
if (faceBytes.Length == 0)
{

View File

@@ -1,4 +1,5 @@
using System.Text;
using Dlhis.Middle.Apis;
using Dlhis.Middle.Request;
using Dlhis.Middle.Services;
using Microsoft.AspNetCore.Mvc;
@@ -13,23 +14,20 @@ namespace Dlhis.Middle.Controllers;
[ApiController]
public class OAuth2Controller : ControllerBase
{
private readonly IHttpClientFactory _httpClientFactory;
private readonly IConfiguration _configuration;
private readonly ICommonApi _commonApi;
private readonly IHealthCheckService _healthCheckService;
public OAuth2Controller(IHttpClientFactory httpClientFactory, IConfiguration configuration, IHealthCheckService healthCheckService)
public OAuth2Controller(
ICommonApi commonApi,
IHealthCheckService healthCheckService)
{
_httpClientFactory = httpClientFactory;
_configuration = configuration;
_commonApi = commonApi;
_healthCheckService = healthCheckService;
}
[HttpPost("clientgrant")]
public async Task<object> ClientGrant(ClientGrantRequest request)
{
var authority = _configuration.GetSection("Authority").Value;
var httpClient = _httpClientFactory.CreateClient("face");
if (_healthCheckService.GetIsOffline())
{
return new
@@ -41,9 +39,12 @@ public class OAuth2Controller : ControllerBase
};
}
var content = new StringContent($"grant_type=client_credentials&client_id={request.ClientId}&client_secret={request.ClientSecret}&scope={request.Scope}", Encoding.UTF8, "application/x-www-form-urlencoded");
var response = await httpClient.PostAsync($"{authority}/oauth2/connect/token", content);
var result = await response.Content.ReadAsStringAsync();
return JObject.Parse(result);
var r = await _commonApi.AuthAsync(new
{
request.ClientId,
request.ClientSecret
});
return r.Data;
}
}