Parcourir la source

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

OnePsycho il y a 3 ans
Parent
commit
f92c434fc5

+ 1 - 1
TEAMModelFunction/MonitorServicesBus.cs

@@ -273,7 +273,7 @@ namespace TEAMModelFunction
             var client = _azureCosmos.GetCosmosClient();
             try
             {
-                await _dingDing.SendBotMsg($"ServiceBus,StuList:{msg}", GroupNames.醍摩豆服務運維群組);
+              
                 var jsonMsg = JsonDocument.Parse(msg);
                 StuListChange stuListChange = msg.ToObject<StuListChange>();
                 //名单变动修改学生课程关联信息

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

@@ -178,7 +178,8 @@ namespace TEAMModelFunction
                         scope = course.scope,
                         school = course.school,
                         creatorId = course.creatorId,
-                        pk = "StuCourse"
+                        pk = "StuCourse",
+                        stulist = new List<string> { stuListChange.listid }
                     };
                     await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-StuListService-FixStuCourse\n名单发生变更 新建课程中间表\n{stucourse.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
                     await client.GetContainer("TEAMModelOS", "Student").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
@@ -195,7 +196,8 @@ namespace TEAMModelFunction
                         scope = course.scope,
                         school = course.school,
                         creatorId = course.creatorId,
-                        pk = "StuCourse"
+                        pk = "StuCourse",
+                        stulist= new List<string> { stuListChange .listid}
                     };
                     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));

+ 4 - 0
TEAMModelOS/ClientApp/src/api/courseMgmt.js

@@ -102,4 +102,8 @@ export default {
     delStuList: function (data) {
         return post('/school/course/delete-list', data)
     },
+    // 加入课程
+    joinList: function (data) {
+        return post('/school/course/get-list-by-no', data)
+    },
 }

+ 16 - 47
TEAMModelOS/ClientApp/src/view/joinclass/JoinClass.vue

@@ -26,7 +26,7 @@
                 </p>
             </div>
 
-            <div class="join-btn" @click="findList()">
+            <div class="join-btn" @click="joinList()">
                 {{$t('cusMgt.join.joinBtn')}}
             </div>
         </div>
@@ -36,7 +36,7 @@
                     {{$t('cusMgt.join.title')}}
                 </span>
             </p>
-            <Icon type="md-checkmark-circle-outline" color="#19be6b" size="120"/>
+            <Icon type="md-checkmark-circle-outline" color="#19be6b" size="120" />
             <p class="success-tips">{{$t('cusMgt.join.hasJoin')}}</p>
         </div>
     </div>
@@ -49,7 +49,7 @@ export default {
             isJoin: false,
             tId: '',
             tName: '',
-            listId: '',
+            listNo: '',
             listName: '',
             cusName: '',
             code: '',
@@ -57,52 +57,21 @@ export default {
         }
     },
     methods: {
-        joinList(stulist) {
-            if (stulist) {
-                stulist.tmids.push(this.userId)
-                this.$api.courseMgmt.upsertStulist({
-                    scope: 'private',
-                    stuList: stulist
-                }).then(
-                    res => {
-                        if (!res.error) {
-                            this.$Message.success(this.$t('cusMgt.join.joinOk'))
-                            this.isJoin = true
-                        } else {
-                            this.$Message.error(this.$t('cusMgt.join.joinErr'))
-                        }
-                    },
-                    err => {
-                        this.$Message.error(this.$t('cusMgt.join.joinErr'))
-                    }
-                )
-            } else {
-                this.$Message.error(this.$t('cusMgt.join.getListErr'))
-            }
-        },
-        //查询名单详细信息
-        findList() {
-            let params = {
-                code: this.tId,
-                ids: [this.listId],
-                scope: 'private'
-            }
-            this.$api.courseMgmt.findListSummary(params).then(
+        joinList() {
+            this.$api.courseMgmt.joinList({
+                stuListNo: this.listNo,
+                tmdId: this.userId
+            }).then(
                 res => {
-                    if (!res.error && res.stuList && res.stuList.length) {
-                        if (res.stuList[0].tmids.includes(this.userId)) {
-                            this.isJoin = true
-                        } else if(this.userId){
-                            this.joinList(res.stuList[0])
-                        }else{
-                            this.$Message.error(this.$t('cusMgt.join.getErr'))
-                        }
+                    if (!res.error) {
+                        this.$Message.success(this.$t('cusMgt.join.joinOk'))
+                        this.isJoin = true
                     } else {
-                        this.$Message.error(this.$t('cusMgt.join.getListErr'))
+                        this.$Message.error(this.$t('cusMgt.join.joinErr'))
                     }
                 },
                 err => {
-                    this.$Message.error(this.$t('cusMgt.join.getListErr'))
+                    this.$Message.error(this.$t('cusMgt.join.joinErr'))
                 }
             )
         }
@@ -110,11 +79,11 @@ export default {
     created() {
         this.tId = this.$route.query.tId //教师id
         this.tName = this.$route.query.tName //教师姓名
-        this.listId = this.$route.query.listId   //名单id
+        this.listNo = this.$route.query.listNo   //名单id
         this.listName = this.$route.query.listName //名单
         this.cusName = this.$route.query.cusName  //课程名称
         this.code = this.$route.query.code  //登录成功返回的code
-        if (!this.listId || !this.tId || !this.code) {
+        if (!this.listNo || !this.code) {
             this.$Modal.error({
                 title: this.$t('cusMgt.join.errorTile'),
                 content: this.$t('cusMgt.join.errorContent')
@@ -152,7 +121,7 @@ export default {
 }
 </script>
 <style scoped lang="less">
-.success-tips{
+.success-tips {
     color: white;
     font-size: 16px;
     margin-top: 20px;

+ 1 - 2
TEAMModelOS/ClientApp/src/view/newcourse/MyCourse.vue

@@ -975,7 +975,6 @@ export default {
         showQrCode(index) {
             console.log(this.teaClassList)
             this.showQrStatus = true
-            let tId = this.$store.state.userInfo.TEAMModelId
             let tName = this.$store.state.userInfo.name
             let listId = this.teaClassList[index].stulist
             let listName = this.teaClassList[index].listName
@@ -1013,7 +1012,7 @@ export default {
             let idToken = localStorage.getItem('id_token')
             let tokenData = jwtDecode(idToken)
             let nonce = tokenData ? tokenData.nonce : ''
-            let callbackUrl = `${host}/joinclass?tId=${tId}&listName=${listName}&tName=${tName}&listId=${listId}&cusName=${cusName}`
+            let callbackUrl = `${host}/joinclass?listName=${listName}&tName=${tName}&listNo=${this.stuListNo}&cusName=${cusName}`
             let dcUrl = encodeURIComponent(callbackUrl)
             let loginUrl = `https://account.teammodel.cn?response_type=code&client_id=${clientId}&state=${state}&nonce=${nonce}&redirect_uri=${dcUrl}`
             this.inviteUrl = loginUrl

+ 74 - 0
TEAMModelOS/Controllers/School/CourseController.cs

@@ -238,6 +238,80 @@ namespace TEAMModelOS.Controllers
         }
             
          */
+        /// <summary>
+        /// 扫码加入名单
+        /// </summary>
+        /// <param name="json"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [HttpPost("scan-code-join-list")]
+        public async Task<IActionResult> ScanCodeJoinList(JsonElement json)
+        {
+            try
+            {
+
+                if (!json.TryGetProperty("stuListNo", out JsonElement _stuListNo)) return BadRequest();
+                if (!json.TryGetProperty("userid", out JsonElement _userid)) return BadRequest();
+                json.TryGetProperty("school", out JsonElement _school);
+                string userid = $"{_userid}";
+                string school = $"{_school}";
+                var client = _azureCosmos.GetCosmosClient();
+                var queryNo = $"SELECT  *  FROM c where  c.no ='{_stuListNo}'";
+                StuList stuList = null;
+                json.TryGetProperty("studentId", out JsonElement _studentId);
+                json.TryGetProperty("tmdId", out JsonElement _tmdId);
+                if (!string.IsNullOrEmpty(school))
+                {
+                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: queryNo,
+                          requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList-{school}") }))
+                    {
+                        using var jsonNo = await JsonDocument.ParseAsync(item.ContentStream);
+                        if (jsonNo.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+                        {
+                            var stuDoc = jsonNo.RootElement.GetProperty("Documents").EnumerateArray();
+                            while (stuDoc.MoveNext())
+                            {
+                                JsonElement data = stuDoc.Current;
+                                stuList = data.ToObject<StuList>();
+                                if (stuList != null)
+                                {
+                                    (int status, StuList stuLis) = JoinList(stuList, $"{_studentId}", $"{_tmdId}", school);
+                                    stuLis = await upsertList(stuList, "school");
+                                    return Ok(new { status, stuLis });
+                                }
+                            }
+                        }
+                    }
+                }
+                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: queryNo,
+                    requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList") }))
+                {
+                    using var jsonNo = await JsonDocument.ParseAsync(item.ContentStream);
+                    if (jsonNo.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+                    {
+                        var stuDoc = jsonNo.RootElement.GetProperty("Documents").EnumerateArray();
+                        while (stuDoc.MoveNext())
+                        {
+                            JsonElement data = stuDoc.Current;
+                            stuList = data.ToObject<StuList>();
+                            if (stuList != null)
+                            {
+                                (int status, StuList stuLis) = JoinList(stuList, $"{_studentId}", $"{_tmdId}", school);
+                                stuLis = await upsertList(stuList, "private");
+                                return Ok(new { status, stuLis });
+                            }
+                        }
+                    }
+                }
+                return Ok(new { status = -1 });
+            }
+            catch (Exception ex)
+            {
+                await _dingDing.SendBotMsg($"OS,{_option.Location},course/get-list-by-no()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
+                return BadRequest();
+            }
+        }
+
 
         /// <summary>
         /// 根据邀请码加入名单

+ 4 - 5
TEAMModelOS/TEAMModelOS.csproj

@@ -37,11 +37,10 @@
     <SpaRoot>ClientApp\</SpaRoot>
     <DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
     <UserSecretsId>078b5d89-7d90-4f6a-88fc-7d96025990a8</UserSecretsId>
-    <Version>5.2107.21</Version>
-    <AssemblyVersion>5.2107.21.1</AssemblyVersion>
-    <FileVersion>5.2107.20.3</FileVersion>
-    <Description>1.HiTeach API :掃碼加入學生相關處理
-2.字串檔變更</Description>
+    <Version>5.2107.26</Version>
+    <AssemblyVersion>5.2107.26.1</AssemblyVersion>
+    <FileVersion>5.2107.26.1</FileVersion>
+    <Description>修复学生端扫码加入课程名单,联动触发相关课程和活动。</Description>
     <PackageReleaseNotes>版本说明</PackageReleaseNotes>
   </PropertyGroup>
   <Target Name="DebugEnsureNodeEnv" BeforeTargets="Build">