|
@@ -0,0 +1,93 @@
|
|
|
+using Azure.Cosmos;
|
|
|
+using Azure.Storage.Blobs.Models;
|
|
|
+using Microsoft.AspNetCore.Authorization;
|
|
|
+using Microsoft.AspNetCore.Http;
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
+using Microsoft.Extensions.Options;
|
|
|
+using StackExchange.Redis;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.ComponentModel.DataAnnotations;
|
|
|
+using System.Dynamic;
|
|
|
+using System.IdentityModel.Tokens.Jwt;
|
|
|
+using System.Linq;
|
|
|
+using System.Net;
|
|
|
+using System.Net.Http;
|
|
|
+using System.Text.Json;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using TEAMModelOS.Models;
|
|
|
+using TEAMModelOS.SDK.DI;
|
|
|
+using TEAMModelOS.SDK.Extension;
|
|
|
+using TEAMModelOS.SDK.Models;
|
|
|
+using TEAMModelOS.SDK.Services;
|
|
|
+using static TEAMModelOS.SDK.Services.BlobService;
|
|
|
+namespace TEAMModelOS.Controllers
|
|
|
+{
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ ///
|
|
|
+ /*
|
|
|
+ AClassONE
|
|
|
+ ee6a461a-3b40-4f70-8842-cf275d1e15ee
|
|
|
+ px-njcS.jL1P7g0-kW:EAkO2Ve7[9k1x
|
|
|
+ 8124850f-03d8-4949-9355-ed0d0709189e
|
|
|
+ l2aR-bk2LfCGt7OjSwRi:qZqfXXhL4:=
|
|
|
+ */
|
|
|
+ /// </summary>
|
|
|
+ [Route("aclassone")]
|
|
|
+ [ApiController]
|
|
|
+ public class AClassONEController : ControllerBase
|
|
|
+ {
|
|
|
+ private readonly HttpClient _httpClient;
|
|
|
+ private readonly AzureStorageFactory _azureStorage;
|
|
|
+ private readonly AzureRedisFactory _azureRedis;
|
|
|
+ private readonly AzureCosmosFactory _azureCosmos;
|
|
|
+ private readonly DingDing _dingDing;
|
|
|
+ private readonly Option _option;
|
|
|
+ private readonly SnowflakeId _snowflakeId;
|
|
|
+
|
|
|
+ public AClassONEController(
|
|
|
+ AzureStorageFactory azureStorage,
|
|
|
+ AzureRedisFactory azureRedis,
|
|
|
+ AzureCosmosFactory azureCosmos,
|
|
|
+ DingDing dingDing,
|
|
|
+ SnowflakeId snowflakeId,
|
|
|
+ IOptionsSnapshot<Option> option, HttpClient httpClient)
|
|
|
+ {
|
|
|
+ _azureStorage = azureStorage;
|
|
|
+ _azureRedis = azureRedis;
|
|
|
+ _azureCosmos = azureCosmos;
|
|
|
+ _dingDing = dingDing;
|
|
|
+ _snowflakeId = snowflakeId;
|
|
|
+ _option = option?.Value;
|
|
|
+ _httpClient = httpClient;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// js_code获取小程序用户信息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="json"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("get-miniapp-userinfo")]
|
|
|
+ //[Authorize(Roles = "AClassONE")]
|
|
|
+ public async Task<IActionResult> GetMiniAPPOpenid( JsonElement json) {
|
|
|
+ if(!json.TryGetProperty("js_code", out JsonElement js_code))return BadRequest("js_code is null") ;
|
|
|
+ string url = $"https://api.weixin.qq.com/sns/jscode2session?appid=wx5705da8747c77cfe&secret=d5adf260a866ca43e74fbb40cec00799&js_code={js_code}&grant_type=authorization_code";
|
|
|
+ HttpResponseMessage responseMessage = await _httpClient.GetAsync(url);
|
|
|
+ if (responseMessage.StatusCode == HttpStatusCode.OK)
|
|
|
+ {
|
|
|
+ JsonDocument document= JsonDocument.Parse(responseMessage.Content.ReadAsStream());
|
|
|
+ // string Content = await responseMessage.Content.ReadAsStringAsync();
|
|
|
+ return Ok(new { miniappData= document });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ string Content = await responseMessage.Content?.ReadAsStringAsync();
|
|
|
+ return BadRequest(Content);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|