fix 优化本地离线和在线消费处理

This commit is contained in:
2024-06-27 10:32:23 +08:00
parent a405af0435
commit cec075bae9
10 changed files with 282 additions and 39 deletions

View File

@@ -0,0 +1,36 @@
using System.Text;
using Dlhis.Middle.Request;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
namespace Dlhis.Middle.Controllers;
/// <summary>
/// OAuth2认证
/// </summary>
[Route("api/user/[controller]")]
[ApiController]
public class OAuth2Controller : ControllerBase
{
private readonly IHttpClientFactory _httpClientFactory;
private readonly IConfiguration _configuration;
public OAuth2Controller(IHttpClientFactory httpClientFactory, IConfiguration configuration)
{
_httpClientFactory = httpClientFactory;
_configuration = configuration;
}
[HttpPost("clientgrant")]
public async Task<object> ClientGrant(ClientGrantRequest request)
{
var authority = _configuration.GetSection("Authority").Value;
var httpClient = _httpClientFactory.CreateClient();
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}/connect/token", content);
var result = await response.Content.ReadAsStringAsync();
return JObject.Parse(result);
}
}

View File

@@ -12,7 +12,7 @@ namespace Dlhis.Middle.Controllers;
/// 订单
/// </summary>
[Authorize]
[Route("api/[controller]")]
[Route("api/canteen/[controller]")]
[ApiController]
public class OrdersController : ControllerBase
{