Browse Source

处理查询学校参数问题

Li 2 năm trước cách đây
mục cha
commit
4fb77b43c8
1 tập tin đã thay đổi với 11 bổ sung5 xóa
  1. 11 5
      TEAMModelBI/Controllers/BISchool/BatchSchoolController.cs

+ 11 - 5
TEAMModelBI/Controllers/BISchool/BatchSchoolController.cs

@@ -508,6 +508,10 @@ namespace TEAMModelBI.Controllers.BISchool
                 jsonElement.TryGetProperty("name", out JsonElement name);
                 jsonElement.TryGetProperty("order", out JsonElement order);
 
+                jsonElement.TryGetProperty("province", out JsonElement province);
+                jsonElement.TryGetProperty("city", out JsonElement city);
+                jsonElement.TryGetProperty("dist", out JsonElement dist);
+
                 //jsonElement.TryGetProperty("site", out JsonElement site);//分开部署,就不需要,一站多用时,取消注释
                 var cosmosClient = _azureCosmos.GetCosmosClient();
                 ////分开部署,就不需要,一站多用时,取消注释
@@ -564,14 +568,16 @@ namespace TEAMModelBI.Controllers.BISchool
                 else
                 {
                     if (!string.IsNullOrEmpty($"{scId}") && string.IsNullOrEmpty($"{name}"))
-                    {
                         stringBuilder.Append($" where c.id='{scId}'");
-                    }
-
                     if (string.IsNullOrEmpty($"{scId}") && !string.IsNullOrEmpty($"{name}"))
-                    {
                         stringBuilder.Append($" where Contains(c.name,'{name}')");
-                    }
+                    if (!string.IsNullOrEmpty($"{province}") && string.IsNullOrEmpty($"{city}") && string.IsNullOrEmpty($"{dist}"))
+                        stringBuilder.Append($" where Contains(c.province,'{province}')");
+                    if (!string.IsNullOrEmpty($"{city}") && !string.IsNullOrEmpty($"{city}") && string.IsNullOrEmpty($"{dist}"))
+                        stringBuilder.Append($" where Contains(c.province,'{province}') and Contains(c.city,'{city}')");
+                    if (!string.IsNullOrEmpty($"{dist}") && !string.IsNullOrEmpty($"{city}") && !string.IsNullOrEmpty($"{dist}"))
+                        stringBuilder.Append($" where Contains(c.province,'{province}') and Contains(c.city,'{city}') and Contains(c.dist,'{dist}')");
+
                     if ($"{order}".Equals("desc"))
                     {
                         stringBuilder.Append(" order by c.createTime desc");