BatchSchoolController.cs 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039
  1. using Azure.Cosmos;
  2. using HTEXLib.COMM.Helpers;
  3. using Microsoft.AspNetCore.Http;
  4. using Microsoft.AspNetCore.Mvc;
  5. using Microsoft.Extensions.Options;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Dynamic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Text.Json;
  12. using System.Threading.Tasks;
  13. using TEAMModelOS.Models;
  14. using TEAMModelOS.SDK.DI;
  15. using TEAMModelOS.SDK.Extension;
  16. using TEAMModelOS.SDK.Models;
  17. using TEAMModelOS.SDK.Models.Cosmos.BI;
  18. using Microsoft.AspNetCore.Hosting; //引用读取文件
  19. using TEAMModelOS.SDK.Models.Service;
  20. using System.IO;
  21. using System.Net.Http;
  22. using Microsoft.Extensions.Configuration;
  23. using System.Net.Http.Json;
  24. using System.Net;
  25. using TEAMModelBI.Filter;
  26. using TEAMModelBI.Tool.Extension;
  27. using TEAMModelBI.Tool;
  28. using TEAMModelBI.Models;
  29. namespace TEAMModelBI.Controllers.BISchool
  30. {
  31. [Route("batchschool")]
  32. [ApiController]
  33. public class BatchSchoolController : ControllerBase
  34. {
  35. private readonly AzureCosmosFactory _azureCosmos;
  36. private readonly DingDing _dingDing;
  37. private readonly Option _option;
  38. private readonly AzureStorageFactory _azureStorage;
  39. private readonly IWebHostEnvironment _environment; //读取文件
  40. private readonly IHttpClientFactory _http;
  41. //读取配置信息
  42. private readonly IConfiguration _configuration;
  43. public readonly string mobel = "学校";
  44. public BatchSchoolController(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, IOptionsSnapshot<Option> option, IWebHostEnvironment hostingEnvironment, IConfiguration configuration, IHttpClientFactory http)
  45. {
  46. _azureCosmos = azureCosmos;
  47. _dingDing = dingDing;
  48. _azureStorage = azureStorage;
  49. _option = option?.Value;
  50. _environment = hostingEnvironment;
  51. _configuration = configuration;
  52. _http = http;
  53. }
  54. /// <summary>
  55. /// 获取BI权限列表
  56. /// </summary>
  57. /// <returns></returns>
  58. [ProducesDefaultResponseType]
  59. [HttpPost("get-teacher-authoritybilist")]
  60. public async Task<IActionResult> GetAuthorityBIList()
  61. {
  62. Dictionary<string, object> dic = new Dictionary<string, object> { { "PartitionKey", "authority-bi" } };
  63. var table = _azureStorage.GetCloudTableClient().GetTableReference("SchoolSetting");
  64. List<Authority> authorityBIList = await table.FindListByDict<Authority>(dic);
  65. return Ok(new { authorityBIList });
  66. }
  67. /// <summary>
  68. /// 通过教师的id和学校的code查询权限
  69. /// </summary>
  70. /// <param name="jsonElement"></param>
  71. /// <returns></returns>
  72. [ProducesDefaultResponseType]
  73. [HttpPost("get-teacherroles")]
  74. public async Task<IActionResult> GetTeacherRoles(JsonElement jsonElement)
  75. {
  76. try
  77. {
  78. if (!jsonElement.TryGetProperty("id", out JsonElement id)) return Ok(new { state = 1, message = "参数错误!" });
  79. if (!jsonElement.TryGetProperty("schoolcode", out JsonElement schoolcode)) return Ok(new { state = 1, message = "参数错误!" });
  80. var client = _azureCosmos.GetCosmosClient();
  81. string sqltxt = $"select * from c where c.id='{id}'";
  82. List<string> roles = new List<string>();//角色列表
  83. List<string> permissions = new List<string>();//权限列表
  84. var schoolRoles = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{id}", new PartitionKey($"Teacher-{schoolcode}"));
  85. if (schoolRoles.Status == 200)
  86. {
  87. using var json = await JsonDocument.ParseAsync(schoolRoles.ContentStream);
  88. if (json.RootElement.TryGetProperty("roles", out JsonElement _roles) && _roles.ValueKind != JsonValueKind.Null)
  89. {
  90. foreach (var obj in _roles.EnumerateArray())
  91. {
  92. roles.Add(obj.GetString());
  93. }
  94. }
  95. if (json.RootElement.TryGetProperty("permissions", out JsonElement _permissions) && _permissions.ValueKind != JsonValueKind.Null)
  96. {
  97. foreach (var obj in _permissions.EnumerateArray())
  98. {
  99. permissions.Add(obj.GetString());
  100. }
  101. }
  102. }
  103. return Ok(new { state = 200, roles = roles, permissions = permissions });
  104. }
  105. catch (Exception ex)
  106. {
  107. await _dingDing.SendBotMsg($"BI,{_option.Location}, /batchschool/get-teacherroles \n{ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  108. return BadRequest();
  109. }
  110. }
  111. /// <summary>
  112. /// 批量创校
  113. /// </summary>
  114. /// <param name="school"></param>
  115. /// <returns></returns>
  116. [ProducesDefaultResponseType]
  117. [AuthToken(Roles = "assist")]
  118. [HttpPost("batch-school")]
  119. public async Task<IActionResult> BatchCreateSchool(FoundSchools foundSchools)
  120. {
  121. try
  122. {
  123. var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
  124. List<BISchool> schools = new List<BISchool>();
  125. StringBuilder stringBuilder = new StringBuilder($"{_tmdName}【{_tmdId}】使用批量创校功能:");
  126. if (foundSchools.biSchools.Count > 0)
  127. {
  128. var cosmosClient = _azureCosmos.GetCosmosClient();
  129. foreach (BISchool bischool in foundSchools.biSchools)
  130. {
  131. string tempTmdId = null;
  132. HttpClient httpClient = _http.CreateClient();
  133. string url = _configuration.GetValue<string>("HaBookAuth:CoreId:userinfo");
  134. List<string> mobile = new List<string>() { bischool.admin };
  135. HttpResponseMessage responseMessage = await httpClient.PostAsJsonAsync(url, mobile);
  136. if (responseMessage.StatusCode == HttpStatusCode.OK)
  137. {
  138. string temp = responseMessage.Content.ReadAsStringAsync().Result;
  139. List<JsonElement> json_id = temp.ToObject<List<JsonElement>>();
  140. foreach (var item in json_id)
  141. {
  142. tempTmdId = item.GetProperty("id").ToString();
  143. }
  144. }
  145. string tmdId = !string.IsNullOrEmpty(tempTmdId) ? tempTmdId : bischool.admin;
  146. CreateSchoolInfo createSchoolInfo = new CreateSchoolInfo()
  147. {
  148. province = bischool.province,
  149. id = "",
  150. name = bischool.name,
  151. city = bischool.city,
  152. aname = "",
  153. createCount = 0,
  154. };
  155. //生成学校ID
  156. bool tempStaus = true;
  157. do
  158. {
  159. createSchoolInfo = await SchoolCode.GenerateSchoolCode(createSchoolInfo, _dingDing, _environment);
  160. var schoolStatu = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{createSchoolInfo.id}", new PartitionKey($"Base"));
  161. if (schoolStatu.Status != 200) tempStaus = false;
  162. else createSchoolInfo.createCount = createSchoolInfo.createCount >= 3 ? createSchoolInfo.createCount = 3 : createSchoolInfo.createCount += 1;
  163. } while (tempStaus);
  164. if (createSchoolInfo.id != null)
  165. {
  166. string campusId = Guid.NewGuid().ToString();
  167. School upSchool = new School
  168. {
  169. id = createSchoolInfo.id,
  170. name = bischool.name,
  171. size = bischool.size == 0 ? 100 : bischool.size,
  172. code = "Base",
  173. campuses = new List<Campus> { new Campus { name = bischool.name, id = campusId } },
  174. region = bischool.region,
  175. province = bischool.province,
  176. city = bischool.city,
  177. dist = bischool.dist,
  178. address = bischool.address,
  179. picture = "https://teammodelstorage.blob.core.chinacloudapi.cn/0-public/school/bbf54fb3-3fc8-43ae-a358-107281c174cc.png",
  180. timeZone = new TEAMModelOS.SDK.Models.TimeZone { label = "(UTC+08:00) 北京,重庆,香港特别行政区,乌鲁木齐", value = "+08:00" },
  181. type = bischool.type,
  182. pk = "School",
  183. ttl = -1,
  184. areaId = string.IsNullOrEmpty(bischool.areaId) ? "" : bischool.areaId,
  185. schoolCode = createSchoolInfo.id,
  186. period = PresetSchoolPeriod(bischool.period, foundSchools.lang, campusId),
  187. scale = bischool.size >= 300 ? 500 : 0
  188. };
  189. stringBuilder.Append($"创建学校:{upSchool.name}【{upSchool.id}】");
  190. //创建学校
  191. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<School>(upSchool, new PartitionKey(upSchool.code));
  192. Teacher teacher = null;
  193. try
  194. {
  195. //查询该教师是否存在
  196. teacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>($"{tmdId}", new PartitionKey("Base"));
  197. }
  198. catch
  199. {
  200. }
  201. if (teacher != null)
  202. {
  203. //教师存在,在该教师信息中添加要管理的学校信息
  204. teacher.schools.Add(new Teacher.TeacherSchool { areaId = string.IsNullOrEmpty(bischool.areaId) ? "" : bischool.areaId, schoolId = createSchoolInfo.id, name = bischool.name, status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() });
  205. //await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, tmdId, new PartitionKey("Base"));
  206. SchoolTeacher schoolTeacher = new SchoolTeacher
  207. {
  208. id = tmdId,
  209. code = $"Teacher-{createSchoolInfo.id}",
  210. roles = new List<string> { "admin", "teacher" },
  211. job = "管理员",
  212. name = teacher.name,
  213. picture = teacher.picture,
  214. status = "join",
  215. createTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
  216. pk = "Teacher",
  217. ttl = -1
  218. };
  219. stringBuilder.Append($"教师信息:{schoolTeacher.name}【{schoolTeacher.id}】,教师权限:{string.Join(",", schoolTeacher.roles)}");
  220. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
  221. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(schoolTeacher, new PartitionKey(schoolTeacher.code));
  222. }
  223. else
  224. {
  225. //不存在 新建教师和新建要管理的学校信息
  226. Teacher addteacher = new Teacher
  227. {
  228. id = tmdId,
  229. pk = "Base",
  230. code = "Base",
  231. name = $"{bischool.name}-管理员"?.ToString(),
  232. picture = "",
  233. //创建账号并第一次登录IES5则默认赠送1G
  234. size = 1,
  235. defaultSchool = createSchoolInfo.id,
  236. schools = new List<Teacher.TeacherSchool>() { new Teacher.TeacherSchool { schoolId = createSchoolInfo.id, name = bischool.name, status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() } }
  237. };
  238. stringBuilder.Append($"没有该教师信息创建的教师信息:{addteacher.name}【{addteacher.id}】");
  239. await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(addteacher, new PartitionKey("Base"));
  240. SchoolTeacher schoolTeacher = new SchoolTeacher
  241. {
  242. id = tmdId,
  243. code = $"Teacher-{createSchoolInfo.id}",
  244. roles = new List<string> { "admin", "teacher" },
  245. job = "管理员",
  246. name = $"{tmdId}-管理员",
  247. picture = "",
  248. status = "join",
  249. createTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
  250. pk = "Teacher",
  251. ttl = -1
  252. };
  253. stringBuilder.Append($"教师权限:{string.Join(",", schoolTeacher.roles)}");
  254. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(schoolTeacher, new PartitionKey(schoolTeacher.code));
  255. }
  256. }
  257. }
  258. }
  259. else return Ok(new { state = 1, message = "创校信息为空" });
  260. //保存操作记录
  261. await _azureStorage.SaveBILog("school-batchAdd", stringBuilder?.ToString(), _dingDing, httpContext: HttpContext);
  262. if (schools.Count > 0)
  263. return Ok(new { state = 201, message = "已有部分学校批量创建成功;学校编号已经重复!请检查学校编号!", schools });
  264. else
  265. return Ok(new { state = 200, message = "批量创校已全部完成" });
  266. }
  267. catch (Exception ex)
  268. {
  269. await _dingDing.SendBotMsg($"BI,{_option.Location} /batchschool/batch-school \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  270. return BadRequest();
  271. }
  272. }
  273. /// <summary>
  274. /// 依据学校编号查询学校信息;若是没有传学校编号,则查询所有学校信息
  275. /// </summary>
  276. /// <param name="jsonElement"></param>
  277. /// <returns></returns>
  278. [ProducesDefaultResponseType]
  279. [HttpPost("get-schoolsinfo")]
  280. public async Task<IActionResult> GetSchoolsInfo(JsonElement jsonElement)
  281. {
  282. try
  283. {
  284. jsonElement.TryGetProperty("tmdId", out JsonElement assistId);
  285. jsonElement.TryGetProperty("schoolCode", out JsonElement _schoolCode);
  286. var cosmosClient = _azureCosmos.GetCosmosClient();
  287. List<AssistSchool> schoolAssists = new();
  288. //StringBuilder stringBuilder = new StringBuilder("select value(c) from c");
  289. StringBuilder stringBuilder = new("select c.id,c.code,c.schoolCode,c.name,c.region,c.province,c.city,c.dist,c.size,c.address,c.picture,c.type,c.scale,c.areaId,c.standard from c");
  290. if (!string.IsNullOrEmpty($"{_schoolCode}"))
  291. {
  292. stringBuilder.Append($" where c.id='{_schoolCode}'");
  293. }
  294. List<string> schools = new();
  295. if (!string.IsNullOrEmpty($"{assistId}"))
  296. schools = await CommonFind.FindSchoolIds(cosmosClient, $"{assistId}");
  297. if (schools.Count > 0)
  298. {
  299. schoolAssists = await CommonFind.FindAssistSchools(cosmosClient, schools);
  300. }
  301. else
  302. {
  303. await foreach (var itemSchool in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<AssistSchool>(queryText: stringBuilder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
  304. {
  305. schoolAssists.Add(itemSchool);
  306. }
  307. schoolAssists.ForEach(async school =>
  308. {
  309. var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(school.id, new PartitionKey("ProductSum"));
  310. if (response.Status == 200)
  311. {
  312. using var json = await JsonDocument.ParseAsync(response.ContentStream);
  313. school.serial = json.RootElement.GetProperty("serial").GetArrayLength();
  314. school.service = json.RootElement.GetProperty("service").GetArrayLength();
  315. school.hard = json.RootElement.GetProperty("hard").GetArrayLength();
  316. }
  317. school.assists = await CommonFind.FindSchoolRoles(cosmosClient, school.id, "assist");
  318. school.lessonCount = await CommonFind.FindTotals(cosmosClient, $"select count(c.id) as totals from c ", "School", $"LessonRecord-{school.id}");
  319. });
  320. }
  321. return Ok(new { state = 200, schoolAssists });
  322. //if (schools.Count > 0)
  323. //{
  324. // schoolAssists = await CommonFind.FindAssistSchools(cosmosClient, schools);
  325. //}
  326. //else
  327. //{
  328. // await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: stringBuilder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
  329. // {
  330. // using var jsonSchool = await JsonDocument.ParseAsync(itemSchool.ContentStream);
  331. // foreach (var objSchool in jsonSchool.RootElement.GetProperty("Documents").EnumerateArray())
  332. // {
  333. // var schoolId = objSchool.GetProperty("id").GetString();
  334. // AssistSchool schoolAssist = new()
  335. // {
  336. // id = schoolId,
  337. // code = objSchool.GetProperty("code").GetString(),
  338. // schoolCode = objSchool.GetProperty("schoolCode").GetString(),
  339. // name = objSchool.GetProperty("name").GetString(),
  340. // region = objSchool.GetProperty("region").GetString(),
  341. // province = objSchool.GetProperty("province").GetString(),
  342. // city = objSchool.GetProperty("city").GetString(),
  343. // dist = objSchool.GetProperty("dist").GetString(),
  344. // size = objSchool.GetProperty("size").GetInt32(),
  345. // address = objSchool.GetProperty("address").GetString(),
  346. // picture = objSchool.GetProperty("picture").GetString(),
  347. // type = objSchool.GetProperty("type").GetInt32(),
  348. // //scale = objSchool.GetProperty("scale").GetInt32(),
  349. // areaId = objSchool.GetProperty("areaId").GetString(),
  350. // standard = objSchool.GetProperty("standard").GetString(),
  351. // };
  352. // try { schoolAssist.scale = objSchool.GetProperty("scale").GetInt32(); }
  353. // catch { schoolAssist.scale = 0; }
  354. // //var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolId, new PartitionKey("ProductSum"));
  355. // //if (response.Status == 200)
  356. // //{
  357. // // using var json = await JsonDocument.ParseAsync(response.ContentStream);
  358. // // schoolAssist.serial = json.RootElement.GetProperty("serial").GetArrayLength();
  359. // // schoolAssist.service = json.RootElement.GetProperty("service").GetArrayLength();
  360. // // schoolAssist.hard = json.RootElement.GetProperty("hard").GetArrayLength();
  361. // //}
  362. // //schoolAssist.assists = await CommonFind.FindSchoolRoles(cosmosClient, schoolId, "assist");
  363. // schoolAssists.Add(schoolAssist);
  364. // }
  365. // }
  366. //}
  367. //List<AssistSchool> tempSchoolAssists = new();
  368. //await foreach (var temp in GetSchools(cosmosClient, schoolAssists))
  369. //{
  370. // tempSchoolAssists.AddRange(temp);
  371. //}
  372. //return Ok(new { state = 200, schoolAssists = tempSchoolAssists });
  373. }
  374. catch (Exception ex)
  375. {
  376. await _dingDing.SendBotMsg($"BI,{_option.Location} /batchschool/get-schoolsinfo \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  377. return BadRequest();
  378. }
  379. }
  380. /// <summary>
  381. /// 使用yieId 关键字 本地效率未测出
  382. /// </summary>
  383. /// <param name="cosmosClient"></param>
  384. /// <param name="schoolAssists"></param>
  385. /// <returns></returns>
  386. private async IAsyncEnumerable<List<AssistSchool>> GetSchools(CosmosClient cosmosClient,List<AssistSchool> schoolAssists)
  387. {
  388. List<AssistSchool> tempSchoolAssists = new();
  389. foreach (var temp in schoolAssists)
  390. {
  391. var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(temp.id, new PartitionKey("ProductSum"));
  392. if (response.Status == 200)
  393. {
  394. using var json = await JsonDocument.ParseAsync(response.ContentStream);
  395. temp.serial = json.RootElement.GetProperty("serial").GetArrayLength();
  396. temp.service = json.RootElement.GetProperty("service").GetArrayLength();
  397. temp.hard = json.RootElement.GetProperty("hard").GetArrayLength();
  398. }
  399. temp.assists = await CommonFind.FindSchoolRoles(cosmosClient, temp.id, "assist");
  400. tempSchoolAssists.Add(temp);
  401. }
  402. yield return tempSchoolAssists;
  403. }
  404. /// <summary>
  405. /// 取得学校所有顾问列表
  406. /// </summary>
  407. /// <returns></returns>
  408. [ProducesDefaultResponseType]
  409. [HttpPost("get-schoolassist")]
  410. public async Task<IActionResult> GetSchoolAssist(JsonElement jsonElement)
  411. {
  412. try
  413. {
  414. string schoolId = (jsonElement.TryGetProperty("schoolId", out JsonElement _schoolId)) ? _schoolId.GetString() : string.Empty;
  415. Dictionary<string, List<Dictionary<string, string>>> haveSchoolManger = new Dictionary<string, List<Dictionary<string, string>>>();
  416. string managerWhereOption = (!string.IsNullOrWhiteSpace(schoolId)) ? $" AND c.code = 'Teacher-{schoolId}'" : string.Empty;
  417. //查询学校的顾问
  418. string managerSql = $"SELECT DISTINCT REPLACE(c.code, 'Teacher-', '') AS schoolId, c.id, c.name FROM c WHERE ARRAY_CONTAINS(c.roles, 'assist', true) AND c.pk = 'Teacher' AND c.status = 'join'{managerWhereOption}";
  419. var cosmosClent = _azureCosmos.GetCosmosClient();
  420. await foreach (var item in cosmosClent.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: managerSql, requestOptions: new QueryRequestOptions() { }))
  421. {
  422. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  423. foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  424. {
  425. string id = obj.GetProperty("id").GetString(); //管理员ID
  426. string name = obj.GetProperty("name").GetString(); //管理员姓名
  427. string tempSchoolId = obj.GetProperty("schoolId").GetString(); //学校ID
  428. Dictionary<string, string> managerDic = new Dictionary<string, string>();
  429. managerDic.Add("id", id);
  430. managerDic.Add("name", name);
  431. if (haveSchoolManger.ContainsKey(tempSchoolId))
  432. {
  433. haveSchoolManger[tempSchoolId].Add(managerDic);
  434. }
  435. else
  436. {
  437. List<Dictionary<string, string>> managerList = new List<Dictionary<string, string>>();
  438. managerList.Add(managerDic);
  439. haveSchoolManger.Add(tempSchoolId, managerList);
  440. }
  441. }
  442. }
  443. //管理模组学校
  444. List<string> baseModuleSchoos = new List<string>();
  445. string baseWhereOption = (!string.IsNullOrEmpty(schoolId)) ? $" and c.id='{schoolId}'" : string.Empty;
  446. await foreach (var item in cosmosClent.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c join serviceProduct in c.service.product where serviceProduct.prodCode = 'IPDYZYLC' {baseWhereOption}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Product") }))
  447. {
  448. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  449. foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  450. {
  451. string tempSchoolId = obj.GetProperty("id").GetString(); //学校ID
  452. baseModuleSchoos.Add(tempSchoolId);
  453. }
  454. }
  455. //学校信息
  456. List<object> schools = new List<object>();
  457. string schoolWhereOption = (!string.IsNullOrEmpty(schoolId)) ? $" where c.id='{schoolId}'" : string.Empty;
  458. await foreach (var item in cosmosClent.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id,c.name,c.period,c.schoolCode,c.region,c.province,c.city,c.picture from c {schoolWhereOption}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
  459. {
  460. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  461. foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  462. {
  463. dynamic schoolExpando = new ExpandoObject();
  464. schoolExpando.id = obj.GetProperty("id").GetString();
  465. schoolExpando.name = obj.GetProperty("name").GetString();
  466. //schoolExpando.period = obj.GetProperty("period");
  467. schoolExpando.schoolCode = obj.GetProperty("schoolCode").GetString();
  468. schoolExpando.region = obj.GetProperty("region").GetString();
  469. schoolExpando.province = obj.GetProperty("province").GetString();
  470. schoolExpando.city = obj.GetProperty("city").GetString();
  471. schoolExpando.picture = obj.GetProperty("picture").GetString();
  472. if (haveSchoolManger.ContainsKey(schoolExpando.id))
  473. {
  474. schoolExpando.hasMarger = true;
  475. schoolExpando.managers = haveSchoolManger[schoolExpando.id];
  476. }
  477. else
  478. {
  479. schoolExpando.hasMarger = false;
  480. schoolExpando.managers = new List<object>();
  481. }
  482. schoolExpando.hasBaseModule = (baseModuleSchoos.Contains(schoolExpando.id)) ? true : false;
  483. schools.Add(schoolExpando);
  484. }
  485. }
  486. return Ok(new { state = 200, schools });
  487. }
  488. catch (Exception ex)
  489. {
  490. await _dingDing.SendBotMsg($"BI,{_option.Location} /batchschool/get-schools \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  491. return BadRequest();
  492. }
  493. }
  494. /// <summary>
  495. /// 修改学校信息和顾问信息
  496. /// </summary>
  497. /// <param name="jsonElement"></param>
  498. /// <returns></returns>
  499. [ProducesDefaultResponseType]
  500. [AuthToken(Roles = "assist")]
  501. [HttpPost("upd-schoolassist")]
  502. public async Task<IActionResult> UpdSchoolAssist(JsonElement jsonElement)
  503. {
  504. try
  505. {
  506. if (!jsonElement.TryGetProperty("schoolId", out JsonElement _schoolId)) return BadRequest();
  507. if (!jsonElement.TryGetProperty("name", out JsonElement schoolName)) return BadRequest();
  508. if (!jsonElement.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
  509. if (!jsonElement.TryGetProperty("standard", out JsonElement standard)) return BadRequest();
  510. //if (!jsonElement.TryGetProperty("period", out JsonElement period)) return BadRequest();
  511. if (!jsonElement.TryGetProperty("picture", out JsonElement picture)) return BadRequest();
  512. if (!jsonElement.TryGetProperty("size", out JsonElement size)) return BadRequest();
  513. if (!jsonElement.TryGetProperty("scale", out JsonElement scale)) return BadRequest();
  514. if (!jsonElement.TryGetProperty("assistId", out JsonElement _assistId)) return BadRequest();
  515. if (!jsonElement.TryGetProperty("type", out JsonElement _type)) return BadRequest();
  516. var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
  517. List<string> assistId = _assistId.ToObject<List<string>>();
  518. //List<string> periodS = period.ToObject<List<string>>();
  519. Dictionary<string, List<Dictionary<string, string>>> haveSchoolManger = new Dictionary<string, List<Dictionary<string, string>>>();
  520. var cosmosClient = _azureCosmos.GetCosmosClient();
  521. School tempShool = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{_schoolId}", new PartitionKey("Base"));
  522. if (tempShool != null)
  523. {
  524. List<Period> periods = new List<Period>();
  525. string campusId = Guid.NewGuid().ToString();
  526. //periodS.ForEach(x =>
  527. //{
  528. // periods.Add(new Period { id = Guid.NewGuid().ToString(), name = x.ToString(), campusId = campusId });
  529. //});
  530. //tempShool.period = periods;
  531. tempShool.size = !string.IsNullOrEmpty($"{size}") ? int.Parse($"{size}") : tempShool.size;
  532. tempShool.scale = !string.IsNullOrEmpty($"{scale}") ? int.Parse($"{scale}") : tempShool.scale;
  533. tempShool.picture = $"{picture}";
  534. tempShool.type = int.Parse($"{_type}");
  535. tempShool.name = $"{schoolName}";
  536. tempShool.areaId = $"{areaId}";
  537. tempShool.standard = $"{standard}";
  538. //修改学校
  539. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(tempShool, tempShool.id, new PartitionKey("Base"));
  540. //修改学校教师关联的信息
  541. string sql = $"SELECT distinct value(c) FROM c join A1 in c.schools where A1.schoolId='{tempShool.id}'";
  542. List<Teacher> teachers = new List<Teacher>();
  543. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
  544. {
  545. teachers.Add(item);
  546. }
  547. foreach (var item in teachers)
  548. {
  549. Teacher.TeacherSchool teacherSchool = item.schools.Find(x => x.schoolId.Equals(tempShool.id));
  550. if (teacherSchool != null)
  551. {
  552. teacherSchool.name = tempShool.name;
  553. teacherSchool.picture = tempShool.picture;
  554. teacherSchool.areaId = tempShool.areaId;
  555. }
  556. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(item, item.id, new PartitionKey($"Base"));
  557. }
  558. //修改学校顾问
  559. string sqlTxt = $"SELECT value(c) From c WHERE ARRAY_CONTAINS(c.roles,'assist',true)";
  560. List<SchoolTeacher> schoolTeachers = new List<SchoolTeacher>();
  561. await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<SchoolTeacher>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{tempShool.id}") }))
  562. {
  563. if (!assistId.Contains(item.id))
  564. {
  565. if (item.roles.Contains("assist"))
  566. {
  567. item.roles.Remove("assist");
  568. if (item.roles.Count > 0)
  569. {
  570. await cosmosClient.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<SchoolTeacher>(item, item.id, new PartitionKey(item.code));
  571. }
  572. else
  573. {
  574. await cosmosClient.GetContainer("TEAMModelOS", "School").DeleteItemAsync<SchoolTeacher>(item.id, new PartitionKey(item.code));
  575. }
  576. }
  577. }
  578. }
  579. if (assistId.Count > 0)
  580. {
  581. foreach (var itemTeacher in assistId)
  582. {
  583. Teacher tempTeacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>($"{itemTeacher}", new PartitionKey("Base"));
  584. if (tempTeacher != null)
  585. {
  586. var haveTeacher = tempTeacher.schools.Find(x => x.schoolId.Equals($"{_schoolId}"));
  587. if (haveTeacher != null)
  588. {
  589. //查询该教师是否存在该校
  590. SchoolTeacher schoolTeacher = null;
  591. try
  592. {
  593. schoolTeacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<SchoolTeacher>($"{itemTeacher}", new PartitionKey($"Teacher-{tempShool.id}"));
  594. }
  595. catch
  596. {
  597. }
  598. if (schoolTeacher != null)
  599. {
  600. if (!schoolTeacher.roles.Contains("assist"))
  601. {
  602. schoolTeacher.roles.Add("assist");
  603. //添加顾问权限
  604. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<SchoolTeacher>(schoolTeacher, schoolTeacher.id, new PartitionKey($"Teacher-{tempShool.id}"));
  605. }
  606. }
  607. else
  608. {
  609. SchoolTeacher addSchoolTeacher = new SchoolTeacher
  610. {
  611. id = itemTeacher,
  612. code = $"Teacher-{tempShool.id}",
  613. pk = "Teacher",
  614. status = "join",
  615. roles = new List<string>() { "assist" },
  616. name = tempTeacher.name,
  617. job = $"{tempShool.name}-顾问",
  618. size = 0,
  619. createTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds()
  620. };
  621. //添加学校顾问
  622. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(addSchoolTeacher, new PartitionKey($"Teacher-{tempShool.id}"));
  623. }
  624. }
  625. else
  626. {
  627. Teacher.TeacherSchool teacherSchool = new Teacher.TeacherSchool
  628. {
  629. schoolId = tempShool.id,
  630. name = tempShool.name,
  631. status = "join",
  632. time = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
  633. picture = tempShool.picture,
  634. areaId = tempShool.areaId
  635. };
  636. tempTeacher.schools.Add(teacherSchool);
  637. //给醍摩豆顾问添加学校
  638. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(tempTeacher, tempTeacher.id, new PartitionKey($"Base"));
  639. //不存在则在原来的基础上添加顾问角色
  640. SchoolTeacher addSchoolTeacher = new SchoolTeacher
  641. {
  642. id = itemTeacher,
  643. code = $"Teacher-{tempShool.id}",
  644. pk = "Teacher",
  645. status = "join",
  646. roles = new List<string>() { "assist" },
  647. name = tempTeacher.name,
  648. job = $"{tempShool.name}-顾问",
  649. size = 0,
  650. createTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds()
  651. };
  652. //添加学校学校顾问
  653. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(addSchoolTeacher, new PartitionKey($"Teacher-{tempShool.id}"));
  654. }
  655. }
  656. }
  657. }
  658. }
  659. //保存操作记录
  660. await _azureStorage.SaveBILog("school-update", $"{_tmdName}【{_tmdId}】修改学校功能,修改的学校:{_schoolId},{_type},{picture},{size},{string.Join("|", assistId.ToArray())}", _dingDing, httpContext: HttpContext);
  661. return Ok(new { state = 200 });
  662. }
  663. catch (Exception ex)
  664. {
  665. await _dingDing.SendBotMsg($"BI, {_option.Location} /batchschool/upd-schoolassist \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  666. return BadRequest();
  667. }
  668. }
  669. /// <summary>
  670. /// 查询区域的学校
  671. /// </summary>
  672. /// <param name="jsonElement"></param>
  673. /// <returns></returns>
  674. [ProducesDefaultResponseType]
  675. [HttpPost("get-schooldist")]
  676. public async Task<IActionResult> GetSchoolDist(JsonElement jsonElement)
  677. {
  678. try
  679. {
  680. if (!jsonElement.TryGetProperty("dist", out JsonElement _dist)) return BadRequest();
  681. var cosmosClient = _azureCosmos.GetCosmosClient();
  682. string sqltxt = $"SELECT * FROM c where c.dist='{_dist}'";
  683. List<School> schools = new List<School>();
  684. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
  685. {
  686. schools.Add(item);
  687. }
  688. return Ok(new { state = 200, schools });
  689. }
  690. catch (Exception ex)
  691. {
  692. await _dingDing.SendBotMsg($"BI,{_option.Location} /batchschool/get-schooldist \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  693. return BadRequest();
  694. }
  695. }
  696. /// <summary>
  697. /// 分页学校和顾问信息
  698. /// </summary>
  699. /// <param name="jsonElement"></param>
  700. /// <returns></returns>
  701. [HttpPost("get-schools")]
  702. public async Task<IActionResult> GetSchools(JsonElement jsonElement)
  703. {
  704. //List<School> schools = new List<School>();
  705. List<AssistSchool> schoolAssists = new List<AssistSchool>();
  706. var cosmosClient = _azureCosmos.GetCosmosClient();
  707. if (!jsonElement.TryGetProperty("endPosition", out JsonElement endPosition)) return BadRequest();
  708. if (!jsonElement.TryGetProperty("pageSize", out JsonElement pageSize)) return BadRequest();
  709. string sqltxt = $"SELECT * FROM c order by c.id offset {endPosition} limit {pageSize}";
  710. await foreach (var itemSchool in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
  711. {
  712. AssistSchool schoolAssist = new()
  713. {
  714. id = itemSchool.id,
  715. code = itemSchool.code,
  716. schoolCode = itemSchool.schoolCode,
  717. name = itemSchool.name,
  718. region = itemSchool.region,
  719. province = itemSchool.province,
  720. city = itemSchool.city,
  721. dist = itemSchool.dist,
  722. size = itemSchool.size,
  723. address = itemSchool.address,
  724. picture = itemSchool.picture,
  725. type = itemSchool.type,
  726. scale = itemSchool.scale,
  727. areaId = itemSchool.areaId,
  728. standard = itemSchool.standard
  729. };
  730. schoolAssist.assists = await CommonFind.FindSchoolRoles(cosmosClient, itemSchool.id, "assist");
  731. //List<Assist> assists = new List<Assist>();
  732. ////查询学校的顾问
  733. //string managerSql = $"SELECT DISTINCT REPLACE(c.code, 'Teacher-', '') AS schoolId, c.id, c.name FROM c WHERE ARRAY_CONTAINS(c.roles, 'assist', true) AND c.pk = 'Teacher' AND c.status = 'join' AND c.code = 'Teacher-{itemSchool.id}'";
  734. //var cosmosClent = _azureCosmos.GetCosmosClient();
  735. //await foreach (var item in cosmosClent.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: managerSql, requestOptions: new QueryRequestOptions() { }))
  736. //{
  737. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  738. // foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  739. // {
  740. // Assist assist = new Assist
  741. // {
  742. // tmdId = obj.GetProperty("id").GetString(),
  743. // tmdName = obj.GetProperty("name").GetString()
  744. // };
  745. // assists.Add(assist);
  746. // }
  747. //}
  748. //schoolAssist.assists = assists;
  749. schoolAssists.Add(schoolAssist);
  750. }
  751. return Ok(new { state = 200, schoolAssists });
  752. }
  753. #region 预设学校基础信息 多语言
  754. /// <summary>
  755. /// 预设学校基础信息 多语言
  756. /// </summary>
  757. /// <param name="period"></param>
  758. /// <param name="Language"></param>
  759. /// <param name="campusId"></param>
  760. /// <returns></returns>
  761. public List<Period> PresetSchoolPeriod(List<string> period, string Language, string campusId)
  762. {
  763. var builder = $"{_environment.ContentRootPath}/JsonFile/Preset/LangSchoolConfig.json";
  764. StreamReader streamReader = new StreamReader(new FileStream(builder, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Encoding.UTF8);
  765. StringBuilder stringBuilder = new StringBuilder();
  766. string text;
  767. while ((text = streamReader.ReadLine()) != null)
  768. {
  769. stringBuilder.Append(text.ToString());
  770. }
  771. streamReader.Close();
  772. string input = stringBuilder.ToString();
  773. List<SchoolConfig> schoolConfigs = input.ToObject<List<SchoolConfig>>();
  774. SchoolConfig schoolConfig = schoolConfigs.Find(x => x.Lang.Contains($"{Language}"));
  775. if (schoolConfig == null)
  776. {
  777. if (Language.Contains("en"))
  778. schoolConfig = schoolConfigs.Find(x => x.Lang.Contains("en-US"));
  779. else
  780. schoolConfig = schoolConfigs.Find(x => x.Lang.Contains("zh-CN"));
  781. }
  782. List<Period> periods = new List<Period>();
  783. period.ForEach(x =>
  784. {
  785. periods.Add(new Period
  786. {
  787. id = Guid.NewGuid().ToString(),
  788. name = x,
  789. campusId = campusId,
  790. semesters = new List<Semester>() { new Semester { name = schoolConfig.semester[0].term, start = schoolConfig.semester[0].start, month = schoolConfig.semester[0].month, day = schoolConfig.semester[0].day, id = Guid.NewGuid().ToString() },
  791. new Semester { name = schoolConfig.semester[1].term, start = schoolConfig.semester[1].start, month = schoolConfig.semester[1].month, day = schoolConfig.semester[1].day, id = Guid.NewGuid().ToString() } },
  792. subjects = new List<Subject>() {
  793. new Subject { id=Guid.NewGuid().ToString(),name=schoolConfig.PresetSubject[0].name,type=schoolConfig.PresetSubject[0].type },
  794. new Subject { id=Guid.NewGuid().ToString(),name=schoolConfig.PresetSubject[1].name,type=schoolConfig.PresetSubject[1].type },
  795. new Subject { id=Guid.NewGuid().ToString(),name=schoolConfig.PresetSubject[2].name,type=schoolConfig.PresetSubject[2].type }
  796. },
  797. grades = schoolConfig.grades,
  798. analysis = new Analysis()
  799. {
  800. type = new List<ExamSimple>() { new ExamSimple { id = Guid.NewGuid().ToString(), name = schoolConfig.PresetExam[0].type[0].name },
  801. new ExamSimple { id = Guid.NewGuid().ToString(), name = schoolConfig.PresetExam[0].type[1].name },
  802. new ExamSimple { id = Guid.NewGuid().ToString(), name = schoolConfig.PresetExam[0].type[2].name },
  803. new ExamSimple { id = Guid.NewGuid().ToString(), name = schoolConfig.PresetExam[0].type[3].name } },
  804. income = schoolConfig.PresetExam[0].income,
  805. eugenics = schoolConfig.PresetExam[0].eugenics,
  806. touch = schoolConfig.PresetExam[0].touch
  807. }
  808. });
  809. });
  810. return periods;
  811. }
  812. public record SchoolConfig
  813. {
  814. public string Lang { get; set; }
  815. public List<semester> semester { get; set; }
  816. public List<string> grades { get; set; }
  817. public List<PresetSubject> PresetSubject { get; set; }
  818. public List<PresetExam> PresetExam { get; set; }
  819. }
  820. public record semester
  821. {
  822. public string id { get; set; } = Guid.NewGuid().ToString();
  823. public string term { get; set; }
  824. public int start { get; set; }
  825. public int month { get; set; }
  826. public int day { get; set; }
  827. }
  828. public record PresetSubject
  829. {
  830. public string id { get; set; } = Guid.NewGuid().ToString();
  831. public string name { get; set; }
  832. public int type { get; set; }
  833. }
  834. public record PresetExam
  835. {
  836. public List<StudyType> type { get; set; }
  837. public int income { get; set; }
  838. public int eugenics { get; set; }
  839. public int touch { get; set; }
  840. }
  841. public record StudyType
  842. {
  843. public string id { get; set; } = Guid.NewGuid().ToString();
  844. public string name { get; set; }
  845. }
  846. #endregion
  847. //public class SchoolAssist
  848. //{
  849. // public string id { get; set; }
  850. // public string code { get; set; }
  851. // public string schoolCode { get; set; }
  852. // public string name { get; set; }
  853. // public string region { get; set; }
  854. // public string province { get; set; }
  855. // public string city { get; set; }
  856. // public string dist { get; set; }
  857. // public int size { get; set; }
  858. // public string address { get; set; }
  859. // public string picture { get; set; }
  860. // public int type { get; set; }
  861. // public int scale { get; set; }
  862. // public string standard { get; set; }
  863. // public string areaId { get; set; }
  864. // public List<SchoolTeacherRoles> assists { get; set; }
  865. // public int serial { get; set; } //软体
  866. // public int service { get; set; } //服务
  867. // public int hard { get; set; } //硬体
  868. // //public List<SchoolProductSumData> serial { get; set; } //软体
  869. // //public List<SchoolProductSumData> service { get; set; } //服务
  870. // //public List<SchoolProductSumDataHard> hard { get; set; } //硬体
  871. //}
  872. /// <summary>
  873. /// 创建多个学校实体
  874. /// </summary>
  875. public record FoundSchools()
  876. {
  877. /// <summary>
  878. /// 语系
  879. /// </summary>
  880. public string lang { get; set; }
  881. /// <summary>
  882. /// 批量创校的数据结构
  883. /// </summary>
  884. public List<BISchool> biSchools { get; set; } = new List<BISchool>();
  885. }
  886. /// <summary>
  887. /// 批量创校的数据结构
  888. /// </summary>
  889. public record BISchool()
  890. {
  891. /// <summary>
  892. /// 学校名称
  893. /// </summary>
  894. public string name { get; set; }
  895. /// <summary>
  896. /// 学校管理员
  897. /// </summary>
  898. public string admin { get; set; }
  899. /// <summary>
  900. /// 学校的学段
  901. /// </summary>
  902. public List<string> period { get; set; }
  903. /// <summary>
  904. /// 学校空间大小
  905. /// </summary>
  906. public int size { get; set; }
  907. /// <summary>
  908. /// 地区
  909. /// </summary>
  910. public string region { get; set; }
  911. /// <summary>
  912. /// 省份
  913. /// </summary>
  914. public string province { get; set; }
  915. /// <summary>
  916. /// 城市
  917. /// </summary>
  918. public string city { get; set; }
  919. /// <summary>
  920. /// 县,区,郡
  921. /// </summary>
  922. public string dist { get; set; }
  923. /// <summary>
  924. /// 学校详细地址
  925. /// </summary>
  926. public string address { get; set; }
  927. /// <summary>
  928. /// 学校类型
  929. /// </summary>
  930. public int type { get; set; }
  931. /// <summary>
  932. /// 区域ID
  933. /// </summary>
  934. public string areaId { get; set; }
  935. }
  936. public record Exist()
  937. {
  938. public string ID { get; set; }
  939. public string name { get; set; }
  940. }
  941. }
  942. }