CrazyIter_Bin 3 лет назад
Родитель
Сommit
6948435864

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

@@ -6,5 +6,6 @@ namespace TEAMModelOS.SDK.Models.Cosmos.Common
 {
     public class Notice :CosmosEntity
     {
+
     }
 }

+ 7 - 1
TEAMModelOS.SDK/Models/Cosmos/Teacher/Share.cs

@@ -90,7 +90,7 @@ namespace TEAMModelOS.SDK.Models
         public string opt { get; set; }
 
         [Required(ErrorMessage = "tmdid 必须设置")]
-        public List<TmdInfo> tmdInfo { get; set; } = new List<TmdInfo>();
+        public List<ShareTmd> tmdInfo { get; set; } = new List<ShareTmd>();
       
         /// <summary>
         /// 课纲章节的id
@@ -126,4 +126,10 @@ namespace TEAMModelOS.SDK.Models
         /// </summary>
         public int agree { get; set; } = 0;
     }
+    public class ShareTmd
+    {
+        public string tmdid { get; set; }
+        public string tmdname { get; set; }
+        public string picture { get; set; }
+    }
 }

+ 11 - 11
TEAMModelOS/Controllers/Syllabus/ShareController.cs

@@ -83,7 +83,7 @@ namespace TEAMModelOS.Controllers
                         {
                             List<SyllabusAuth> syllabusAuths = new List<SyllabusAuth>();
                             syllabusD.auth.ForEach(x => {
-                                if (request.tmdInfo.Select(tmd => tmd.id).Contains(x.tmdid)) {
+                                if (request.tmdInfo.Select(tmd => tmd.tmdid).Contains(x.tmdid)) {
                                     syllabusAuths.Add(x);
                                 }
                             });
@@ -92,7 +92,7 @@ namespace TEAMModelOS.Controllers
                             });
                             await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<Syllabus>(syllabusD, request.syllabusId, new PartitionKey($"Syllabus-{request.school}"));
                             request.tmdInfo.ForEach(async x => {
-                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemAsync<Share>(request.syllabusId, new PartitionKey($"Share-{request.type}-{x.id}"));
+                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemAsync<Share>(request.syllabusId, new PartitionKey($"Share-{request.type}-{x.tmdid}"));
                             });
 
                         }
@@ -157,7 +157,7 @@ namespace TEAMModelOS.Controllers
                             await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Syllabus>(syllabusD, request.syllabusId, new PartitionKey($"Syllabus-{request.issuer}"));
                             request.tmdInfo.ForEach(async x => {
                                 try {
-                                    await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemAsync<Share>(request.syllabusId, new PartitionKey($"Share-{request.type}-{x.id}"));
+                                    await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemAsync<Share>(request.syllabusId, new PartitionKey($"Share-{request.type}-{x.tmdid}"));
                                 } catch 
                                 {
                                     //仅处理找不到数据的情况
@@ -209,7 +209,7 @@ namespace TEAMModelOS.Controllers
                     volumeId = request.volumeId,
                     volumeName = request.volumeName,
                     syllabusName = request.syllabusName,
-                    code = $"Share-{request.type}-{xmd.id}",
+                    code = $"Share-{request.type}-{xmd.tmdid}",
                     pk = "Share",
                     ttl = -1,
                     issuer = request.issuer,
@@ -231,7 +231,7 @@ namespace TEAMModelOS.Controllers
                     int indx = 0;
                     for (int index = 0; index < syllabus.auth.Count; index++)
                     {
-                        if (syllabus.auth[index].tmdid == xmd.id && request.type == syllabus.auth[index].type)
+                        if (syllabus.auth[index].tmdid == xmd.tmdid && request.type == syllabus.auth[index].type)
                         {
                             flag = true;
                             indx = index;
@@ -243,8 +243,8 @@ namespace TEAMModelOS.Controllers
                     {
                         syllabus.auth[indx] = new SyllabusAuth
                         {
-                            tmdid = xmd.id,
-                            tmdname = xmd.name,
+                            tmdid = xmd.tmdid,
+                            tmdname = xmd.tmdname,
                             type = request.type,
                             agree = request.agree,
                         };
@@ -254,8 +254,8 @@ namespace TEAMModelOS.Controllers
                     {
                         syllabus.auth.Add(new SyllabusAuth
                         {
-                            tmdid = xmd.id,
-                            tmdname = xmd.name,
+                            tmdid = xmd.tmdid,
+                            tmdname = xmd.tmdname,
                             type = request.type,
                             agree = request.agree,
                         });
@@ -267,8 +267,8 @@ namespace TEAMModelOS.Controllers
                 request.tmdInfo.ForEach(xmd => {
                     syllabus.auth = new List<SyllabusAuth>() {
                         new SyllabusAuth {
-                            tmdid = xmd.id,
-                            tmdname = xmd.name,
+                            tmdid = xmd.tmdid,
+                            tmdname = xmd.tmdname,
                             type = request.type,
                             agree = request.agree,
                         }