BatchSchoolController.cs 57 KB

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