Browse Source

[BI]TMID取得IOT資料API修正

jeff 1 year ago
parent
commit
ee554f50e4

+ 5 - 6
TEAMModelBI/Controllers/BITmid/TmidController.cs

@@ -187,21 +187,20 @@ namespace TEAMModelBI.Controllers.BITmid
                             if (string.IsNullOrWhiteSpace(tmidStics.mobile)) tmidStics.mobile = GenDataMask(doc.GetProperty("mobile").GetString(), "mobile");
                             if (string.IsNullOrWhiteSpace(tmidStics.mail)) tmidStics.mail = GenDataMask(doc.GetProperty("mail").GetString(), "mail");
                             string country = doc.GetProperty("country").GetString();
-                            tmidStics.country = (regionData.country.ContainsKey(country)) ? regionData.country[country].name : country;
-                            tmidStics.country = tmidStics.country.Replace("地區", "").Replace("地区", "");
                             string province = doc.GetProperty("province").GetString();
                             string city = doc.GetProperty("city").GetString();
                             string district = string.Empty;
-                            if (country.Equals("TW"))
+                            if (!string.IsNullOrWhiteSpace(country) && country.Equals("TW"))
                             {
                                 district = city;
                                 city = province;
                                 province = string.Empty;
                             }
-                            tmidStics.province = (regionData.country.ContainsKey(country) && !string.IsNullOrWhiteSpace(province) && regionData.province.ContainsKey(country) && regionData.province[country].ContainsKey(province)) ? regionData.province[country][province].name : province;
-                            if (country.Equals("TW"))
+                            tmidStics.country = (!string.IsNullOrWhiteSpace(country) && regionData.country.ContainsKey(country)) ? regionData.country[country].name.Replace("地區", "").Replace("地区", "") : country;
+                            tmidStics.province = (!string.IsNullOrWhiteSpace(country) && regionData.country.ContainsKey(country) && !string.IsNullOrWhiteSpace(province) && regionData.province.ContainsKey(country) && regionData.province[country].ContainsKey(province)) ? regionData.province[country][province].name : province;
+                            if (!string.IsNullOrWhiteSpace(country) && country.Equals("TW"))
                                 tmidStics.city = (regionData.city.ContainsKey(country) && !string.IsNullOrWhiteSpace(city) && regionData.city[country]["tw"].ContainsKey(city)) ? regionData.city[country]["tw"][city].name : city;
-                            else if(country.Equals("CN"))
+                            else if(!string.IsNullOrWhiteSpace(country) && country.Equals("CN"))
                                 tmidStics.city = (regionData.city.ContainsKey(country) && regionData.city[country].ContainsKey(province) && regionData.city[country][province].ContainsKey(city)) ? regionData.city[country][province][city].name : city;
                             tmidStics.dist = (!string.IsNullOrWhiteSpace(district) && country.Equals("TW") && regionData.city[country]["tw"].ContainsKey(city) && regionData.dist[country]["tw"][city].ContainsKey(district)) ? regionData.dist[country]["tw"][city][district].name : district;
                             tmidStics.schoolCode = (doc.TryGetProperty("schoolCode", out JsonElement schCode)) ? schCode.GetString() : string.Empty;

+ 1 - 1
TEAMModelOS/Controllers/Student/StudentController.cs

@@ -995,7 +995,7 @@ namespace TEAMModelOS.Controllers
         }
 
         /// <summary>
-        /// 學生追加教育雲ID
+        /// 學生解綁教育雲ID
         /// </summary>
         /// <param name = "request" ></ param >
         [AllowAnonymous]