|
@@ -502,7 +502,45 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (change.tmdjoin.Count != 0 || change.tmdhleave.Count != 0 || change.stujoin.Count != 0 || change.stuleave.Count != 0)
|
|
|
+ if (stuList.teachers != null) {
|
|
|
+ if (odlStus[0].teachers != null)
|
|
|
+ {
|
|
|
+ StuList oldStu = odlStus[0];
|
|
|
+ foreach (var teacher in stuList.teachers)
|
|
|
+ {
|
|
|
+ bool flag = false;
|
|
|
+ //判断新增名单成员不在已经存在的名单
|
|
|
+ foreach (var old in oldStu.teachers)
|
|
|
+ {
|
|
|
+ if (old.Equals(teacher))
|
|
|
+ {
|
|
|
+ flag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (flag == false)
|
|
|
+ {
|
|
|
+ change.tchjoin.Add(teacher);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ foreach (var old in oldStu.teachers)
|
|
|
+ {
|
|
|
+ bool flag = false;
|
|
|
+ //判断已存在名单成员不在变更后的名单里
|
|
|
+ foreach (var teacher in stuList.teachers)
|
|
|
+ {
|
|
|
+ if (old.Equals(teacher))
|
|
|
+ {
|
|
|
+ flag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (flag == false)
|
|
|
+ {
|
|
|
+ change.tchleave.Add(old);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (change.tmdjoin.Count != 0 || change.tmdhleave.Count != 0 || change.stujoin.Count != 0 || change.stuleave.Count != 0 || change.tchjoin.Count != 0 || change.tchleave.Count != 0)
|
|
|
{
|
|
|
var messageChange = new ServiceBusMessage(change.ToJsonString());
|
|
|
messageChange.ApplicationProperties.Add("name", "StuList");
|
|
@@ -528,7 +566,7 @@ namespace TEAMModelOS.Controllers
|
|
|
creatorId = stuList.creatorId
|
|
|
};
|
|
|
|
|
|
- var query = $"SELECT distinct value(c) FROM c where c.id='{stuList.id}'";
|
|
|
+ var query = $"SELECT distinct value(c) FROM c where c.id='{stuList.id}'";
|
|
|
List<StuList> odlStus = new List<StuList>();
|
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<StuList>(queryText: query,
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList") }))
|
|
@@ -699,7 +737,7 @@ namespace TEAMModelOS.Controllers
|
|
|
|
|
|
//查询名单
|
|
|
[ProducesDefaultResponseType]
|
|
|
- //[AuthToken(Roles = "Teacher")]
|
|
|
+ [AuthToken(Roles = "admin,teacher")]
|
|
|
[HttpPost("get-summary-list")]
|
|
|
public async Task<IActionResult> getSummary(JsonElement requert)
|
|
|
{
|
|
@@ -707,45 +745,41 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
|
if (!requert.TryGetProperty("scope", out JsonElement scope)) return BadRequest();
|
|
|
- if (!requert.TryGetProperty("ids", out JsonElement classId)) return BadRequest();
|
|
|
+ requert.TryGetProperty("ids", out JsonElement _stuids);
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
List<object> stuList = new();
|
|
|
- //List<int> stuCount = new List<int>();
|
|
|
List<string> ids = new();
|
|
|
- ids = classId.ToObject<List<string>>();
|
|
|
- if (!(ids.Count > 0)) return BadRequest();
|
|
|
- //List<Students> stu = new();
|
|
|
- var query = $"select c.id,c.name,c.students,c.tmids,c.no,c.code,c.scope,c.school,c.creatorId from c where c.id in ({string.Join(",", ids.Select(o => $"'{o}'"))})";
|
|
|
+ ids = _stuids.ToObject<List<string>>();
|
|
|
+ // var query = $"select c.id,c.name,c.students,c.tmids,c.periodId from c";
|
|
|
+ StringBuilder query = new StringBuilder($"select c.id,c.name,c.students,c.tmids,c.no,c.code,c.scope,c.school,c.creatorId,c.periodId from c ");
|
|
|
+ if (ids.IsNotEmpty()) {
|
|
|
+ string sql= $" where c.id in ({string.Join(",", ids.Select(o => $"'{o}'"))})";
|
|
|
+ query.Append(sql);
|
|
|
+ }
|
|
|
if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
|
|
|
{
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{code}") }))
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: query.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{code}") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
{
|
|
|
foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
{
|
|
|
- //stu = obj.GetProperty("students").ToObject<List<Students>>();
|
|
|
stuList.Add(obj.ToObject<object>());
|
|
|
- //stuList.Add(stu.Count);
|
|
|
- //stuCount.Add(stu.Count);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
{
|
|
|
foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
{
|
|
|
- //stu = obj.GetProperty("students").ToObject<List<Students>>();
|
|
|
stuList.Add(obj.ToObject<object>());
|
|
|
- //stuList.Add(stu.Count);
|
|
|
- //stuCount.Add(stu.Count);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -759,10 +793,43 @@ namespace TEAMModelOS.Controllers
|
|
|
return BadRequest();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
//查询名单
|
|
|
[ProducesDefaultResponseType]
|
|
|
- //[AuthToken(Roles = "Teacher")]
|
|
|
+ [AuthToken(Roles = "admin,teacher")]
|
|
|
+ [HttpPost("get-research-list")]
|
|
|
+ public async Task<IActionResult> getResearch(JsonElement requert)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
|
+ if (!requert.TryGetProperty("scope", out JsonElement scope)) return BadRequest();
|
|
|
+ requert.TryGetProperty("ids", out JsonElement _stuids);
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ List<StuList> stuList = new();
|
|
|
+ List<string> ids = new();
|
|
|
+ ids = _stuids.ToObject<List<string>>();
|
|
|
+ // var query = $"select c.id,c.name,c.students,c.tmids,c.periodId from c";
|
|
|
+ StringBuilder query = new StringBuilder($"select vaule(c) from c where c.type='research' ");
|
|
|
+ if (ids.IsNotEmpty())
|
|
|
+ {
|
|
|
+ string sql = $" and c.id in ({string.Join(",", ids.Select(o => $"'{o}'"))})";
|
|
|
+ query.Append(sql);
|
|
|
+ }
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<StuList>(queryText: query.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{code}") }))
|
|
|
+ {
|
|
|
+ stuList.Add(item);
|
|
|
+ }
|
|
|
+ return Ok(new { stuList });
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ await _dingDing.SendBotMsg($"OS,{_option.Location},course/get-summary-list()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
|
|
|
+ return BadRequest();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //查询名单
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [AuthToken(Roles = "admin,teacher")]
|
|
|
[HttpPost("delete-list")]
|
|
|
public async Task<IActionResult> deleteList(JsonElement requert)
|
|
|
{
|
|
@@ -772,50 +839,14 @@ namespace TEAMModelOS.Controllers
|
|
|
if (!requert.TryGetProperty("scope", out JsonElement scope)) return BadRequest();
|
|
|
if (!requert.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
- //var query = $"select c.id,c.name,c.students,c.tmids from c where c.id in ({string.Join(",", ids.Select(o => $"'{o}'"))})";
|
|
|
if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
|
|
|
{
|
|
|
- /*List<string> classIds = new List<string>();
|
|
|
- var query = $"select c.id from c join A0 in c.schedule where A0.teacherId = '{id}'";
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{id}") }))
|
|
|
- {
|
|
|
- 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;
|
|
|
- if (string.IsNullOrEmpty(account.GetProperty("id").GetString()))
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- classIds.Add(account.GetProperty("id").GetString());
|
|
|
- listClassInfo.Add((account.GetProperty("id").GetString(), account.GetProperty("scope").GetString()));
|
|
|
- }
|
|
|
- }
|
|
|
- }*/
|
|
|
await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"StuList-{code}"));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"StuLis"));
|
|
|
- /*await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
|
|
|
- {
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
- {
|
|
|
- foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
- {
|
|
|
- List<Students> stu = obj.GetProperty("students").ToObject<List<Students>>();
|
|
|
- stuList.Add(obj.ToObject<object>());
|
|
|
- //stuList.Add(stu.Count);
|
|
|
- //stuCount.Add(stu.Count);
|
|
|
- }
|
|
|
- }
|
|
|
- }*/
|
|
|
}
|
|
|
-
|
|
|
return Ok(new { id });
|
|
|
}
|
|
|
catch (Exception ex)
|