BatchSchoolController.cs 57 KB

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