ソースを参照

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

XW 4 年 前
コミット
466ffb9df6

+ 1 - 1
TEAMModelOS.SDK/DI/AzureStorage/AzureStorageFactory.cs

@@ -156,7 +156,7 @@ namespace TEAMModelOS.SDK.DI
                 BlobContainerSasPermissions blobContainerSasPermissions = BlobContainerSasPermissions.Read;
                 if (isRead)
                 {
-                    blobContainerSasPermissions = BlobContainerSasPermissions.Read;
+                    blobContainerSasPermissions = BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List;
                 }
                 else
                 {

+ 4 - 1
TEAMModelOS/ClientApp/src/locale/lang/en-US/cusMgt.js

@@ -245,6 +245,9 @@ export default {
         listLabel:'名单:',
         joinBtn:'立即加入',
         errorTile:'信息错误',
-        errorContent:'课程名单获取失败,请重新扫码加入!'
+        errorContent:'课程名单获取失败,请重新扫码加入!',
+        joinOk:'加入成功',
+        joinErr:'加入失敗',
+        getListErr:'獲取名單信息失敗'
     }
 }

+ 4 - 1
TEAMModelOS/ClientApp/src/locale/lang/zh-CN/cusMgt.js

@@ -245,6 +245,9 @@ export default {
         listLabel:'名单:',
         joinBtn:'立即加入',
         errorTile:'信息错误',
-        errorContent:'课程名单获取失败,请重新扫码加入!'
+        errorContent:'课程名单获取失败,请重新扫码加入!',
+        joinOk:'加入成功',
+        joinErr:'加入失败',
+        getListErr:'获取名单信息失败'
     }
 }

+ 4 - 1
TEAMModelOS/ClientApp/src/locale/lang/zh-TW/cusMgt.js

@@ -245,6 +245,9 @@ export default {
         listLabel:'名單:',
         joinBtn:'立即加入',
         errorTile:'信息錯誤',
-        errorContent:'課程名單獲取失敗,請重新掃碼加入! '
+        errorContent:'課程名單獲取失敗,請重新掃碼加入! ',
+        joinOk:'加入成功',
+        joinErr:'加入失敗',
+        getListErr:'獲取名單信息失敗'
     }  
 }

+ 48 - 13
TEAMModelOS/ClientApp/src/view/joinclass/JoinClass.vue

@@ -5,9 +5,6 @@
                 <span>
                     {{$t('cusMgt.join.title')}}
                 </span>
-                <!-- <Divider dashed plain class="join-title">
-                    加入课程名单
-                </Divider> -->
             </p>
             <p class="course-name">{{cusName || $t('cusMgt.join.errorInfo')}}</p>
             <div style="width:fit-content;margin: auto;">
@@ -29,7 +26,7 @@
                 </p>
             </div>
 
-            <div class="join-btn" @click="joinList()">
+            <div class="join-btn" @click="findList()">
                 {{$t('cusMgt.join.joinBtn')}}
             </div>
         </div>
@@ -44,11 +41,52 @@ export default {
             listId: '',
             listName: '',
             cusName: '',
+            tmid: ''
         }
     },
     methods: {
-        joinList() {
-            this.$Message.warning('暂未对接API')
+        joinList(stulist) {
+            if (stulist) {
+                stulist.tmids.push(this.tmid)
+                this.$api.courseMgmt.upsertStulist({
+                    scope: 'private',
+                    stuList: stulist
+                }).then(
+                    res => {
+                        if (!res.error) {
+                            this.$Message.success(this.$t('cusMgt.join.joinOk'))
+                        } 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(
+                res => {
+                    if (!res.error && res.stulist && res.stulist.length) {
+                        console.log(res)
+                        this.joinList(res.stulist[0])
+                    } else {
+                        this.$Message.error(this.$t('cusMgt.join.getListErr'))
+                    }
+                },
+                err => {
+                    this.$Message.error(this.$t('cusMgt.join.getListErr'))
+                }
+            )
         }
     },
     created() {
@@ -77,29 +115,26 @@ export default {
     background-image: url("../../assets/image/bak_light.jpg");
 }
 .join-btn {
-    // width: fit-content;
     width: 100%;
     margin: auto;
     margin-top: 60px;
     text-align: center;
     border: 1px solid rgba(25, 190, 107, 0.5);
-    color: rgba(25, 190, 107, 1);
+    // color: rgba(25, 190, 107, 1);
+    color: white;
     padding: 4px 30px;
     border-radius: 5px;
     font-size: 16px;
     letter-spacing: 2px;
     font-weight: 400;
     user-select: none;
-    &:hover {
-        background: rgba(25, 190, 107, 0.5);
-        color: white;
-    }
+    background: rgba(25, 190, 107, 0.5);
 }
 .course-name {
     color: white;
     margin-bottom: 15px;
     font-size: 30px;
-    font-family: cursive;
+    // font-family: cursive;
 }
 .join-main-box {
     max-width: 90%;

+ 13 - 4
TEAMModelOS/ClientApp/src/view/newcourse/MyCourse.vue

@@ -330,6 +330,7 @@ import PersonalPhoto from '@/components/public/personalPhoto/Index.vue'
 import E from '@/utils/wangEditor.js'
 import StudentList from '@/components/coursemgt/StudentList.vue'
 import TeaTable from './TeaTable.vue'
+import jwtDecode from 'jwt-decode'
 export default {
     components: {
         StudentList, PersonalPhoto, TeaTable
@@ -1001,7 +1002,7 @@ export default {
             //这里需要根据站点动态拼接域名
             let addr = this.$store.state.config.srvAdr
             let type = this.$store.state.config.srvAdrType
-            let host
+            let host, clientId
             //国际站
             if (addr == 'Global') {
                 if (type == 'product') {
@@ -1011,6 +1012,7 @@ export default {
                     // 测试站
                     host = this.$store.state.config[addr].domainUrl[1].url
                 }
+                clientId = this.$store.state.config.Global.clientID
             }
             // 大陆站
             else {
@@ -1019,10 +1021,17 @@ export default {
                 } else {
                     host = this.$store.state.config.China.domainUrl[1].url
                 }
+                clientId = this.$store.state.config.China.clientID
             }
-            let url = `${host}/joinclass?tId=${tId}&listName=${listName}&tName=${tName}&listId=${listId}&cusName=${cusName}`
-            console.log(url)
-            this.createQRCode(url)
+            let state = this.$jsFn.getBtwRandom(1000,9999)
+            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 dcUrl = encodeURIComponent(callbackUrl)
+            let loginUrl = `https://account-rc.teammodel.cn?response_type=code&client_id=${clientId}&state=${state}&nonce=${nonce}&redirect_uri=${dcUrl}`
+            console.log(loginUrl)
+            this.createQRCode(loginUrl)
         },
         //确认添加自定义名单
         confirmCreateList() {

+ 26 - 26
TEAMModelOS/ClientApp/src/view/task/mark/MarkCanvas.vue

@@ -588,30 +588,30 @@ export default {
     },
     mounted() {
         let _this = this
-		_this.$nextTick(() => {
-			//创建画布
-			_this.stage = new Konva.Stage({
-			    container: 'container',
-			    id: 'canvas',
-			    width: this.options.width,
-			    height: this.options.height
-			})
-			_this.orgLayer = new Konva.Layer()
-			_this.markLayer = new Konva.Layer()
-			_this.stage.add(_this.orgLayer)
-			_this.stage.add(_this.markLayer)
-			_this.orgLayer.batchDraw()
-			_this.bundleScoll()
-			_this.stage.on('click', (evt) => {
-			    _this.tr.nodes([])
-			})
-			_this.stage.on('mouseover', (evt) => {
-			    let nodes = _this.tr.nodes()
-			    if (_this.mouseStatus == 'resize' && nodes.length == 0) _this.mouseStatus = _this.resizeBefore
-			
-			})
-		}) 
-        
+        _this.$nextTick(() => {
+            //创建画布
+            _this.stage = new Konva.Stage({
+                container: 'container',
+                id: 'canvas',
+                width: this.options.width,
+                height: this.options.height
+            })
+            _this.orgLayer = new Konva.Layer()
+            _this.markLayer = new Konva.Layer()
+            _this.stage.add(_this.orgLayer)
+            _this.stage.add(_this.markLayer)
+            _this.orgLayer.batchDraw()
+            _this.bundleScoll()
+            _this.stage.on('click', (evt) => {
+                _this.tr.nodes([])
+            })
+            _this.stage.on('mouseover', (evt) => {
+                let nodes = _this.tr.nodes()
+                if (_this.mouseStatus == 'resize' && nodes.length == 0) _this.mouseStatus = _this.resizeBefore
+
+            })
+        })
+
 
         this.tr = new Konva.Transformer({
             rotateEnabled: false,
@@ -640,7 +640,7 @@ export default {
         bgImg: {
             handler(n, o) {
                 this.$nextTick(() => {
-                    this.restore()
+                    if (this.stage) this.restore()
                     this.orgLayer.removeChildren()
                     this.markLayer.removeChildren()
                     let imageObj = new Image()
@@ -665,7 +665,7 @@ export default {
                     this.stage.add(this.orgLayer)
                 })
             },
-            immediate: true,
+            // immediate: true,
             deep: true
         },
         drawImgData: {

+ 3 - 3
TEAMModelOS/Controllers/Item/ItemController.cs

@@ -122,12 +122,12 @@ namespace TEAMModelOS.Controllers
                     {
                         if (itemInfo.scope.Equals("private"))
                         {
-                            itemInfo = await client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(itemInfo, new PartitionKey($"{itemInfo.code}"));
+                            itemInfo = await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(itemInfo, new PartitionKey($"{itemInfo.code}"));
                         }
                         else
                         {
-                          // itemInfo.periodId
-                            itemInfo = await client.GetContainer("TEAMModelOS", "School").CreateItemAsync(itemInfo, new PartitionKey($"{itemInfo.code}"));
+                            // itemInfo.periodId
+                            itemInfo = await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync(itemInfo, new PartitionKey($"{itemInfo.code}"));
                             ItemCond itemCond = null;
                             try {
 

+ 2 - 2
TEAMModelOS/Controllers/Pager/PaperController.cs

@@ -230,12 +230,12 @@ namespace TEAMModelOS.Controllers
                     if (paper.scope.Equals("private"))
                     {
                         //paper.JsonRemove("periodId");
-                        paper = await client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(paper, new PartitionKey($"{paper.code}"));
+                        paper = await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(paper, new PartitionKey($"{paper.code}"));
                     }
                     else
                     {
                         //paper.JsonRemove("periodId");
-                        paper = await client.GetContainer("TEAMModelOS", "School").CreateItemAsync(paper, new PartitionKey($"{paper.code}"));
+                        paper = await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync(paper, new PartitionKey($"{paper.code}"));
                     }
                 }
             }

+ 49 - 30
TEAMModelOS/Controllers/Syllabus/ShareController.cs

@@ -260,34 +260,7 @@ namespace TEAMModelOS.Controllers
                 if (!request.TryGetProperty("opt", out JsonElement opt)) { return BadRequest(); }
                 var client = _azureCosmos.GetCosmosClient();
                 Share share = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Share>($"{id}", new PartitionKey($"Share-{type}-{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.type == $"{type}")
-                        {
-                            if ($"{opt}".Equals("ignore"))
-                            {
-                                x.agree = 0;
-                            }
-                            else if ($"{opt}".Equals("ignore")) {
-                                x.agree = 1;
-                            }
-
-                        }
-                    });
-                }
-
-                if ($"{opt}".Equals("ignore"))
+                if ($"{opt}".Equals("agree"))
                 {
                     share.agree = 1;
                     await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Share>(share, $"{id}", new PartitionKey($"Share-{type}-{code}"));
@@ -296,13 +269,53 @@ namespace TEAMModelOS.Controllers
                 {
                     await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<Share>($"{id}", new PartitionKey($"Share-{type}-{code}"));
                 }
+
+                Syllabus syllabus = null;
                 if (share.scope == "school")
                 {
-                    syllabus = await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<Syllabus>(syllabus, $"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
+                    try 
+                    { 
+                        syllabus = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Syllabus>($"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
+                    } catch {
+                        //仅处理差不到数据的情况
+                    }
                 }
                 else if (share.scope == "private")
                 {
-                    syllabus = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Syllabus>(syllabus, $"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
+                    try 
+                    {
+                        syllabus = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Syllabus>($"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
+                    } catch 
+                    {
+                    }
+                }
+                if (syllabus != null) {
+                    if (syllabus.auth.IsNotEmpty())
+                    {
+                        syllabus.auth.ForEach(x =>
+                        {
+                            if (x.tmdid == $"{code}" && x.type == $"{type}")
+                            {
+                                if ($"{opt}".Equals("ignore"))
+                                {
+                                    x.agree = 0;
+                                }
+                                else if ($"{opt}".Equals("ignore"))
+                                {
+                                    x.agree = 1;
+                                }
+
+                            }
+                        });
+                    }
+                    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) {
@@ -310,6 +323,12 @@ namespace TEAMModelOS.Controllers
                 return Ok(new { status = 500 });
             }
         }
+        /// <summary>
+        /// 删除共享记录
+        /// {"id":"章节id","type:"coedit/share","code":"教师tmdid"}
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
         [ProducesDefaultResponseType]
         [HttpPost("del-share")]
         public async Task<IActionResult> DelShare(JsonElement request) {

+ 33 - 0
TEAMModelOS/Controllers/Syllabus/SyllabusController.cs

@@ -240,11 +240,44 @@ namespace TEAMModelOS.Controllers
                 var client = _azureCosmos.GetCosmosClient();
                 if (scope.ToString().Equals("school"))
                 {
+                    Syllabus syllabus = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Syllabus>(id.ToString(), new PartitionKey($"Syllabus-{code}"));
+                    if (syllabus.auth.IsNotEmpty()) {
+                        foreach (var a in syllabus.auth)
+                        {
+                            try
+                            {
+                                Share share = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Share>(syllabus.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
+                                share.agree = -1;
+                                await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Share>(share, syllabus.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
+                            }
+                            catch (Exception ex)
+                            {
+                                ///仅用于处理查不到该数据的问题
+                            }
+                        }
+                    }
                     var response = await client.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Syllabus-{code}"));
                     return Ok(new { code = response.Status });
                 }
                 else
                 {
+                    Syllabus syllabus = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Syllabus>(id.ToString(), new PartitionKey($"Syllabus-{code}"));
+                    if (syllabus.auth.IsNotEmpty())
+                    {
+                        foreach (var a in syllabus.auth)
+                        {
+                            try
+                            {
+                                Share share = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Share>(syllabus.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
+                                share.agree = -1;
+                                await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Share>(share, syllabus.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
+                            }
+                            catch (Exception ex)
+                            {
+                                ///仅用于处理查不到该数据的问题
+                            }
+                        }
+                    }
                     var response = await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Syllabus-{code}"));
                     return Ok(new { code = response.Status });
                 }

+ 51 - 1
TEAMModelOS/Controllers/Syllabus/VolumeController.cs

@@ -61,19 +61,69 @@ namespace TEAMModelOS.Controllers
                 if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
                 if (!request.TryGetProperty("scope", out JsonElement scope)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
+                string sql = "select value(c) from c ";
+                List<Syllabus> syllabus = new List<Syllabus>();
                 if (scope.ToString().Equals("school"))
                 {
                     var response = await client.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Volume-{code}"));
+                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Syllabus>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Syllabus-{id}") })) {
+                        syllabus.Add(item);
+                    }
+                    if (syllabus.IsNotEmpty())
+                    {
+                        foreach (var s in syllabus) {
+                            if (s.auth.IsNotEmpty()) {
+                                foreach (var a in s.auth) {
+                                    try {
+                                        Share share = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Share>(s.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
+                                        share.agree = -1;
+                                        await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Share>(share,s.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
+                                    } catch (Exception ex) {
+                                        ///仅用于处理查不到该数据的问题
+                                    }
+                                }
+                            }
+                        }
+                        var sresponse = await client.GetContainer("TEAMModelOS", "School").DeleteItemsStreamAsync(syllabus.Select(x => x.id).ToList(), $"Syllabus-{id}");
+                    }
                     return Ok(new { code = response.Status });
                 }
                 else
                 {
                     var response = await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Volume-{code}"));
+                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Syllabus>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Syllabus-{id}") }))
+                    {
+                        syllabus.Add(item);
+                    }
+                    if (syllabus.IsNotEmpty())
+                    {
+                        foreach (var s in syllabus)
+                        {
+                            if (s.auth.IsNotEmpty())
+                            {
+                                foreach (var a in s.auth)
+                                {
+                                    try
+                                    {
+                                        Share share = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Share>(s.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
+                                        share.agree = -1;
+                                        await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Share>(share, s.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
+                                    }
+                                    catch (Exception ex)
+                                    {
+                                        ///仅用于处理查不到该数据的问题
+                                    }
+                                }
+                            }
+                        }
+                        var sresponse = await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemsStreamAsync(syllabus.Select(x => x.id).ToList(), $"Syllabus-{id}");
+                    }
                     return Ok(new { code = response.Status });
                 }
             }
-            catch (Exception e)
+            catch (Exception ex)
             {
+                await _dingDing.SendBotMsg($"OS,{_option.Location},VolumeController:Delete\n{ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
                 return BadRequest();
             }
         }