Browse Source

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

liqk 4 years ago
parent
commit
784a5575a8

+ 2 - 2
Client/Program.cs

@@ -22,8 +22,8 @@ namespace Client
             {
                 var cts = new CancellationTokenSource();
                 var header = new Dictionary<string, string>() { { "X-Auth-Name", "IES5" } };
-                //var sse = new EventSource(new Uri("https://localhost:5001/service/sse"), headeer, 5000);
-                var sse = new EventSource(new Uri("https://api2.teammodel.net/service/sse"), header, 5000);
+                var sse = new EventSource(new Uri("https://localhost:5001/service/sse"), header, 5000);
+                //var sse = new EventSource(new Uri("https://api2.teammodel.net/service/sse"), header, 5000);
 
                 sse.StateChanged += Sse_StateChanged;
                 sse.EventReceived += Sse_EventReceived;

+ 2 - 2
TEAMModelOS/ClientApp/src/common/BaseLayout.less

@@ -56,7 +56,7 @@
 }
 
 .collapsed-logo-width {
-    height: 30px !important;
+    height: 36px !important;
     width: 90px !important;
     transition: width 0.2s, height 0.2s;
 }
@@ -69,7 +69,7 @@
 	margin-left: 20px;
 
     .unit-logo {
-        height: 30px;
+        height: 40px;
     }
 
     .unit-name {

+ 1 - 1
TEAMModelOS/ClientApp/src/common/BaseLayout.vue

@@ -3,7 +3,7 @@
         <!-- 头部菜单栏 -->
         <Header class="header">
             <div class="logo-wrap">
-                <img src="../assets/ies5.png" :class="isCollapsed ? 'collapsed-logo-width unit-logo':'collapsed-logo-width  unit-logo'" v-show="isShowLogo" />
+                <img src="../assets/login/ies5_logo_2.svg" :class="isCollapsed ? 'collapsed-logo-width unit-logo':'collapsed-logo-width  unit-logo'" v-show="isShowLogo" />
             </div>
             <div class="school-wrap">
                 <BaseSelectSchool></BaseSelectSchool>

File diff suppressed because it is too large
+ 751 - 722
TEAMModelOS/ClientApp/src/components/selflearn/NewChooseContent.vue


+ 4 - 2
TEAMModelOS/ClientApp/src/locale/lang/en-US/settings.js

@@ -56,15 +56,17 @@ export default {
 	openStatus: '状态',
 	enable: '启用',
 	disable: '禁用',
-	webhook: "webhook",
+	webhook: "通知接口配置",
+	authorization: "接口密钥",
 	domainName: "域名",
-	subNews: "订阅通知",
+	subNews: "订阅通知接口",
 	apiType1: "数据写入接口",
 	apiType2: "数据读取接口",
 	apiName: '接口名称',
 	apiAddress: '接口地址',
 	apiMethod: '请求方法',
 	apiParams: '参数示例',
+	newName: "通知名称",
 	openKeep: '保存平台',
 	edit: "编辑应用",
 	unedit: '取消编辑',

+ 4 - 2
TEAMModelOS/ClientApp/src/locale/lang/zh-TW/settings.js

@@ -56,15 +56,17 @@ export default {
     openStatus: '狀態',
     enable: '啟用',
     disable: '禁用',
-    webhook: "webhook",
+    webhook: "通知接口配寘",
+    authorization: "接口金鑰",
     domainName: "域名",
-	subNews: "訂閱通知",
+	subNews: "訂閱通知接口",
 	apiType1: "數據寫入接口",
 	apiType2: "數據讀取接口",
     apiName: '接口名稱',
     apiAddress: '接口地址',
     apiMethod: '請求方法',
     apiParams: '參數示例',
+    newName: "通知名稱",
     openKeep: '儲存平臺',
     edit: "編輯應用",
     unedit: '取消編輯',

+ 16 - 13
TEAMModelOS/ClientApp/src/view/syllabus/Syllabus.vue

@@ -220,7 +220,7 @@
 
 		<!-- 关联内容弹窗 -->
 		<Modal v-model="isRelateContentModal" width="900" class="tree-modal add-volume-modal choose-content-modal">
-			<ChooseContent  ref="chooseContentRef" :showSyllabus="false"
+			<ChooseContent v-if="isRelateContentModal" ref="chooseContentRef" :showSyllabus="false"
 				@previewPaper="onPreviewPaper"></ChooseContent>
 			<Button slot="footer" @click="onRelateContent" style="margin-bottom: 20px;" class="modal-btn"
 				:loading="isRelateLoading">{{ $t('syllabus.confirm') }}</Button>
@@ -961,8 +961,11 @@
 					let privateSas = await this.$tools.getPrivateSas()
 					let privateBlobTool = new BlobTool(privateSas.url, privateSas.name, privateSas.sas,
 						'private')
-					let toClient = privateToSchool ? this.containerClient : privateBlobTool
-					let fromClient = privateToSchool ? privateBlobTool : this.containerClient
+					let schoolSas = await this.$tools.getSchoolSas()
+					let schoolBlobTool = new BlobTool(schoolSas.url, schoolSas.name, schoolSas.sas,
+						'school')	
+					let toClient = privateToSchool ? schoolBlobTool : privateBlobTool
+					let fromClient = privateToSchool ? privateBlobTool : schoolBlobTool
 					const itemJsonFile = await this.$evTools.createBlobItem(pItem);
 					let file = new File([JSON.stringify(itemJsonFile)], pItem.id + ".json", {
 						type: "",
@@ -988,7 +991,8 @@
 			/* 获取关联的试题数据 */
 			onSelectQuestion(val) {
 				return new Promise((r, j) => {
-					let list = this.$refs.chooseContentRef.$refs.exListRef.selectItems
+					let exRef = this.$refs.chooseContentRef.$refs.exListRef
+					let list =  exRef ? exRef.selectItems : []
 					console.log('xxxxx', list)
 					if (!list.length) {
 						r(200)
@@ -1007,7 +1011,7 @@
 								pItem.gradeIds = [this.curVolume.gradeId + '']
 								pItem.scope = 'school'
 								pItem.code = this.$store.state.userInfo.schoolCode
-								promiseArr.push(this.saveItemToBlob(pItem, false))
+								promiseArr.push(this.saveItemToBlob(pItem, true))
 							})
 							Promise.all(promiseArr).then(result => {
 								list.forEach(i => {
@@ -1039,7 +1043,7 @@
 								pItem.gradeIds = null
 								pItem.scope = 'private'
 								pItem.code = this.$store.state.userInfo.TEAMModelId
-								promiseArr.push(this.saveItemToBlob(pItem, true))
+								promiseArr.push(this.saveItemToBlob(pItem, false))
 							})
 							Promise.all(promiseArr).then(result => {
 								list.forEach(i => {
@@ -1162,7 +1166,8 @@
 			/* 获取关联的试卷数据 */
 			onSelectPaper() {
 				return new Promise(async (r, j) => {
-					let list = this.$refs.chooseContentRef.$refs.paperListRef.checkedPaperList
+					let paperRef = this.$refs.chooseContentRef.$refs.paperListRef
+					let list =  paperRef ? paperRef.checkedPaperList : []
 					if (!list.length) {
 						r(200)
 					} else {
@@ -1290,12 +1295,10 @@
 				this.isRelateLoading = true
 				Promise.all([this.onSelectFile(), this.onSelectQuestion(), this.onSelectPaper()]).then(result => {
 					console.log(result)
-					setTimeout(() => {
-						this.isRelateLoading = false
-						this.isRelateContentModal = false
-						this.hasModify = true
-						this.modifyIdArr.push(this.curChapter.data.id)
-					}, 500)
+					this.isRelateLoading = false
+					this.isRelateContentModal = false
+					this.hasModify = true
+					this.modifyIdArr.push(this.curChapter.data.id)
 				}).catch(err => {
 					console.log(err)
 					this.isRelateLoading = false

+ 36 - 28
TEAMModelOS/Controllers/Client/HiScanController.cs

@@ -77,7 +77,7 @@ namespace TEAMModelOS.Controllers.Core
             try {
                 if (!request.TryGetProperty("sid", out JsonElement sid)) return BadRequest();
                 if (!request.TryGetProperty("id_token", out JsonElement id_token)) return BadRequest();
-                if (!request.TryGetProperty("dev", out JsonElement dev)) return BadRequest();
+                
                 IServerSentEventsClient sseClient;
                 if (Guid.TryParse($"{sid}", out Guid guid) && (sseClient = _sse.GetClient(guid)) != null) {
                     //var clientName = sseClient.GetProperty<string>("NAME");
@@ -89,9 +89,9 @@ namespace TEAMModelOS.Controllers.Core
                     var id = jwt.Payload.Sub;
                     jwt.Payload.TryGetValue("name", out object name);
                     jwt.Payload.TryGetValue("picture", out object picture);
-                    List<object> schools = new List<object>();
-                    // object schools = null;
-                    string defaultschool = null;
+
+                    List<ScanSchool> schools = new List<ScanSchool>();
+                   
                     //TODO 取得Teacher 個人相關數據(課程清單、虛擬教室清單、歷史紀錄清單等),學校數據另外API處理,多校切換時不同
                     var client = _azureCosmos.GetCosmosClient();
                     var response = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync(id, new PartitionKey("Base"));
@@ -112,39 +112,34 @@ namespace TEAMModelOS.Controllers.Core
                                 //正式加入才会有
                                 if (statusNow == "join")
                                 {
-                                    dynamic schoolExtobj = new ExpandoObject();
+                                    //dynamic schoolExtobj = new ExpandoObject();
                                     var schoolJson = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{obj.GetProperty("schoolId")}", new PartitionKey("Base"));
                                     var school = await JsonDocument.ParseAsync(schoolJson.ContentStream);
-                                    schoolExtobj.schoolId = obj.GetProperty("schoolId");
-                                    schoolExtobj.name = obj.GetProperty("name");
-                                    schoolExtobj.status = obj.GetProperty("status");
-                                    if (obj.TryGetProperty("time", out JsonElement time))
-                                    {
-                                        schoolExtobj.time = obj.GetProperty("time");
+                                    var schoolId = obj.GetProperty("schoolId");
+                                    var schoolName = obj.GetProperty("name");
+                                    var schoolStatus = obj.GetProperty("status");
+                                    var schoolPicture = school.RootElement.GetProperty("picture");
+                                    //检查学校购买的模组是否包含阅卷模组
+                                    int count = 0;
+                                    string sql = $" SELECT value(count(serial))  FROM c join serial in c.serial where c.id ='{schoolId}'  and  c.pk='Product' and serial.prodCode='3222C6D2' ";
+                                    await  foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<int>(sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Product") })) {
+                                        count = item;
                                     }
+                                    if (count > 0) {
+                                        //生成token
+                                        var  token = JwtAuthExtension.CreateAuthToken(_option.HostName, id, name?.ToString(), picture?.ToString(), _option.JwtSecretKey, roles: new[] { "teacher" }, schoolID: $"{schoolId}");
+                                        //获取线下阅卷评测
 
-                                    schoolExtobj.picture = school.RootElement.GetProperty("picture");
-                                    schools.Add(schoolExtobj);
-                                    //如果有申请或者加入学校,但是未分配空间则都可以得到1G免费空间
-                                    if (size == 0)
-                                    {
-                                        size = 1;
-                                        Teacher tech = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Teacher>(id, new PartitionKey("Base"));
-                                        tech.size = size;
-                                        await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(tech, id, new PartitionKey("Base"));
+                                        schools.Add(new ScanSchool { name = $"schoolName", picture = $"{schoolPicture}", code = $"{schoolId}", status = $"{schoolStatus}" ,token=token});
                                     }
                                 }
                             }
                         }
-                        //預設學校ID
-                        if (json.RootElement.TryGetProperty("defaultSchool", out JsonElement valueD) && !string.IsNullOrEmpty(valueD.ToString()))
-                        {
-                            defaultschool = valueD.ToString();
-                        }
+
                         //換取AuthToken,提供給前端
-                        var auth_token = JwtAuthExtension.CreateAuthToken(_option.HostName, id, name?.ToString(), picture?.ToString(), _option.JwtSecretKey, roles: new[] { "teacher" });
-                        await sseClient.SendEventAsync(new { auth_token, schools }.ToJsonString());
-                        return Ok(new { auth_token, schools });
+                        var data = new { name, picture, id, schools };
+                        await sseClient.SendEventAsync(data.ToJsonString());
+                        return Ok(data);
                     }
                     else
                     {
@@ -157,5 +152,18 @@ namespace TEAMModelOS.Controllers.Core
             }
            return Ok();
         }
+        private void GetExam(string schoolId ,string  tmdid)
+        {
+
+
+        }
+    }
+
+    public class ScanSchool { 
+        public string name { get; set; }
+        public string picture { get; set; }
+        public string code { get; set; }
+        public string status { get; set; }
+        public string token { get; set; }
     }
 }

+ 11 - 10
TEAMModelOS/Controllers/Core/BlobController.cs

@@ -593,20 +593,21 @@ namespace TEAMModelOS.Controllers.Core
                 request.TryGetProperty("url", out JsonElement jurl);
                 request.TryGetProperty("opt", out JsonElement opt);
                 request.TryGetProperty("id", out JsonElement id);
-                var url = System.Web.HttpUtility.UrlDecode(jurl.GetString(), Encoding.UTF8);
-                string[] uls = url.Split("/");
-                var u = "";
-                if (uls != null)
-                {
-                     u = !string.IsNullOrEmpty(uls[0]) ? uls[0] : uls[1];
-                    
-                }
-                var size = await _azureStorage.GetBlobContainerClient($"{name}").GetBlobsSize(url);
-                long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+               
                 //获取文件的大小
                 var client = _azureCosmos.GetCosmosClient();
                 if (opt.GetString().Equals("add"))
                 {
+                    var url = System.Web.HttpUtility.UrlDecode(jurl.GetString(), Encoding.UTF8);
+                    string[] uls = url.Split("/");
+                    var u = "";
+                    if (uls != null)
+                    {
+                        u = !string.IsNullOrEmpty(uls[0]) ? uls[0] : uls[1];
+
+                    }
+                    var size = await _azureStorage.GetBlobContainerClient($"{name}").GetBlobsSize(url);
+                    long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                     //地址相同的,直接更新
                     bool exsit = false;
                     try {

+ 9 - 6
TEAMModelOS/Controllers/XTest/TestController.cs

@@ -80,12 +80,15 @@ namespace TEAMModelOS.Controllers.XTest
         [ProducesDefaultResponseType]
         [HttpGet("test-redis")]
         public async Task<IActionResult> TestRedis( ) {
-
-           
-            var db  = _azureRedis.GetRedisClient(8);
-
-          await  db.StringSetAsync("1111", "111111");
-                return Ok() ;
+            var client = _azureCosmos.GetCosmosClient();
+            int count = 0;
+            string sql = $" SELECT value(count(serial))  FROM c join serial in c.serial where c.id ='hbcn'  and  c.pk='Product' and serial.prodCode='3222C6D2' ";
+            await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<int>(sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Product") }))
+            {
+                count = item;
+                break;
+            }
+            return Ok(count) ;
         }
         /// <summary>
         /// 删除