Browse Source

update返回名称,头像

CrazyIter_Bin 3 years ago
parent
commit
e232af6643

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

@@ -251,5 +251,6 @@ namespace TEAMModelOS.SDK.Models
         public string id { get; set; }
         public string name { get; set; }
         public string code { get; set; }
+        public string picture { get; set; }
     }
 }

+ 8 - 0
TEAMModelOS.SDK/Models/Cosmos/Common/LessonRecord.cs

@@ -15,6 +15,14 @@ namespace TEAMModelOS.SDK.Models
         /// </summary>
         public string tmdid { get; set; }
         /// <summary>
+        /// 教师醍摩豆id名称
+        /// </summary>
+        public string tmdname { get; set; }
+        /// <summary>
+        /// 教师醍摩豆id名称
+        /// </summary>
+        public string tmdpicture { get; set; }
+        /// <summary>
         ///必填 课堂名称
         /// </summary>
         public string name { get; set; }

+ 18 - 0
TEAMModelOS/Controllers/Common/LessonRecordController.cs

@@ -1,4 +1,5 @@
 using Azure.Cosmos;
+using HTEXLib.COMM.Helpers;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
@@ -198,6 +199,23 @@ namespace TEAMModelOS.Controllers
                         break;
                     }
                 }
+                var tmdids= lessonRecords.Select(x => x.tmdid).ToHashSet();
+                if (tmdids != null && tmdids.Count > 0) {
+                    List< IdNameCode > codes= new List<IdNameCode> ();  
+                    string sqltmd = $"select c.id,c.name,c.picture from c where c.id in ({string.Join(",", tmdids.Select(x => $"'{x}'"))})";
+                    await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).GetItemQueryIterator<IdNameCode>(queryText:sqltmd,requestOptions:new QueryRequestOptions { PartitionKey=new PartitionKey("Base") })){
+                        codes.Add(item);
+                    }
+                    if (codes.IsNotEmpty()) {
+                        lessonRecords.ForEach(x => {
+                            var tmd=  codes.Find(z => z.id.Equals(x.tmdid));
+                            if (tmd != null) {
+                                x.tmdname = tmd.name;
+                                x.tmdpicture= tmd.picture;
+                            }
+                        });
+                    }
+                }
                 return Ok(new { currCount=lessonRecords.Count, continuationToken, lessonRecords });
             } catch (Exception ex) {
                 continuationToken = null;