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,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;
}
}