فهرست منبع

update .学科网。API

CrazyIter_Bin 3 سال پیش
والد
کامیت
3968eb98a4

+ 12 - 0
TEAMModelOS.SDK/Models/Service/Third/Xkw/XkwOAuthModel.cs

@@ -26,6 +26,18 @@ namespace TEAMModelOS.SDK.Models
         /// </summary>
         public string AppSecret { get; set; }
         /// <summary>
+        /// 接口key
+        /// </summary>
+        public string ApiKey { get; set; }
+        /// <summary>
+        /// 接口Secret
+        /// </summary>
+        public string ApiSecret { get; set; }
+        /// <summary>
+        /// 接口Url
+        /// </summary>
+        public string ApiUrl { get; set; }
+        /// <summary>
         /// 单点回调地址
         /// </summary>
         public string RedirectUrl { get; set; }

+ 16 - 6
TEAMModelOS/Controllers/Third/Xkw/Sdk/XkwAPIHttpService.cs

@@ -50,12 +50,22 @@ namespace TEAMModelOS.Controllers.Third.Xkw.Sdk
             options = optionsMonitor;
             var table = _azureStorageFactory.GetCloudTableClient().GetTableReference("IESOAuth");
 
-            string domain = "w";
-
-          //  List<OAuthComConfig> configs = await table.FindListByDict<OAuthComConfig>(new Dictionary<string, object>() { { "PartitionKey", "OAuthComConfig" }, { "RowKey", RowKey } });
-            this.baseUrl = baseUrl;
-            this.appId = appId;
-            this.secret = secret;
+            string domain = "www.teammodel.cn";
+            string  location = options.Get("Default").location;
+            if (location.Equals("China-Test")) {
+                domain = "test.teammodel.cn";
+            }
+            if (location.Equals("China-Dep"))
+            {
+                domain = "kong.sso.com";
+            }
+            string RowKey = $"xkw-{domain}";
+            List<OAuthComConfig> configs =   table.FindListByDictSync<OAuthComConfig>(new Dictionary<string, object>() { { "PartitionKey", "OAuthComConfig" }, { "RowKey", RowKey } });
+            if (configs.Any()) {
+                this.baseUrl = configs[0].ApiUrl;
+                this.appId = configs[0].ApiKey;
+                this.secret = configs[0].ApiSecret;
+            }
         }
 
 

+ 6 - 1
TEAMModelOS/Controllers/Third/Xkw/XkwServiceController.cs

@@ -33,6 +33,8 @@ using TEAMModelOS.Filter;
 using TEAMModelOS.Controllers.Third.Xkw;
 using Microsoft.Extensions.Primitives;
 using System.Net.Http;
+using TEAMModelOS.Controllers.Third.Xkw.Sdk;
+
 namespace TEAMModelOS.Controllers.Third.Xkw
 { 
     // <summary>
@@ -58,8 +60,9 @@ namespace TEAMModelOS.Controllers.Third.Xkw
         private readonly ThirdApisService _scsApisService;
         private readonly HttpTrigger _httpTrigger;
         private readonly IWebHostEnvironment _environment;
+        private readonly XkwAPIHttpService _xkwAPIHttpService;
         public IConfiguration _configuration { get; set; }
-        public XkwServiceController(IWebHostEnvironment environment, AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option, AzureStorageFactory azureStorage,
+        public XkwServiceController(XkwAPIHttpService xkwAPIHttpService, IWebHostEnvironment environment, AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option, AzureStorageFactory azureStorage,
             AzureRedisFactory azureRedis, AzureServiceBusFactory serviceBus, IConfiguration configuration, CoreAPIHttpService coreAPIHttpService, ThirdApisService scsApisService, HttpTrigger httpTrigger)
         {
             _azureCosmos = azureCosmos;
@@ -74,6 +77,7 @@ namespace TEAMModelOS.Controllers.Third.Xkw
             _scsApisService = scsApisService;
             _httpTrigger = httpTrigger;
             _environment = environment;
+            _xkwAPIHttpService=xkwAPIHttpService;
         }
 
         [HttpGet("paper-notice")]
@@ -81,6 +85,7 @@ namespace TEAMModelOS.Controllers.Third.Xkw
         //[AuthToken(Roles = "teacher,admin,area,student")]
         public async Task<IActionResult> PaperNotice([FromQuery] OAuthCode authCode)
         {
+           var a = _xkwAPIHttpService.Get<JsonElement>("/xopqbm/courses/all", null);
             await _dingDing.SendBotMsg($"学科网推送消息:{authCode.ToJsonString()}", GroupNames.成都开发測試群組);
             return Ok();
         }