|
@@ -34,6 +34,7 @@ using Microsoft.AspNetCore.Hosting;
|
|
|
using TEAMModelOS.SDK.Context.Constant;
|
|
|
using TEAMModelOS.SDK.Models.Service.BI;
|
|
|
using TEAMModelBI.Models;
|
|
|
+using System.Text.RegularExpressions;
|
|
|
|
|
|
namespace TEAMModelBI.Controllers.BINormal
|
|
|
{
|
|
@@ -681,6 +682,24 @@ namespace TEAMModelBI.Controllers.BINormal
|
|
|
if (item.shortCode.Equals($"{shortCode}"))
|
|
|
return Ok(new { state = 1, message = "此学区简码已存在请检查" });
|
|
|
}
|
|
|
+
|
|
|
+ // 檢查是否有大寫或是中文字
|
|
|
+ if (shortCode.Any(c => char.IsUpper(c)) || Regex.IsMatch(shortCode, @"[\u4e00-\u9fa5]"))
|
|
|
+ {
|
|
|
+ return Ok(new { state = 1, message = "此區級簡碼必須為小寫字母!" });
|
|
|
+ }
|
|
|
+
|
|
|
+ string sqlCheckRep = $"SELECT c.id FROM c WHERE c.shortCode = '{shortCode}'";
|
|
|
+ var _azureCosmosClientCsv2Read = _azureCosmos.GetCosmosClient(name: "CoreServiceV2CnRead");
|
|
|
+ await foreach (var item in _azureCosmosClientCsv2Read.GetContainer("Core", "School").GetItemQueryStreamIterator(queryText: sqlCheckRep, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("district") }))
|
|
|
+ {
|
|
|
+ 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;
|