Prechádzať zdrojové kódy

修改語言文字為簡體 / 增加檢查學校簡碼邏輯

upon 1 rok pred
rodič
commit
6c282e422b

+ 12 - 3
TEAMModelBI/Controllers/BINormal/BatchAreaController.cs

@@ -686,7 +686,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 // 檢查是否有大寫或是中文字
                 if ( Regex.IsMatch(shortCode, @"[^a-z0-9]") )
                 {
-                    return Ok(new { state = 1, message = "此區級簡碼必須為小寫字母!" });
+                    return Ok(new { state = 1, message = "此区级简码必须为小写字母!" });
                 }             
 
                 string sqlCheckRep =  $"SELECT c.id FROM c WHERE c.shortCode = '{shortCode}'";
@@ -696,10 +696,19 @@ namespace TEAMModelBI.Controllers.BINormal
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0)
                     {
-                        return Ok(new { state = 1, message = "区级名称相同,请检测区级名称!" });
+                        return Ok(new { state = 1, message = "此学区简码与其他 [学区] 简码相同请检查!" });
                     }                    
                 }
-                
+                await foreach (var item in _azureCosmosClientCsv2Read.GetContainer("Core", "School").GetItemQueryStreamIterator(queryText: sqlCheckRep, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base") }))
+                {
+                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0)
+                    {
+                        return Ok(new { state = 1, message = "此学区简码与其他 [学校] 简码相同请检查!" });
+                    }
+                }
+
+
                 //DB值更新
                 if (!string.IsNullOrWhiteSpace(name)) area.name = name;
                 if (!string.IsNullOrWhiteSpace(shortCode)) area.shortCode = shortCode;