Explorar el Código

调整学生端以醍摩豆登陆,且是以学生身份登入。

CrazyIter_Bin hace 3 años
padre
commit
4dc53eefb5

+ 4 - 4
TEAMModelOS.SDK/Models/Service/StuListService.cs

@@ -116,14 +116,14 @@ namespace TEAMModelFunction
                             classIds = classes
                         }; 
                         await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-StuListService-FixActivity\n名单发生变更 新建活动中间表\n{stucourse.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
-                        await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
+                        await client.GetContainer("TEAMModelOS", "Student").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
                     }
                     foreach (Students students in stuListChange.stuleave)
                     {
                         try
                         {
 
-                            await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<StuActivity>(activity.id, new PartitionKey($"Activity-{students.code.Replace("Base-", "")}-{students.id}"));
+                            await client.GetContainer("TEAMModelOS", "Student").DeleteItemAsync<StuActivity>(activity.id, new PartitionKey($"Activity-{students.code.Replace("Base-", "")}-{students.id}"));
                         }
                         catch (CosmosException ex)
                         {
@@ -135,7 +135,7 @@ namespace TEAMModelFunction
                         try
                         {
 
-                            await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<StuActivity>(activity.id, new PartitionKey($"Activity-{tmdid}"));
+                            await client.GetContainer("TEAMModelOS", "Student").DeleteItemAsync<StuActivity>(activity.id, new PartitionKey($"Activity-{tmdid}"));
                         }
                         catch(CosmosException ex )
                         {
@@ -210,7 +210,7 @@ namespace TEAMModelFunction
                         createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
                     };
                     await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-StuListService-FixStuCourse\n名单发生变更 新建课程中间表\n{stucourse.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
-                    await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
+                    await client.GetContainer("TEAMModelOS", "Student").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
                 }
                 //移除名单的。 在点击相关的课程,再去二次校验是否存在,不存在则再去删除。
                 foreach (var delStu in stuListChange.stuleave)

+ 4 - 4
TEAMModelOS.SDK/Models/Service/TriggerStuActivity.cs

@@ -58,7 +58,7 @@ namespace TEAMModelFunction
                             taskStatus = -1,
                             classIds = classes
                         };
-                        await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
+                        await client.GetContainer("TEAMModelOS", "Student").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
                     }
                 }
                 if (students.IsNotEmpty())
@@ -104,7 +104,7 @@ namespace TEAMModelFunction
                 {
                     foreach (var x in tmdActivities)
                     {
-                        await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(x, new PartitionKey(x.code));
+                        await client.GetContainer("TEAMModelOS", "Student").UpsertItemAsync(x, new PartitionKey(x.code));
                     }
                 }
             } catch (Exception ex) {
@@ -229,7 +229,7 @@ namespace TEAMModelFunction
                     tmdids.ForEach(x => { inids.Add($"'{x}'"); });
                     var insql = string.Join(",", inids);
                     var queryslt = $"SELECT  value(c) FROM c where c.id in ({insql})";
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<TmdInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
+                    await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<TmdInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
                     {
                         infos.Add(item);
                     }
@@ -393,7 +393,7 @@ namespace TEAMModelFunction
                     tmdids.ForEach(x => { inids.Add($"'{x}'"); });
                     var insql = string.Join(",", inids);
                     var queryslt = $"SELECT  value(c) FROM c where c.id in ({insql})";
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<TmdInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
+                    await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<TmdInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
                     {
                         infos.Add(item);
                     }

+ 1 - 1
TEAMModelOS/Controllers/Common/CommonController.cs

@@ -364,7 +364,7 @@ namespace TEAMModelOS.Controllers.Common
                 {
                     if (role.GetString().Equals("teacher") || role.GetString().Equals("admin"))
                     {
-                        await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<StuActivity>($"{id}", new PartitionKey($"{code}"));
+                        await client.GetContainer("TEAMModelOS", "Student").DeleteItemAsync<StuActivity>($"{id}", new PartitionKey($"{code}"));
                     }
                     else if (role.GetString().Equals("student"))
                     {

+ 4 - 5
TEAMModelOS/Controllers/School/CourseController.cs

@@ -355,14 +355,14 @@ namespace TEAMModelOS.Controllers
                     jwt.Payload.TryGetValue("picture", out object picture);
                     try
                     {
-                        Teacher teacher = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Teacher>(id, new PartitionKey("Base"));
+                        TmdUser tmduser = await client.GetContainer("TEAMModelOS", "Student").ReadItemAsync<TmdUser>(id, new PartitionKey("Base"));
                     }
                     catch (CosmosException ex)
                     {
                         if (ex.Status == 404)
                         {
                             //如果沒有,則初始化Teacher基本資料到Cosmos
-                            Teacher teacher = new Teacher
+                            TmdUser tmduser = new TmdUser
                             {
                                 id = id,
                                 pk = "Base",
@@ -370,13 +370,12 @@ namespace TEAMModelOS.Controllers
                                 name = name?.ToString(),
                                 picture = picture?.ToString(),
                                 //创建账号并第一次登录IES5则默认赠送1G
-                                size = 1,
                                 defaultSchool = null,
-                                schools = new List<Teacher.School>(),
+                                schools = new List<TmdUser.School>(),
                             };
                             var container = _azureStorage.GetBlobContainerClient(id);
                             await container.CreateIfNotExistsAsync(PublicAccessType.None); //嘗試創建Teacher私有容器,如存在則不做任何事,保障容器一定存在
-                            teacher = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey("Base"));
+                            tmduser = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student").CreateItemAsync<TmdUser>(tmduser, new PartitionKey("Base"));
                         }
                     }
                     await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: queryNo,

+ 1 - 1
TEAMModelOS/Controllers/School/StudentCommonController.cs

@@ -110,7 +110,7 @@ namespace TEAMModelOS.Controllers
             }
             else
             {
-                containerId = "Teacher";
+                containerId = "Student";
                 PartitionKey = $"StuCourse-{id}";
             }
 

+ 1 - 1
TEAMModelOS/Controllers/School/StudentController.cs

@@ -2013,7 +2013,7 @@ namespace TEAMModelOS.Controllers
                         tmdids.ForEach(x => { inids.Add($"'{x}'"); });
                         var insql = string.Join(",", inids);
                         var queryslt = $"SELECT c.id,c.name,c.picture FROM c where c.id in ({insql})";
-                        await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<TmdInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
+                        await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<TmdInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
                         {
                             tmdinfos.Add(item);
                         }

+ 10 - 8
TEAMModelOS/Controllers/XTest/DataMigrationController.cs

@@ -28,14 +28,16 @@ namespace TEAMModelOS.Controllers
     public class DataMigrationController : ControllerBase
     {
         ///Teacher表
-        ///     复制的数据
-        ///     Base  ==>>Student
-        ///     迁移的数据   StuCourse  ==>> Student
-        ///                  Activity   ==>> Student
-        ///                  AbilitySub ==>> Student
-        ///                  ClassVideo ==>> Student
-        ///                  Debate     ==>> Student
-        ///                  Appraise   ==>> Student
+        ///     
+        ///     复制的数据  
+        ///     Base  ==>>Student   //IES5&教研中心
+        ///     迁移的数据   StuCourse  ==>> Student  //IES5
+        ///                  Activity   ==>> Student  //IES5
+        ///                  
+        ///                  AbilitySub ==>> Student  //IES5  教研中心
+        ///                  ClassVideo ==>> Student  //IES5  教研中心
+        ///                  Debate     ==>> Student  //IES5  教研中心
+        ///                  Appraise   ==>> Student  //IES5  教研中心
         private readonly AzureStorageFactory _azureStorage;
         private readonly AzureRedisFactory _azureRedis;
         private readonly AzureCosmosFactory _azureCosmos;

+ 10 - 10
TEAMModelOS/Services/Common/ActivityStudentService.cs

@@ -154,9 +154,9 @@ namespace TEAMModelOS.Services.Common
                         }
                         else
                         {
-                            StuActivity activity = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<StuActivity>(vote.id, new PartitionKey($"Activity-{userid}"));
+                            StuActivity activity = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student").ReadItemAsync<StuActivity>(vote.id, new PartitionKey($"Activity-{userid}"));
                             activity.taskStatus = taskStatus;
-                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<StuActivity>(activity, vote.id, new PartitionKey($"Activity-{userid}"));
+                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<StuActivity>(activity, vote.id, new PartitionKey($"Activity-{userid}"));
                         }
 
                     }
@@ -164,9 +164,9 @@ namespace TEAMModelOS.Services.Common
                     {
                         if (ex.Status == 404)
                         {
-                            StuActivity activity = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<StuActivity>(vote.id, new PartitionKey($"Activity-{userid}"));
+                            StuActivity activity = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student").ReadItemAsync<StuActivity>(vote.id, new PartitionKey($"Activity-{userid}"));
                             activity.taskStatus = taskStatus;
-                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<StuActivity>(activity, vote.id, new PartitionKey($"Activity-{userid}"));
+                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<StuActivity>(activity, vote.id, new PartitionKey($"Activity-{userid}"));
                         }
 
                     }
@@ -425,7 +425,7 @@ namespace TEAMModelOS.Services.Common
             }
             List<StuActivity> datas = new List<StuActivity>();
             var client = _azureCosmos.GetCosmosClient();
-            string containerId = "";
+            string containerId = "Student";
             string PartitionKey = "";
             if (!string.IsNullOrWhiteSpace(school) && userType.Equals("schoolid"))
             {
@@ -434,7 +434,7 @@ namespace TEAMModelOS.Services.Common
             }
             else
             {
-                containerId = "Teacher";
+                containerId = "Student";
                 PartitionKey = $"Activity-{id}";
             }
             string querySchool = $" SELECT distinct  value c   FROM c   {joinSqlSubjects}  where {stimesql}  {etimesql} and c.pk='Activity'   {typesql}  {andSqlSubjects}  ";
@@ -674,9 +674,9 @@ namespace TEAMModelOS.Services.Common
                         }
                         else
                         {
-                            StuActivity activity = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<StuActivity>(survey.id, new PartitionKey($"Activity-{userid}"));
+                            StuActivity activity = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student").ReadItemAsync<StuActivity>(survey.id, new PartitionKey($"Activity-{userid}"));
                             activity.taskStatus = taskStatus;
-                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<StuActivity>(activity, survey.id, new PartitionKey($"Activity-{userid}"));
+                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<StuActivity>(activity, survey.id, new PartitionKey($"Activity-{userid}"));
                         }
 
                     }
@@ -684,9 +684,9 @@ namespace TEAMModelOS.Services.Common
                     {
                         if (ex.Status == 404)
                         {
-                            StuActivity activity = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<StuActivity>(survey.id, new PartitionKey($"Activity-{userid}"));
+                            StuActivity activity = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student").ReadItemAsync<StuActivity>(survey.id, new PartitionKey($"Activity-{userid}"));
                             activity.taskStatus = taskStatus;
-                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<StuActivity>(activity, survey.id, new PartitionKey($"Activity-{userid}"));
+                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<StuActivity>(activity, survey.id, new PartitionKey($"Activity-{userid}"));
                         }
                     }
                 }