BatchSchoolController.cs 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045
  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 = "admin,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 = string.IsNullOrEmpty(bischool.type.ToString()) ? 1 : bischool.type,
  182. pk = "School",
  183. ttl = -1,
  184. areaId = string.IsNullOrEmpty(bischool.areaId) ? "" : bischool.areaId,
  185. standard = string.IsNullOrEmpty(bischool.standard) ? "" : bischool.standard,
  186. schoolCode = createSchoolInfo.id,
  187. period = PresetSchoolPeriod(bischool.period, foundSchools.lang, campusId),
  188. scale = bischool.size >= 300 ? 500 : 0,
  189. createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
  190. };
  191. stringBuilder.Append($"创建学校:{upSchool.name}【{upSchool.id}】");
  192. //创建学校
  193. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<School>(upSchool, new PartitionKey(upSchool.code));
  194. Teacher teacher = null;
  195. try
  196. {
  197. //查询该教师是否存在
  198. teacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>($"{tmdId}", new PartitionKey("Base"));
  199. }
  200. catch
  201. {
  202. }
  203. if (teacher != null)
  204. {
  205. //教师存在,在该教师信息中添加要管理的学校信息
  206. 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() });
  207. //await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, tmdId, new PartitionKey("Base"));
  208. SchoolTeacher schoolTeacher = new SchoolTeacher
  209. {
  210. id = tmdId,
  211. code = $"Teacher-{createSchoolInfo.id}",
  212. roles = new List<string> { "admin", "teacher" },
  213. job = "管理员",
  214. name = teacher.name,
  215. picture = teacher.picture,
  216. status = "join",
  217. createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
  218. pk = "Teacher",
  219. ttl = -1
  220. };
  221. stringBuilder.Append($"教师信息:{schoolTeacher.name}【{schoolTeacher.id}】,教师权限:{string.Join(",", schoolTeacher.roles)}");
  222. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
  223. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(schoolTeacher, new PartitionKey(schoolTeacher.code));
  224. }
  225. else
  226. {
  227. //不存在 新建教师和新建要管理的学校信息
  228. Teacher addteacher = new Teacher
  229. {
  230. id = tmdId,
  231. pk = "Base",
  232. code = "Base",
  233. name = $"{bischool.name}-管理员"?.ToString(),
  234. picture = "",
  235. //创建账号并第一次登录IES5则默认赠送1G
  236. size = 1,
  237. defaultSchool = createSchoolInfo.id,
  238. createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
  239. schools = new List<Teacher.TeacherSchool>() { new Teacher.TeacherSchool { schoolId = createSchoolInfo.id, name = bischool.name, status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() } }
  240. };
  241. stringBuilder.Append($"没有该教师信息创建的教师信息:{addteacher.name}【{addteacher.id}】");
  242. await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(addteacher, new PartitionKey("Base"));
  243. SchoolTeacher schoolTeacher = new SchoolTeacher
  244. {
  245. id = tmdId,
  246. code = $"Teacher-{createSchoolInfo.id}",
  247. roles = new List<string> { "admin", "teacher" },
  248. job = "管理员",
  249. name = $"{tmdId}-管理员",
  250. picture = "",
  251. status = "join",
  252. createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
  253. pk = "Teacher",
  254. ttl = -1
  255. };
  256. stringBuilder.Append($"教师权限:{string.Join(",", schoolTeacher.roles)}");
  257. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(schoolTeacher, new PartitionKey(schoolTeacher.code));
  258. }
  259. }
  260. }
  261. }
  262. else return Ok(new { state = 1, message = "创校信息为空" });
  263. //保存操作记录
  264. await _azureStorage.SaveBILog("school-batchAdd", stringBuilder?.ToString(), _dingDing, httpContext: HttpContext);
  265. if (schools.Count > 0)
  266. return Ok(new { state = 201, message = "已有部分学校批量创建成功;学校编号已经重复!请检查学校编号!", schools });
  267. else
  268. return Ok(new { state = 200, message = "批量创校已全部完成" });
  269. }
  270. catch (Exception ex)
  271. {
  272. await _dingDing.SendBotMsg($"BI,{_option.Location} /batchschool/batch-school \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  273. return BadRequest();
  274. }
  275. }
  276. /// <summary>
  277. /// 依据学校编号查询学校信息;若是没有传学校编号,则查询所有学校信息
  278. /// </summary>
  279. /// <param name="jsonElement"></param>
  280. /// <returns></returns>
  281. [ProducesDefaultResponseType]
  282. [HttpPost("get-schoolsinfo")]
  283. public async Task<IActionResult> GetSchoolsInfo(JsonElement jsonElement)
  284. {
  285. try
  286. {
  287. jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
  288. jsonElement.TryGetProperty("schoolCode", out JsonElement _schoolCode);
  289. var cosmosClient = _azureCosmos.GetCosmosClient();
  290. int? pageSize = null; //默认不指定返回大小
  291. string continuationToken = string.Empty; //返给前端分页token
  292. string pageToken = default;//接受前端的分页Tolen
  293. bool iscontinuation = false;//是否需要进行分页查询,默认不分页
  294. List<AssistSchool> schoolAssists = new(); //返回学校列表集合
  295. List<string> schoolIds = new();
  296. 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");
  297. if (jsonElement.TryGetProperty("pageSize", out JsonElement jsonPageSize))
  298. {
  299. if (!jsonPageSize.ValueKind.Equals(JsonValueKind.Undefined) && !jsonPageSize.ValueKind.Equals(JsonValueKind.Null) && jsonPageSize.TryGetInt32(out int tempPageSize))
  300. {
  301. pageSize = tempPageSize;
  302. }
  303. }
  304. if (pageSize != null && pageSize.Value > 0)
  305. {
  306. iscontinuation = true;
  307. }
  308. if (jsonElement.TryGetProperty("contToken", out JsonElement ContToken))
  309. {
  310. pageToken = ContToken.GetString();
  311. }
  312. if (!string.IsNullOrEmpty($"{tmdId}"))
  313. {
  314. schoolIds = await CommonFind.FindSchoolIds(cosmosClient, $"{tmdId}");
  315. }
  316. if (schoolIds.Count > 0)
  317. {
  318. foreach (var id in schoolIds)
  319. {
  320. string sqlTxt = $"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 where c.id='{id}'";
  321. await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<AssistSchool>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
  322. {
  323. schoolAssists.Add(itemSchool);
  324. }
  325. }
  326. }
  327. else
  328. {
  329. if (!string.IsNullOrEmpty($"{_schoolCode}"))
  330. {
  331. stringBuilder.Append($" where c.id='{_schoolCode}'");
  332. }
  333. await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: stringBuilder.ToString(), continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base") }))
  334. {
  335. using var json = await JsonDocument.ParseAsync(itemSchool.ContentStream);
  336. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0)
  337. {
  338. foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  339. {
  340. schoolAssists.Add(obj.ToObject<AssistSchool>());
  341. }
  342. if (iscontinuation)
  343. {
  344. continuationToken = itemSchool.GetContinuationToken();
  345. break;
  346. }
  347. }
  348. }
  349. }
  350. schoolAssists.ForEach(async school =>
  351. {
  352. var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(school.id, new PartitionKey("ProductSum"));
  353. if (response.Status == 200)
  354. {
  355. using var json = await JsonDocument.ParseAsync(response.ContentStream);
  356. if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
  357. {
  358. school.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
  359. }
  360. if (json.RootElement.TryGetProperty("service", out JsonElement service) && !service.ValueKind.Equals(JsonValueKind.Null))
  361. {
  362. school.service = service.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
  363. }
  364. if (json.RootElement.TryGetProperty("hard", out JsonElement hard) && !hard.ValueKind.Equals(JsonValueKind.Null))
  365. {
  366. school.hard = hard.ToObject<List<SchoolProductSumDataHard>>().Select(x => x.prodCode).ToList();
  367. }
  368. }
  369. school.assists = await CommonFind.FindSchoolRoles(cosmosClient, school.id, "assist");
  370. school.lessonCount = await CommonFind.FindTotals(cosmosClient, $"select count(c.id) as totals from c ", "School", $"LessonRecord-{school.id}");
  371. });
  372. return Ok(new { state = 200, continuationToken, schoolAssists, });
  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. if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
  396. {
  397. temp.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
  398. }
  399. if (json.RootElement.TryGetProperty("service", out JsonElement service) && !service.ValueKind.Equals(JsonValueKind.Null))
  400. {
  401. temp.service = service.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
  402. }
  403. if (json.RootElement.TryGetProperty("hard", out JsonElement hard) && !hard.ValueKind.Equals(JsonValueKind.Null))
  404. {
  405. temp.hard = hard.ToObject<List<SchoolProductSumDataHard>>().Select(x => x.prodCode).ToList();
  406. }
  407. }
  408. temp.assists = await CommonFind.FindSchoolRoles(cosmosClient, temp.id, "assist");
  409. tempSchoolAssists.Add(temp);
  410. }
  411. yield return tempSchoolAssists;
  412. }
  413. /// <summary>
  414. /// 取得学校所有顾问列表
  415. /// </summary>
  416. /// <returns></returns>
  417. [ProducesDefaultResponseType]
  418. [HttpPost("get-schoolassist")]
  419. public async Task<IActionResult> GetSchoolAssist(JsonElement jsonElement)
  420. {
  421. try
  422. {
  423. string schoolId = (jsonElement.TryGetProperty("schoolId", out JsonElement _schoolId)) ? _schoolId.GetString() : string.Empty;
  424. Dictionary<string, List<Dictionary<string, string>>> haveSchoolManger = new Dictionary<string, List<Dictionary<string, string>>>();
  425. string managerWhereOption = (!string.IsNullOrWhiteSpace(schoolId)) ? $" AND c.code = 'Teacher-{schoolId}'" : string.Empty;
  426. //查询学校的顾问
  427. 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}";
  428. var cosmosClent = _azureCosmos.GetCosmosClient();
  429. await foreach (var item in cosmosClent.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: managerSql, requestOptions: new QueryRequestOptions() { }))
  430. {
  431. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  432. foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  433. {
  434. string id = obj.GetProperty("id").GetString(); //管理员ID
  435. string name = obj.GetProperty("name").GetString(); //管理员姓名
  436. string tempSchoolId = obj.GetProperty("schoolId").GetString(); //学校ID
  437. Dictionary<string, string> managerDic = new Dictionary<string, string>();
  438. managerDic.Add("id", id);
  439. managerDic.Add("name", name);
  440. if (haveSchoolManger.ContainsKey(tempSchoolId))
  441. {
  442. haveSchoolManger[tempSchoolId].Add(managerDic);
  443. }
  444. else
  445. {
  446. List<Dictionary<string, string>> managerList = new List<Dictionary<string, string>>();
  447. managerList.Add(managerDic);
  448. haveSchoolManger.Add(tempSchoolId, managerList);
  449. }
  450. }
  451. }
  452. //管理模组学校
  453. List<string> baseModuleSchoos = new List<string>();
  454. string baseWhereOption = (!string.IsNullOrEmpty(schoolId)) ? $" and c.id='{schoolId}'" : string.Empty;
  455. 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") }))
  456. {
  457. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  458. foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  459. {
  460. string tempSchoolId = obj.GetProperty("id").GetString(); //学校ID
  461. baseModuleSchoos.Add(tempSchoolId);
  462. }
  463. }
  464. //学校信息
  465. List<object> schools = new List<object>();
  466. string schoolWhereOption = (!string.IsNullOrEmpty(schoolId)) ? $" where c.id='{schoolId}'" : string.Empty;
  467. 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") }))
  468. {
  469. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  470. foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  471. {
  472. dynamic schoolExpando = new ExpandoObject();
  473. schoolExpando.id = obj.GetProperty("id").GetString();
  474. schoolExpando.name = obj.GetProperty("name").GetString();
  475. //schoolExpando.period = obj.GetProperty("period");
  476. schoolExpando.schoolCode = obj.GetProperty("schoolCode").GetString();
  477. schoolExpando.region = obj.GetProperty("region").GetString();
  478. schoolExpando.province = obj.GetProperty("province").GetString();
  479. schoolExpando.city = obj.GetProperty("city").GetString();
  480. schoolExpando.picture = obj.GetProperty("picture").GetString();
  481. if (haveSchoolManger.ContainsKey(schoolExpando.id))
  482. {
  483. schoolExpando.hasMarger = true;
  484. schoolExpando.managers = haveSchoolManger[schoolExpando.id];
  485. }
  486. else
  487. {
  488. schoolExpando.hasMarger = false;
  489. schoolExpando.managers = new List<object>();
  490. }
  491. schoolExpando.hasBaseModule = (baseModuleSchoos.Contains(schoolExpando.id)) ? true : false;
  492. schools.Add(schoolExpando);
  493. }
  494. }
  495. return Ok(new { state = 200, schools });
  496. }
  497. catch (Exception ex)
  498. {
  499. await _dingDing.SendBotMsg($"BI,{_option.Location} /batchschool/get-schools \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  500. return BadRequest();
  501. }
  502. }
  503. /// <summary>
  504. /// 修改学校信息和顾问信息
  505. /// </summary>
  506. /// <param name="jsonElement"></param>
  507. /// <returns></returns>
  508. [ProducesDefaultResponseType]
  509. [AuthToken(Roles = "admin,assist")]
  510. [HttpPost("upd-schoolassist")]
  511. public async Task<IActionResult> UpdSchoolAssist(JsonElement jsonElement)
  512. {
  513. try
  514. {
  515. if (!jsonElement.TryGetProperty("schoolId", out JsonElement _schoolId)) return BadRequest();
  516. if (!jsonElement.TryGetProperty("name", out JsonElement schoolName)) return BadRequest();
  517. if (!jsonElement.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
  518. if (!jsonElement.TryGetProperty("standard", out JsonElement standard)) return BadRequest();
  519. //if (!jsonElement.TryGetProperty("period", out JsonElement period)) return BadRequest();
  520. if (!jsonElement.TryGetProperty("picture", out JsonElement picture)) return BadRequest();
  521. if (!jsonElement.TryGetProperty("size", out JsonElement size)) return BadRequest();
  522. if (!jsonElement.TryGetProperty("scale", out JsonElement scale)) return BadRequest();
  523. if (!jsonElement.TryGetProperty("assistId", out JsonElement _assistId)) return BadRequest();
  524. if (!jsonElement.TryGetProperty("type", out JsonElement _type)) return BadRequest();
  525. var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
  526. List<string> assistId = _assistId.ToObject<List<string>>();
  527. //List<string> periodS = period.ToObject<List<string>>();
  528. Dictionary<string, List<Dictionary<string, string>>> haveSchoolManger = new Dictionary<string, List<Dictionary<string, string>>>();
  529. var cosmosClient = _azureCosmos.GetCosmosClient();
  530. School tempShool = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{_schoolId}", new PartitionKey("Base"));
  531. if (tempShool != null)
  532. {
  533. List<Period> periods = new List<Period>();
  534. string campusId = Guid.NewGuid().ToString();
  535. //periodS.ForEach(x =>
  536. //{
  537. // periods.Add(new Period { id = Guid.NewGuid().ToString(), name = x.ToString(), campusId = campusId });
  538. //});
  539. //tempShool.period = periods;
  540. tempShool.size = !string.IsNullOrEmpty($"{size}") ? int.Parse($"{size}") : tempShool.size;
  541. tempShool.scale = !string.IsNullOrEmpty($"{scale}") ? int.Parse($"{scale}") : tempShool.scale;
  542. tempShool.picture = $"{picture}";
  543. tempShool.type = int.Parse($"{_type}");
  544. tempShool.name = $"{schoolName}";
  545. tempShool.areaId = $"{areaId}";
  546. tempShool.standard = $"{standard}";
  547. //修改学校
  548. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(tempShool, tempShool.id, new PartitionKey("Base"));
  549. //修改学校教师关联的信息
  550. string sql = $"SELECT distinct value(c) FROM c join A1 in c.schools where A1.schoolId='{tempShool.id}'";
  551. List<Teacher> teachers = new List<Teacher>();
  552. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
  553. {
  554. teachers.Add(item);
  555. }
  556. foreach (var item in teachers)
  557. {
  558. Teacher.TeacherSchool teacherSchool = item.schools.Find(x => x.schoolId.Equals(tempShool.id));
  559. if (teacherSchool != null)
  560. {
  561. teacherSchool.name = tempShool.name;
  562. teacherSchool.picture = tempShool.picture;
  563. teacherSchool.areaId = tempShool.areaId;
  564. }
  565. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(item, item.id, new PartitionKey($"Base"));
  566. }
  567. //修改学校顾问
  568. string sqlTxt = $"SELECT value(c) From c WHERE ARRAY_CONTAINS(c.roles,'assist',true)";
  569. List<SchoolTeacher> schoolTeachers = new List<SchoolTeacher>();
  570. await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<SchoolTeacher>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{tempShool.id}") }))
  571. {
  572. if (!assistId.Contains(item.id))
  573. {
  574. if (item.roles.Contains("assist"))
  575. {
  576. item.roles.Remove("assist");
  577. if (item.roles.Count > 0)
  578. {
  579. await cosmosClient.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<SchoolTeacher>(item, item.id, new PartitionKey(item.code));
  580. }
  581. else
  582. {
  583. await cosmosClient.GetContainer("TEAMModelOS", "School").DeleteItemAsync<SchoolTeacher>(item.id, new PartitionKey(item.code));
  584. }
  585. }
  586. }
  587. }
  588. if (assistId.Count > 0)
  589. {
  590. foreach (var itemTeacher in assistId)
  591. {
  592. Teacher tempTeacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>($"{itemTeacher}", new PartitionKey("Base"));
  593. if (tempTeacher != null)
  594. {
  595. var haveTeacher = tempTeacher.schools.Find(x => x.schoolId.Equals($"{_schoolId}"));
  596. if (haveTeacher != null)
  597. {
  598. //查询该教师是否存在该校
  599. SchoolTeacher schoolTeacher = null;
  600. try
  601. {
  602. schoolTeacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<SchoolTeacher>($"{itemTeacher}", new PartitionKey($"Teacher-{tempShool.id}"));
  603. }
  604. catch
  605. {
  606. }
  607. if (schoolTeacher != null)
  608. {
  609. if (!schoolTeacher.roles.Contains("assist"))
  610. {
  611. schoolTeacher.roles.Add("assist");
  612. //添加顾问权限
  613. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<SchoolTeacher>(schoolTeacher, schoolTeacher.id, new PartitionKey($"Teacher-{tempShool.id}"));
  614. }
  615. }
  616. else
  617. {
  618. SchoolTeacher addSchoolTeacher = new SchoolTeacher
  619. {
  620. id = itemTeacher,
  621. code = $"Teacher-{tempShool.id}",
  622. pk = "Teacher",
  623. status = "join",
  624. roles = new List<string>() { "assist" },
  625. name = tempTeacher.name,
  626. job = $"{tempShool.name}-顾问",
  627. size = 0,
  628. createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
  629. };
  630. //添加学校顾问
  631. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(addSchoolTeacher, new PartitionKey($"Teacher-{tempShool.id}"));
  632. }
  633. }
  634. else
  635. {
  636. Teacher.TeacherSchool teacherSchool = new Teacher.TeacherSchool
  637. {
  638. schoolId = tempShool.id,
  639. name = tempShool.name,
  640. status = "join",
  641. time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
  642. picture = tempShool.picture,
  643. areaId = tempShool.areaId
  644. };
  645. tempTeacher.schools.Add(teacherSchool);
  646. //给醍摩豆顾问添加学校
  647. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(tempTeacher, tempTeacher.id, new PartitionKey($"Base"));
  648. //不存在则在原来的基础上添加顾问角色
  649. SchoolTeacher addSchoolTeacher = new SchoolTeacher
  650. {
  651. id = itemTeacher,
  652. code = $"Teacher-{tempShool.id}",
  653. pk = "Teacher",
  654. status = "join",
  655. roles = new List<string>() { "assist" },
  656. name = tempTeacher.name,
  657. job = $"{tempShool.name}-顾问",
  658. size = 0,
  659. createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
  660. };
  661. //添加学校学校顾问
  662. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(addSchoolTeacher, new PartitionKey($"Teacher-{tempShool.id}"));
  663. }
  664. }
  665. }
  666. }
  667. }
  668. //保存操作记录
  669. await _azureStorage.SaveBILog("school-update", $"{_tmdName}【{_tmdId}】修改学校功能,修改的学校:{_schoolId},{_type},{picture},{size},{string.Join("|", assistId.ToArray())}", _dingDing, httpContext: HttpContext);
  670. return Ok(new { state = 200 });
  671. }
  672. catch (Exception ex)
  673. {
  674. await _dingDing.SendBotMsg($"BI, {_option.Location} /batchschool/upd-schoolassist \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  675. return BadRequest();
  676. }
  677. }
  678. /// <summary>
  679. /// 查询区域的学校
  680. /// </summary>
  681. /// <param name="jsonElement"></param>
  682. /// <returns></returns>
  683. [ProducesDefaultResponseType]
  684. [HttpPost("get-schooldist")]
  685. public async Task<IActionResult> GetSchoolDist(JsonElement jsonElement)
  686. {
  687. try
  688. {
  689. if (!jsonElement.TryGetProperty("dist", out JsonElement _dist)) return BadRequest();
  690. var cosmosClient = _azureCosmos.GetCosmosClient();
  691. string sqltxt = $"SELECT * FROM c where c.dist='{_dist}'";
  692. List<School> schools = new List<School>();
  693. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
  694. {
  695. schools.Add(item);
  696. }
  697. return Ok(new { state = 200, schools });
  698. }
  699. catch (Exception ex)
  700. {
  701. await _dingDing.SendBotMsg($"BI,{_option.Location} /batchschool/get-schooldist \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  702. return BadRequest();
  703. }
  704. }
  705. /// <summary>
  706. /// 分页学校和顾问信息
  707. /// </summary>
  708. /// <param name="jsonElement"></param>
  709. /// <returns></returns>
  710. [HttpPost("get-schools")]
  711. public async Task<IActionResult> GetSchools(JsonElement jsonElement)
  712. {
  713. //List<School> schools = new List<School>();
  714. List<AssistSchool> schoolAssists = new List<AssistSchool>();
  715. var cosmosClient = _azureCosmos.GetCosmosClient();
  716. if (!jsonElement.TryGetProperty("endPosition", out JsonElement endPosition)) return BadRequest();
  717. if (!jsonElement.TryGetProperty("pageSize", out JsonElement pageSize)) return BadRequest();
  718. string sqltxt = $"SELECT * FROM c order by c.id offset {endPosition} limit {pageSize}";
  719. await foreach (var itemSchool in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
  720. {
  721. AssistSchool schoolAssist = new()
  722. {
  723. id = itemSchool.id,
  724. code = itemSchool.code,
  725. schoolCode = itemSchool.schoolCode,
  726. name = itemSchool.name,
  727. region = itemSchool.region,
  728. province = itemSchool.province,
  729. city = itemSchool.city,
  730. dist = itemSchool.dist,
  731. size = itemSchool.size,
  732. address = itemSchool.address,
  733. picture = itemSchool.picture,
  734. type = itemSchool.type,
  735. scale = itemSchool.scale,
  736. areaId = itemSchool.areaId,
  737. standard = itemSchool.standard
  738. };
  739. schoolAssist.assists = await CommonFind.FindSchoolRoles(cosmosClient, itemSchool.id, "assist");
  740. //List<Assist> assists = new List<Assist>();
  741. ////查询学校的顾问
  742. //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}'";
  743. //var cosmosClent = _azureCosmos.GetCosmosClient();
  744. //await foreach (var item in cosmosClent.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: managerSql, requestOptions: new QueryRequestOptions() { }))
  745. //{
  746. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  747. // foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  748. // {
  749. // Assist assist = new Assist
  750. // {
  751. // tmdId = obj.GetProperty("id").GetString(),
  752. // tmdName = obj.GetProperty("name").GetString()
  753. // };
  754. // assists.Add(assist);
  755. // }
  756. //}
  757. //schoolAssist.assists = assists;
  758. schoolAssists.Add(schoolAssist);
  759. }
  760. return Ok(new { state = 200, schoolAssists });
  761. }
  762. #region 预设学校基础信息 多语言
  763. /// <summary>
  764. /// 预设学校基础信息 多语言
  765. /// </summary>
  766. /// <param name="period"></param>
  767. /// <param name="Language"></param>
  768. /// <param name="campusId"></param>
  769. /// <returns></returns>
  770. public List<Period> PresetSchoolPeriod(List<string> period, string Language, string campusId)
  771. {
  772. var builder = $"{_environment.ContentRootPath}/JsonFile/Preset/LangSchoolConfig.json";
  773. StreamReader streamReader = new StreamReader(new FileStream(builder, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Encoding.UTF8);
  774. StringBuilder stringBuilder = new StringBuilder();
  775. string text;
  776. while ((text = streamReader.ReadLine()) != null)
  777. {
  778. stringBuilder.Append(text.ToString());
  779. }
  780. streamReader.Close();
  781. string input = stringBuilder.ToString();
  782. List<SchoolConfig> schoolConfigs = input.ToObject<List<SchoolConfig>>();
  783. SchoolConfig schoolConfig = schoolConfigs.Find(x => x.Lang.Contains($"{Language}"));
  784. if (schoolConfig == null)
  785. {
  786. if (Language.Contains("en"))
  787. schoolConfig = schoolConfigs.Find(x => x.Lang.Contains("en-US"));
  788. else
  789. schoolConfig = schoolConfigs.Find(x => x.Lang.Contains("zh-CN"));
  790. }
  791. List<Period> periods = new List<Period>();
  792. period.ForEach(x =>
  793. {
  794. periods.Add(new Period
  795. {
  796. id = Guid.NewGuid().ToString(),
  797. name = x,
  798. campusId = campusId,
  799. 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() },
  800. 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() } },
  801. subjects = new List<Subject>() {
  802. new Subject { id=Guid.NewGuid().ToString(),name=schoolConfig.PresetSubject[0].name,type=schoolConfig.PresetSubject[0].type },
  803. new Subject { id=Guid.NewGuid().ToString(),name=schoolConfig.PresetSubject[1].name,type=schoolConfig.PresetSubject[1].type },
  804. new Subject { id=Guid.NewGuid().ToString(),name=schoolConfig.PresetSubject[2].name,type=schoolConfig.PresetSubject[2].type }
  805. },
  806. grades = schoolConfig.grades,
  807. analysis = new Analysis()
  808. {
  809. type = new List<ExamSimple>() { new ExamSimple { id = Guid.NewGuid().ToString(), name = schoolConfig.PresetExam[0].type[0].name },
  810. new ExamSimple { id = Guid.NewGuid().ToString(), name = schoolConfig.PresetExam[0].type[1].name },
  811. new ExamSimple { id = Guid.NewGuid().ToString(), name = schoolConfig.PresetExam[0].type[2].name },
  812. new ExamSimple { id = Guid.NewGuid().ToString(), name = schoolConfig.PresetExam[0].type[3].name } },
  813. income = schoolConfig.PresetExam[0].income,
  814. eugenics = schoolConfig.PresetExam[0].eugenics,
  815. touch = schoolConfig.PresetExam[0].touch
  816. }
  817. });
  818. });
  819. return periods;
  820. }
  821. public record SchoolConfig
  822. {
  823. public string Lang { get; set; }
  824. public List<semester> semester { get; set; }
  825. public List<string> grades { get; set; }
  826. public List<PresetSubject> PresetSubject { get; set; }
  827. public List<PresetExam> PresetExam { get; set; }
  828. }
  829. public record semester
  830. {
  831. public string id { get; set; } = Guid.NewGuid().ToString();
  832. public string term { get; set; }
  833. public int start { get; set; }
  834. public int month { get; set; }
  835. public int day { get; set; }
  836. }
  837. public record PresetSubject
  838. {
  839. public string id { get; set; } = Guid.NewGuid().ToString();
  840. public string name { get; set; }
  841. public int type { get; set; }
  842. }
  843. public record PresetExam
  844. {
  845. public List<StudyType> type { get; set; }
  846. public int income { get; set; }
  847. public int eugenics { get; set; }
  848. public int touch { get; set; }
  849. }
  850. public record StudyType
  851. {
  852. public string id { get; set; } = Guid.NewGuid().ToString();
  853. public string name { get; set; }
  854. }
  855. #endregion
  856. //public class SchoolAssist
  857. //{
  858. // public string id { get; set; }
  859. // public string code { get; set; }
  860. // public string schoolCode { get; set; }
  861. // public string name { get; set; }
  862. // public string region { get; set; }
  863. // public string province { get; set; }
  864. // public string city { get; set; }
  865. // public string dist { get; set; }
  866. // public int size { get; set; }
  867. // public string address { get; set; }
  868. // public string picture { get; set; }
  869. // public int type { get; set; }
  870. // public int scale { get; set; }
  871. // public string standard { get; set; }
  872. // public string areaId { get; set; }
  873. // public List<SchoolTeacherRoles> assists { get; set; }
  874. // public int serial { get; set; } //软体
  875. // public int service { get; set; } //服务
  876. // public int hard { get; set; } //硬体
  877. // //public List<SchoolProductSumData> serial { get; set; } //软体
  878. // //public List<SchoolProductSumData> service { get; set; } //服务
  879. // //public List<SchoolProductSumDataHard> hard { get; set; } //硬体
  880. //}
  881. /// <summary>
  882. /// 创建多个学校实体
  883. /// </summary>
  884. public record FoundSchools()
  885. {
  886. /// <summary>
  887. /// 语系
  888. /// </summary>
  889. public string lang { get; set; }
  890. /// <summary>
  891. /// 批量创校的数据结构
  892. /// </summary>
  893. public List<BISchool> biSchools { get; set; } = new List<BISchool>();
  894. }
  895. /// <summary>
  896. /// 批量创校的数据结构
  897. /// </summary>
  898. public record BISchool()
  899. {
  900. /// <summary>
  901. /// 学校名称
  902. /// </summary>
  903. public string name { get; set; }
  904. /// <summary>
  905. /// 学校管理员
  906. /// </summary>
  907. public string admin { get; set; }
  908. /// <summary>
  909. /// 学校的学段
  910. /// </summary>
  911. public List<string> period { get; set; }
  912. /// <summary>
  913. /// 学校空间大小
  914. /// </summary>
  915. public int size { get; set; }
  916. /// <summary>
  917. /// 地区
  918. /// </summary>
  919. public string region { get; set; }
  920. /// <summary>
  921. /// 省份
  922. /// </summary>
  923. public string province { get; set; }
  924. /// <summary>
  925. /// 城市
  926. /// </summary>
  927. public string city { get; set; }
  928. /// <summary>
  929. /// 县,区,郡
  930. /// </summary>
  931. public string dist { get; set; }
  932. /// <summary>
  933. /// 学校详细地址
  934. /// </summary>
  935. public string address { get; set; }
  936. /// <summary>
  937. /// 学校类型
  938. /// </summary>
  939. public int type { get; set; }
  940. /// <summary>
  941. /// 区域ID
  942. /// </summary>
  943. public string areaId { get; set; }
  944. /// <summary>
  945. /// 区域标准
  946. /// </summary>
  947. public string standard { get; set; }
  948. }
  949. public record Exist()
  950. {
  951. public string ID { get; set; }
  952. public string name { get; set; }
  953. }
  954. }
  955. }