BatchSchoolController.cs 54 KB

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