CrazyIter_Bin 3 éve
szülő
commit
02c5febc9e

+ 1 - 0
TEAMModelOS.FunctionV4/local.settings.json

@@ -12,6 +12,7 @@
     "Azure:ServiceBus:ItemCondQueue": "dep-itemcond",
     "Option:Location": "China-Dep",
     "HaBookAuth:CoreService:sendnotification": "https://api2.teammodel.net/service/sendnotification",
+    "HaBookAuth:CoreAPI": "https://api2.teammodel.cn",
     "HaBookAuth:CoreService:clientID": "c7317f88-7cea-4e48-ac57-a16071f7b884",
     "HaBookAuth:CoreService:clientSecret": "kguxh:V.PLmxBdaI@jnrTrDSth]A3346"
   }

+ 5 - 5
TEAMModelOS.SDK/DI/CoreAPI/CoreAPIHttpService.cs

@@ -110,25 +110,25 @@ namespace TEAMModelOS.SDK
         /// <param name="data"></param>
         /// <returns></returns>
         public async Task<string> GetUserInfos(StringContent scontent, string name = "Default") {
-            var url = options.Get(name).url;
-            //url = "https://api2-rc.teammodel.cn";
-            url = $"{url}/oauth2/getuserinfos";
+            
             var clientID = options.Get(name).clientID;
             var clientSecret = options.Get(name).clientSecret;
             var location = options.Get(name).location;
+            var url = options.Get(name).url;
             if (location.Contains("China"))
-            {
+            {   url =string.IsNullOrWhiteSpace(url)? "https://api2.teammodel.cn":url;
                 location = "China";
             }
             else if (location.Contains("Global"))
             {
+                url = string.IsNullOrWhiteSpace(url) ? "https://api2.teammodel.net" : url;
                 location = "Global";
             }
+            url = $"{url}/oauth2/getuserinfos";
             var token = await CoreTokenExtensions.CreateAccessToken(clientID, clientSecret, location);
             if (_httpClient.DefaultRequestHeaders.Contains("Authorization"))
             {
                 _httpClient.DefaultRequestHeaders.Remove("Authorization");
-
             }
             _httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
             HttpResponseMessage responseMessage = await _httpClient.PostAsync(url, scontent);

+ 15 - 13
TEAMModelOS.SDK/Models/Service/GroupListService.cs

@@ -770,22 +770,24 @@ namespace TEAMModelOS.SDK
                 ///获取真实的名称 
                 var content = new StringContent(tmdids.Select(x=>x.id).ToJsonString(), Encoding.UTF8, "application/json");
                 string json = await _coreAPIHttpService.GetUserInfos(content);
-                try
-                {
-                    List<TmdInfo> tmdInfos = json.ToObject<List<TmdInfo>>();
-                    if (tmdInfos.IsNotEmpty())
+                if (!string.IsNullOrWhiteSpace(json)) {
+                    try
                     {
-                        tmdsData.ForEach(y =>
+                        List<TmdInfo> tmdInfos = json.ToObject<List<TmdInfo>>();
+                        if (tmdInfos.IsNotEmpty())
                         {
-                            var tmd = tmdInfos.Find(x => x.id.Equals(y.id));
-                            y.name = tmd?.name;
-                            y.picture = tmd?.picture;
-                        });
+                            tmdsData.ForEach(y =>
+                            {
+                                var tmd = tmdInfos.Find(x => x.id.Equals(y.id));
+                                y.name = tmd?.name;
+                                y.picture = tmd?.picture;
+                            });
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        await _dingDing.SendBotMsg($"{_coreAPIHttpService.options.Get("Default").location}用户转换失败:{_coreAPIHttpService.options.Get("Default").url}{json}\n {ex.StackTrace}", GroupNames.成都开发測試群組);
                     }
-                }
-                catch (Exception ex)
-                {
-                    await _dingDing.SendBotMsg($"用户转换失败:{json}\n {ex.StackTrace}", GroupNames.成都开发測試群組);
                 }
                 tmdids.ForEach(x =>
                 {