瀏覽代碼

版本号修改

CrazyIter_Bin 3 年之前
父節點
當前提交
02c7bd5306
共有 2 個文件被更改,包括 139 次插入15 次删除
  1. 1 1
      TEAMModelOS.SDK/TEAMModelOS.SDK.csproj
  2. 138 14
      TEAMModelOS/Controllers/Research/AbilityStatisticsController.cs

+ 1 - 1
TEAMModelOS.SDK/TEAMModelOS.SDK.csproj

@@ -11,7 +11,7 @@
 
 
   <ItemGroup>
-    <PackageReference Include="HTEXLib" Version="5.2108.27" />
+    <PackageReference Include="HTEXLib" Version="5.2109.6" />
     <PackageReference Include="AspectCore.Extensions.Reflection" Version="2.2.0" />
     <PackageReference Include="Azure.Cosmos" Version="4.0.0-preview3" />
     <PackageReference Include="Azure.Identity" Version="1.4.0" />

+ 138 - 14
TEAMModelOS/Controllers/Research/AbilityStatisticsController.cs

@@ -1073,17 +1073,15 @@ namespace TEAMModelOS.Controllers.Research
             try
             {
                 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();
                 if (!request.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
@@ -1107,19 +1105,76 @@ namespace TEAMModelOS.Controllers.Research
 
                 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)
                     {
                         try
                         {
+
                             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}") }))
                             {
-                                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) { }
                     }
+                    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 });
                 }
                 else
@@ -1127,7 +1182,9 @@ namespace TEAMModelOS.Controllers.Research
                     var teacer = teachers.Find(x => x.id.Equals($"{_tmdid}"));
                     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();
                         foreach (var t in tecs)
                         {
@@ -1136,9 +1193,58 @@ namespace TEAMModelOS.Controllers.Research
                             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}") }))
                             {
-                                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 });
                     }
                     else
@@ -1153,6 +1259,24 @@ namespace TEAMModelOS.Controllers.Research
                 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>