|
@@ -1073,17 +1073,15 @@ namespace TEAMModelOS.Controllers.Research
|
|
try
|
|
try
|
|
{
|
|
{
|
|
if (!HttpContext.Items.TryGetValue("Standard", out object standard)) return BadRequest();
|
|
if (!HttpContext.Items.TryGetValue("Standard", out object standard)) return BadRequest();
|
|
- (string id, _, _, string school) = HttpContext.GetAuthTokenInfo();
|
|
|
|
- if (string.IsNullOrEmpty(school))
|
|
|
|
|
|
+ // (string id, _, _, string school) = HttpContext.GetAuthTokenInfo();
|
|
|
|
+ string school = "";
|
|
|
|
+ if (!request.TryGetProperty("school", out JsonElement _school))
|
|
{
|
|
{
|
|
- if (!request.TryGetProperty("school", out JsonElement _school))
|
|
|
|
- {
|
|
|
|
- return BadRequest();
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- school = $"{_school}";
|
|
|
|
- }
|
|
|
|
|
|
+ return BadRequest();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ school = $"{_school}";
|
|
}
|
|
}
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
if (!request.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
|
|
if (!request.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
|
|
@@ -1107,19 +1105,76 @@ namespace TEAMModelOS.Controllers.Research
|
|
|
|
|
|
if ($"{_all}".Equals("1"))
|
|
if ($"{_all}".Equals("1"))
|
|
{
|
|
{
|
|
- List<dynamic> groupMembers = new List<dynamic>();
|
|
|
|
|
|
+ List<SubGroupMember> groupMembers = new List<SubGroupMember>();
|
|
|
|
+ List<Debate> debates = new List<Debate>();
|
|
|
|
+ HashSet<string> comids = new HashSet<string>();
|
|
foreach (var t in teachers)
|
|
foreach (var t in teachers)
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
|
|
+
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
|
|
.GetItemQueryIterator<AbilitySub>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilitySub-{school}-{t.id}") }))
|
|
.GetItemQueryIterator<AbilitySub>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilitySub-{school}-{t.id}") }))
|
|
{
|
|
{
|
|
- groupMembers.Add(new { tmdname = t.name, tmdid = t.id, picture = t.picture, groupName = t.groupName, groupId = t.groupId, sub = new { abilityId = item.id, code = item.code, uploads = item.uploads, otherScore = item.otherScore, comid = item.comid, self = item.self } });
|
|
|
|
|
|
+ comids.Add(item.comid);
|
|
|
|
+ groupMembers.Add(new SubGroupMember
|
|
|
|
+ {
|
|
|
|
+ tmdname = t.name,
|
|
|
|
+ tmdid = t.id,
|
|
|
|
+ picture = t.picture,
|
|
|
|
+ groupName = t.groupName,
|
|
|
|
+ groupId = t.groupId,
|
|
|
|
+ sub = new SubGroup
|
|
|
|
+ {
|
|
|
|
+ abilityId = item.id,
|
|
|
|
+ code = item.code,
|
|
|
|
+ uploads = item.uploads,
|
|
|
|
+ otherScore = item.otherScore,
|
|
|
|
+ comid = item.comid,
|
|
|
|
+ self = item.self
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
catch (CosmosException ex) { }
|
|
catch (CosmosException ex) { }
|
|
}
|
|
}
|
|
|
|
+ foreach (var comid in comids)
|
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ Debate debate = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReadItemAsync<Debate>(comid, new PartitionKey($"Debate-{school}"));
|
|
|
|
+ debates.Add(debate);
|
|
|
|
+ }
|
|
|
|
+ catch (CosmosException ex)
|
|
|
|
+ {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<DebateReply> debateReplies = debates.SelectMany(x => x.replies).ToList();
|
|
|
|
+ groupMembers.ForEach(groupMember =>
|
|
|
|
+ {
|
|
|
|
+ groupMember.sub.otherScore.ForEach(y =>
|
|
|
|
+ {
|
|
|
|
+ List<string> replyIds = new List<string>();
|
|
|
|
+ y.replyIds.ForEach(reply =>
|
|
|
|
+ {
|
|
|
|
+ if (reply != null)
|
|
|
|
+ {
|
|
|
|
+ DebateReply replies = debateReplies.Find(x => reply.Equals(x.id));
|
|
|
|
+ if (replies != null)
|
|
|
|
+ {
|
|
|
|
+ replyIds.Add(replies.comment);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ y.replyIds = replyIds;
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ });
|
|
return Ok(new { groupMembers, abilities });
|
|
return Ok(new { groupMembers, abilities });
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -1127,7 +1182,9 @@ namespace TEAMModelOS.Controllers.Research
|
|
var teacer = teachers.Find(x => x.id.Equals($"{_tmdid}"));
|
|
var teacer = teachers.Find(x => x.id.Equals($"{_tmdid}"));
|
|
if (teacer != null)
|
|
if (teacer != null)
|
|
{
|
|
{
|
|
- List<dynamic> groupMembers = new List<dynamic>();
|
|
|
|
|
|
+ List<Debate> debates = new List<Debate>();
|
|
|
|
+ List<SubGroupMember> groupMembers = new List<SubGroupMember>();
|
|
|
|
+ HashSet<string> comids = new HashSet<string>();
|
|
var tecs = teachers.Where(x => x.groupId.Equals(teacer.groupId)).ToList();
|
|
var tecs = teachers.Where(x => x.groupId.Equals(teacer.groupId)).ToList();
|
|
foreach (var t in tecs)
|
|
foreach (var t in tecs)
|
|
{
|
|
{
|
|
@@ -1136,9 +1193,58 @@ namespace TEAMModelOS.Controllers.Research
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
|
|
.GetItemQueryIterator<AbilitySub>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilitySub-{school}-{t.id}") }))
|
|
.GetItemQueryIterator<AbilitySub>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilitySub-{school}-{t.id}") }))
|
|
{
|
|
{
|
|
- groupMembers.Add(new { tmdname = t.name, tmdid = t.id, picture = t.picture, groupName = t.groupName, groupId = t.groupId, sub = new { abilityId = item.id, code = item.code, uploads = item.uploads, otherScore = item.otherScore, comid = item.comid, self = item.self } });
|
|
|
|
|
|
+ groupMembers.Add(new SubGroupMember
|
|
|
|
+ {
|
|
|
|
+ tmdname = t.name,
|
|
|
|
+ tmdid = t.id,
|
|
|
|
+ picture = t.picture,
|
|
|
|
+ groupName = t.groupName,
|
|
|
|
+ groupId = t.groupId,
|
|
|
|
+ sub = new SubGroup
|
|
|
|
+ {
|
|
|
|
+ abilityId = item.id,
|
|
|
|
+ code = item.code,
|
|
|
|
+ uploads = item.uploads,
|
|
|
|
+ otherScore = item.otherScore,
|
|
|
|
+ comid = item.comid,
|
|
|
|
+ self = item.self
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ foreach (var comid in comids)
|
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ Debate debate = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReadItemAsync<Debate>(comid, new PartitionKey($"Debate-{school}"));
|
|
|
|
+ debates.Add(debate);
|
|
|
|
+ }
|
|
|
|
+ catch (CosmosException ex)
|
|
|
|
+ {
|
|
|
|
+ continue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ List<DebateReply> debateReplies = debates.SelectMany(x => x.replies).ToList();
|
|
|
|
+ groupMembers.ForEach(groupMember =>
|
|
|
|
+ {
|
|
|
|
+ groupMember.sub.otherScore.ForEach(y =>
|
|
|
|
+ {
|
|
|
|
+ List<string> replyIds = new List<string>();
|
|
|
|
+ y.replyIds.ForEach(reply =>
|
|
|
|
+ {
|
|
|
|
+ if (reply != null)
|
|
|
|
+ {
|
|
|
|
+ DebateReply replies = debateReplies.Find(x => reply.Equals(x.id));
|
|
|
|
+ if (replies != null)
|
|
|
|
+ {
|
|
|
|
+ replyIds.Add(replies.comment);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ y.replyIds = replyIds;
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ });
|
|
return Ok(new { groupMembers, abilities });
|
|
return Ok(new { groupMembers, abilities });
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -1153,6 +1259,24 @@ namespace TEAMModelOS.Controllers.Research
|
|
return BadRequest();
|
|
return BadRequest();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ public class SubGroup
|
|
|
|
+ {
|
|
|
|
+ public string comid { get; set; }
|
|
|
|
+ public int self { get; set; }
|
|
|
|
+ public string abilityId { get; set; }
|
|
|
|
+ public string code { get; set; }
|
|
|
|
+ public List<SubUpload> uploads { get; set; }
|
|
|
|
+ public List<OtherScore> otherScore { get; set; }
|
|
|
|
+ }
|
|
|
|
+ public class SubGroupMember
|
|
|
|
+ {
|
|
|
|
+ public string tmdname { get; set; }
|
|
|
|
+ public string tmdid { get; set; }
|
|
|
|
+ public string picture { get; set; }
|
|
|
|
+ public string groupName { get; set; }
|
|
|
|
+ public string groupId { get; set; }
|
|
|
|
+ public SubGroup sub { get; set; }
|
|
|
|
+ }
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 保存
|
|
/// 保存
|
|
/// </summary>
|
|
/// </summary>
|