Prechádzať zdrojové kódy

共编分享更新数据结构

CrazyIter_Bin 4 rokov pred
rodič
commit
5ae532788a

+ 8 - 0
TEAMModelOS.SDK/Models/Cosmos/Teacher/Share.cs

@@ -73,6 +73,14 @@ namespace TEAMModelOS.SDK.Models
         /// 分享-是否同意
         /// </summary>
         public int sagree { get; set; } =0;
+        /// <summary>
+        /// 分享  type=coedit共编,share分享
+        /// </summary>
+        public bool type { get; set; }
+        /// <summary>
+        /// 是否同意
+        /// </summary>
+        public int agree { get; set; } = 0;
     }
     /// <summary>
     /// 主动分享给谁,当接收者接收并完成相关资源复制后则删除本条数据。

+ 48 - 1
TEAMModelOS/Controllers/Syllabus/ShareController.cs

@@ -265,7 +265,54 @@ namespace TEAMModelOS.Controllers
             }
             return (syllabus, shares);
         }
-
+        /// <summary>
+        /// {"code":"教师编码","id":"章节id"} 
+        /// 教师删除自己收到的
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [HttpPost("del-share")]
+        // [AuthToken(Roles = "Teacher")]
+        public async Task<IActionResult> DelShare(JsonElement request) {
+            try {
+                if (!request.TryGetProperty("code", out JsonElement code)) { return BadRequest(); }
+                if (!request.TryGetProperty("id", out JsonElement id)) { return BadRequest(); }
+                var client = _azureCosmos.GetCosmosClient();
+                Share share = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Share>($"{id}", new PartitionKey($"Share-{code}"));
+                Syllabus syllabus = null;
+                if (share.scope == "school")
+                {
+                    syllabus = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Syllabus>($"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
+                }
+                else if (share.scope == "private")
+                {
+                    syllabus = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Syllabus>($"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
+                }
+                if (syllabus.auth.IsNotEmpty())
+                {
+                    syllabus.auth.ForEach(x =>
+                    {
+                        if (x.tmdid == $"{code}")
+                        {
+                            x.sagree = 0;
+                        }
+                    });
+                }
+                if (share.scope == "school")
+                {
+                    syllabus = await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<Syllabus>(syllabus, $"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
+                }
+                else if (share.scope == "private")
+                {
+                    syllabus = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Syllabus>(syllabus, $"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
+                }
+                return Ok(new { status = 200 });
+            } catch (Exception ex) {
+                await _dingDing.SendBotMsg($"OS,{_option.Location},teacher/share/del-share()\n{ex.Message}{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
+                return Ok(new { status = 500 });
+            }
+        }
         /// <summary>
         /// {"code":"教师编码","id":"章节id","agree":1共编同意,2共编拒绝,3分享同意,4分享拒绝} 
         /// 教师拉取自己收到的分享及共编

+ 1 - 1
TEAMModelOS/Controllers/Teacher/InitController.cs

@@ -183,7 +183,7 @@ namespace TEAMModelOS.Controllers
                 await container.CreateIfNotExistsAsync(PublicAccessType.None); //嘗試創建Teacher私有容器,如存在則不做任何事,保障容器一定存在
                 var (blob_uri, blob_sas) = _azureStorage.GetBlobContainerSAS(id, BlobContainerSasPermissions.Write | BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List | BlobContainerSasPermissions.Delete);
 
-                return Ok(new { auth_token, blob_uri, blob_sas, schools, defaultschool, courses });
+                return Ok(new { auth_token, blob_uri, blob_sas, schools, defaultschool, courses ,size});
 
             }
             catch (Exception ex)