Browse Source

Merge branch 'develop5.0-tmd' of http://106.12.23.251:10000/TEAMMODEL/TEAMModelOS into develop5.0-tmd

liqk 3 years ago
parent
commit
ab9ebf2af5

+ 1 - 1
TEAMModelOS.SDK/Models/Cosmos/Common/Notice.cs

@@ -10,7 +10,7 @@ namespace TEAMModelOS.SDK.Models
         public string title { get; set; }
         public string content { get; set; }
         public string school { get; set; }
-        public string scope { get; set; }
+        
         [Required(ErrorMessage = "creatorId 必须设置")]
         public string creatorId { get; set; }
         /// <summary>

+ 2 - 2
TEAMModelOS/ClientApp/src/view/evaluation/index/TestPaper.vue

@@ -81,9 +81,9 @@
 						:curPeriodIndex="paperInfo.paperPeriod" :curSubjectIndex="paperInfo.paperSubject">
 					</BaseCreateChild>
 				</TabPane>
-				<TabPane label="快速出题" name="name2" tab="newExerciseTab">
+				<!-- <TabPane label="快速出题" name="name2" tab="newExerciseTab">
 					<BasePasteTool></BasePasteTool>
-				</TabPane>
+				</TabPane> -->
 			</Tabs>
 		</Modal>
 

+ 2 - 2
TEAMModelOS/ClientApp/src/view/student-analysis/total-analysis/EvaluationList/TotalIndex.vue

@@ -11,12 +11,12 @@
 			<div class="section">
 				<!-- 评测数据统计部分 -->
 				<div class="section">
-					<div class="section-title">
+					<div class="section-title" @click="goAnswerSheet">
 						{{ $t("totalAnalysis.ti_title2") }}
 					</div>
 					<div class="section-box">
 						<div class="exam-data-item block-item">
-							<div class="item-content" @click="goAnswerSheet">
+							<div class="item-content">
 								<div class="item-num">{{ originList.length }}</div>
 								<div class="item-name">
 									{{ $t("totalAnalysis.ti_text12") }}

+ 2 - 1
TEAMModelOS/Controllers/Common/VoteController.cs

@@ -223,7 +223,7 @@ namespace TEAMModelOS.Controllers.Learn
 
                 };
                 var progresssql = "";
-                if (!requert.TryGetProperty("progress", out JsonElement progress))
+                if (requert.TryGetProperty("progress", out JsonElement progress))
                 {
 
                     if (!progress.ValueKind.Equals(JsonValueKind.Undefined) && !progress.ValueKind.Equals(JsonValueKind.Null) && progress.ValueKind.Equals(JsonValueKind.String))
@@ -386,6 +386,7 @@ namespace TEAMModelOS.Controllers.Learn
             }
             catch (Exception e)
             {
+                await _dingDing.SendBotMsg($"{_option.Location}-投票活动{e.Message}\n{e.StackTrace}", GroupNames.成都开发測試群組);
                 return BadRequest(e.StackTrace);
             }
         }

+ 59 - 29
TEAMModelOS/Controllers/School/NoticeController.cs

@@ -58,6 +58,7 @@ namespace TEAMModelOS.Controllers
         {
             try
             {
+                var (userid, _, _, school) = HttpContext.GetAuthTokenInfo();
                 //新增
                 var client = _azureCosmos.GetCosmosClient();
                 request.code =$"Notice-{request.code}";
@@ -65,7 +66,7 @@ namespace TEAMModelOS.Controllers
                 request.ttl = -1;
                 long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                 request.createTime = now;
-
+                request.creatorId = userid;
                 //如果设置的时间是小于当前时间则立即发布
                 if (request.startTime <= 0)
                 {
@@ -78,20 +79,20 @@ namespace TEAMModelOS.Controllers
                 {
                     request.id = Guid.NewGuid().ToString();
                   
-                    request = await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
+                    request = await client.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(request, new PartitionKey($"{request.code}"));
                 }
                 else
                 {
-                    var response = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync(request.id, new PartitionKey($"{request.code}"));
+                    var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(request.id, new PartitionKey($"{request.code}"));
                  
                     if (response.Status == 200)
                     {
                        
-                        request = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(request, request.id, new PartitionKey($"{request.code}"));
+                        request = await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(request, request.id, new PartitionKey($"{request.code}"));
                     }
                     else
                     {
-                        request = await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
+                        request = await client.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(request, new PartitionKey($"{request.code}"));
                     }
                 }
                 return Ok(new { vote = request });
@@ -124,46 +125,52 @@ namespace TEAMModelOS.Controllers
                 var (userid, _, _, school) = HttpContext.GetAuthTokenInfo();
                 //必须有学校或者教师编码
                 if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
-                //开始时间,默认最近三十天
-                var stimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
-                if (requert.TryGetProperty("stime", out JsonElement stime))
-                {
-                    if (long.TryParse($"{stime}", out long data))
+                requert.TryGetProperty("admin", out JsonElement admin);
+                string stimestampsql = "";
+                string etimestampsql = "";
+                if (!$"{admin}" .Equals("1")) {
+                    var stimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+                    if (requert.TryGetProperty("stime", out JsonElement stime))
                     {
-                        stimestamp = data;
-                    };
-                };
-                //默认当前时间
-                var etimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
-                if (requert.TryGetProperty("etime", out JsonElement etime))
-                {
-                    if (long.TryParse($"{etime}", out long data))
+                        if (long.TryParse($"{stime}", out long data))
+                        {
+                            stimestamp = data;
+                        }
+                    }
+                    stimestampsql = $" and c.startTime <= {stimestamp} ";
+                    //默认当前时间
+                    var etimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+                    if (requert.TryGetProperty("etime", out JsonElement etime))
                     {
-                        etimestamp = data;
-                    };
-
-                };
-                var progresssql = "";
-                if (!requert.TryGetProperty("publish", out JsonElement publish))
+                        if (long.TryParse($"{etime}", out long data))
+                        {
+                            etimestamp = data;
+                        }
+                    }
+                    etimestampsql = $" and c.endTime >= {etimestamp} ";
+                   
+                }
+                var publishsql = "";
+                if (requert.TryGetProperty("publish", out JsonElement publish))
                 {
 
-                    if (!publish.ValueKind.Equals(JsonValueKind.Undefined) && !publish.ValueKind.Equals(JsonValueKind.Null) && publish.ValueKind.Equals(JsonValueKind.String))
+                    if (!publish.ValueKind.Equals(JsonValueKind.Undefined) && !publish.ValueKind.Equals(JsonValueKind.Null) && publish.ValueKind.Equals(JsonValueKind.Number))
                     {
-                        progresssql = $" and c.publish={publish} ";
+                        publishsql = $" and c.publish={publish} ";
                     }
                 }
                 var typesql = "";
-                if (!requert.TryGetProperty("type", out JsonElement type))
+                if (requert.TryGetProperty("type", out JsonElement type))
                 {
 
-                    if (!publish.ValueKind.Equals(JsonValueKind.Undefined) && !publish.ValueKind.Equals(JsonValueKind.Null) && publish.ValueKind.Equals(JsonValueKind.String))
+                    if (!type.ValueKind.Equals(JsonValueKind.Undefined) && !type.ValueKind.Equals(JsonValueKind.Null) && type.ValueKind.Equals(JsonValueKind.String))
                     {
                         typesql = $" and c.type='{type}' ";
                     }
                 }
                 List<Notice> notices = new List<Notice>();
                 var client = _azureCosmos.GetCosmosClient();
-                var query = $"select value(c) from c where c.endTime >= {stimestamp} and c.startTime <= {etimestamp}  {progresssql } and c.ttl=-1 ";
+                var query = $"select value(c) from c where  c.ttl=-1 {etimestampsql} {stimestampsql} {publishsql }  {typesql} ";
                 await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Notice>(queryText: query,
                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Notice-{code}") }))
                 {
@@ -177,5 +184,28 @@ namespace TEAMModelOS.Controllers
                 return BadRequest(ex.StackTrace);
             }
         }
+        /// <summary>
+        /// 删除
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [HttpPost("delete")]
+        [AuthToken(Roles = "admin,teacher")]
+        public async Task<IActionResult> Delete(JsonElement request) {
+            try
+            {
+                var (userid, _, _, school) = HttpContext.GetAuthTokenInfo();
+                if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
+                if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
+                var client = _azureCosmos.GetCosmosClient();
+                await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemStreamAsync(id.GetString(), new PartitionKey($"Notice-{code}"));
+                return Ok(new { status = 200 });
+            }
+            catch (Exception e)
+            {
+                return BadRequest(e.StackTrace);
+            }
+        }
     }
 }