|
@@ -199,11 +199,28 @@ namespace TEAMModelOS.Controllers
|
|
|
try
|
|
|
{
|
|
|
if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
|
- if (!request.TryGetProperty("para", out JsonElement para)) return BadRequest();
|
|
|
+ //if (!request.TryGetProperty("para", out JsonElement para)) return BadRequest();
|
|
|
if (!request.TryGetProperty("study", out JsonElement stu)) return BadRequest();
|
|
|
- List<parameter> parameters = para.ToObject<List<parameter>>();
|
|
|
+ //List<parameter> parameters = para.ToObject<List<parameter>>();
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
var (userid, _, _, school) = HttpContext.GetAuthTokenInfo();
|
|
|
+ //获取区级以下所有学校编码和基础信息
|
|
|
+ List<string> baseIds = new();
|
|
|
+ //List<(string id, string name, string picture)> scInfos = new List<(string id, string name, string picture)>();
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.areaId = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
+ {
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ {
|
|
|
+ var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ while (accounts.MoveNext())
|
|
|
+ {
|
|
|
+ JsonElement account = accounts.Current;
|
|
|
+ baseIds.Add(account.GetProperty("id").GetString());
|
|
|
+ //scInfos.Add((account.GetProperty("id").GetString(), account.GetProperty("name").GetString(), account.GetProperty("picture").GetString()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
List<Study> studies = new();
|
|
|
Study areaStudy = stu.ToObject<Study>();
|
|
@@ -236,19 +253,18 @@ namespace TEAMModelOS.Controllers
|
|
|
list.code = "GroupList";
|
|
|
list.school = null;
|
|
|
list = await GroupListService.UpsertList(list, _azureCosmos, _azureStorage, _configuration, _serviceBus);
|
|
|
- foreach (parameter pa in parameters)
|
|
|
+ foreach (string scId in baseIds)
|
|
|
{
|
|
|
Study study = stu.ToObject<Study>();
|
|
|
study.areaId = id.GetString();
|
|
|
- study.school = pa.sId;
|
|
|
+ study.school = scId;
|
|
|
study.owner = "area";
|
|
|
study.ttl = -1;
|
|
|
- study.code = "Study-" + pa.sId;
|
|
|
+ study.code = "Study-" + scId;
|
|
|
study.createTime = now;
|
|
|
study.creatorId = userid;
|
|
|
study.publish = 1;
|
|
|
study.progress = "pending";
|
|
|
- //study.tchLists = pa.gId;
|
|
|
study.pId = areaStudy.id;
|
|
|
study.scope = "school";
|
|
|
study.targetType = "research";
|
|
@@ -260,9 +276,8 @@ namespace TEAMModelOS.Controllers
|
|
|
if (!request.TryGetProperty("exam", out JsonElement exam)) return BadRequest();
|
|
|
ExamLite trExam = exam.ToObject<ExamLite>();
|
|
|
trExam.owner = "area";
|
|
|
- trExam.school = pa.sId;
|
|
|
+ trExam.school = scId;
|
|
|
trExam.areaId = id.GetString();
|
|
|
- //trExam.tchLists = pa.gId;
|
|
|
trExam.creatorId = userid;
|
|
|
trExam.targetType = "research";
|
|
|
trExam.publish = 1;
|
|
@@ -286,7 +301,7 @@ namespace TEAMModelOS.Controllers
|
|
|
if (!request.TryGetProperty("survey", out JsonElement survey)) return BadRequest();
|
|
|
Survey trSurvey = survey.ToObject<Survey>();
|
|
|
trSurvey.owner = "area";
|
|
|
- trSurvey.school = pa.sId;
|
|
|
+ trSurvey.school = scId;
|
|
|
trSurvey.areaId = id.GetString();
|
|
|
//trSurvey.tchLists = pa.gId;
|
|
|
trSurvey.scope = "school";
|
|
@@ -311,7 +326,7 @@ namespace TEAMModelOS.Controllers
|
|
|
if (!request.TryGetProperty("work", out JsonElement work)) return BadRequest();
|
|
|
Homework homework = work.ToObject<Homework>();
|
|
|
homework.owner = "area";
|
|
|
- homework.school = pa.sId;
|
|
|
+ homework.school = scId;
|
|
|
homework.areaId = id.GetString();
|
|
|
//homework.tchLists = pa.gId;
|
|
|
homework.scope = "school";
|