CrazyIter_Bin 1 year ago
parent
commit
1eb1a35149

+ 22 - 1
TEAMModelOS.SDK/Models/Cosmos/Common/Activity.cs

@@ -279,6 +279,10 @@ namespace TEAMModelOS.SDK.Models
         /// 0 分数展示,1等级展示
         /// </summary>
         public int showType { get; set; }
+        /// <summary>
+        /// 在个人活动页面展示细项得分0不展示。1展示
+        /// </summary>
+        public int showDetail { get; set; }
         public List<ScoreLevel> scoreLevels { get; set; } = new List<ScoreLevel>();
         //取前多少名的数据作为公示,-1表示默认全部   0-n则表示取前n位进行公布,其他不做展示。
         public int top { get; set; } = -1;
@@ -731,7 +735,24 @@ namespace TEAMModelOS.SDK.Models
         public int showScore { get; set; }
         //public List<ExpertUploadScore> expertScore { get; set; } = new List<ExpertUploadScore>();
     }
-
+    public class MaskScoreDto {
+        /// <summary>
+        /// 醍摩豆id
+        /// </summary>
+        public string tmdid { get; set; }
+        /// <summary>
+        /// 调整分数 -1未评分
+        /// </summary>
+        public double maskScore { get; set; } = -1;
+        /// <summary>
+        /// 展示分数,0真实得分,1调整分数,默认真实得分
+        /// </summary>
+        public int showScore { get; set; }
+        /// <summary>
+        /// 修改成功200. 0未报名,1修改失败
+        /// </summary>
+        public int hasError { get; set; }
+    }
     public class ExpertUploadScore { 
         public string id { get; set; }
         public string name { get; set; }

+ 30 - 1
TEAMModelOS/Controllers/Common/ActivityController.cs

@@ -2427,17 +2427,23 @@ namespace TEAMModelOS.Controllers
                             if (!request.TryGetProperty("showType", out JsonElement _showType)) return BadRequest();
                             request.TryGetProperty("attention", out JsonElement _attention);
                             request.TryGetProperty("top", out JsonElement _top);
+                            request.TryGetProperty("showDetail", out JsonElement _showDetail);
+                            
                             List<ScoreLevel> scoreLevels = new List<ScoreLevel>();
                             bool ok = true;
                             string msg = string.Empty;
                             int code = 200;
                             //全部
-
+                            int showDetail = 0;
                             int top = -1;
                             if (int.TryParse($"{_top}", out int topReq)  && topReq>0) 
                             {
                                 top=topReq;
                             }
+                            if (int.TryParse($"{_showDetail}", out int showDetailReq)) 
+                            {
+                                showDetail=showDetailReq;
+                            }
                             if (int.TryParse($"{_showType}", out int showType))
                             {
                                 if (showType==1)
@@ -2522,6 +2528,7 @@ namespace TEAMModelOS.Controllers
                                         contest.score.scoreLevels=scoreLevels;
                                         contest.score.attention=$"{_attention}";
                                         contest.score.top=top;
+                                        contest.score.showDetail=showDetail;
                                         await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).UpsertItemAsync(contest, new PartitionKey("Contest"));
                                         return Ok(new { code = 200, msg = "操作成功" });
                                     }
@@ -2540,6 +2547,27 @@ namespace TEAMModelOS.Controllers
                                 return Ok(new { code, msg });
                             }
                         }
+                        //修改分数,在作品公布环节才能调整
+                    case bool when $"{grant_type}".Equals("update-maskScore", StringComparison.OrdinalIgnoreCase):
+                        {
+                            if (!request.TryGetProperty("activityId", out JsonElement _activityId)) return BadRequest();
+                            if (!request.TryGetProperty("maskScoreDatas", out JsonElement _maskScoreDatas)) return BadRequest();
+                            List<MaskScoreDto> maskScores = _maskScoreDatas.ToObject<List<MaskScoreDto>>();
+                            if (maskScores.IsNotEmpty()) 
+                            {
+                                Azure.Response responseContest = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).ReadItemStreamAsync(_activityId.GetString(), new PartitionKey("Contest"));
+                                if (responseContest.Status == 200)
+                                {
+                                    long now = DateTimeOffset.Now.ToUnixTimeMilliseconds();
+                                    Contest contest = JsonDocument.Parse(responseContest.Content).RootElement.ToObject<Contest>();
+                                    if (contest.review?.stime<now && contest.review?.etime>now)
+                                    {
+
+                                    }
+                                }
+                            }
+                            break;
+                        }
                 }
             }
             catch (Exception ex)
@@ -2550,6 +2578,7 @@ namespace TEAMModelOS.Controllers
             return Ok();
         }
 
+
         /// <summary>
         /// portal站的
         /// </summary>