|
@@ -610,9 +610,60 @@ namespace TEAMModelOS.Controllers
|
|
|
case "SaveFileRcd":
|
|
|
//保存线上学习记录
|
|
|
if (!request.TryGetProperty("fileRcd", out JsonElement _fileRcd)) return BadRequest();
|
|
|
- AbilityVideoRcd fileRcd = _fileRcd.ToObject<AbilityVideoRcd>();
|
|
|
-
|
|
|
- return Ok(new { status, abilitySub.videoRcds });
|
|
|
+ TeacherFileRcd fileRcd = _fileRcd.ToObject<TeacherFileRcd>();
|
|
|
+ TeacherFile teacherFile = null;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ teacherFile = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<TeacherFile>($"{_tmdid}", new PartitionKey($"TeacherFile-{_school}"));
|
|
|
+ var file= teacherFile.fileRecords.Find(x => x.hash.Equals(fileRcd.hash));
|
|
|
+ if (file != null)
|
|
|
+ {
|
|
|
+ file.hash = fileRcd.hash;
|
|
|
+ file.view = fileRcd.view;
|
|
|
+ FileAbility ability= file.files.Find(x => x.abilityId.Equals(fileRcd.abilityId) && x.url.Equals(fileRcd.url) && x.taskId.Equals(fileRcd.taskId));
|
|
|
+ if (ability != null)
|
|
|
+ {
|
|
|
+ ability.url = fileRcd.url;
|
|
|
+ ability.abilityId = fileRcd.abilityId;
|
|
|
+ ability.taskId = fileRcd.taskId;
|
|
|
+ ability.nodeId = fileRcd.nodeId;
|
|
|
+ ability.done = fileRcd.done;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ file.files.Add(new FileAbility { url = fileRcd.url, abilityId = fileRcd.abilityId, taskId = fileRcd.taskId, nodeId = fileRcd.nodeId, done = fileRcd.done });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ teacherFile.fileRecords.Add(new FileRecord
|
|
|
+ {
|
|
|
+ hash = fileRcd.hash,
|
|
|
+ size = fileRcd.size,
|
|
|
+ duration = fileRcd.duration,
|
|
|
+ view = fileRcd.view,
|
|
|
+ type = fileRcd.type,
|
|
|
+ files = new List<FileAbility> { new FileAbility { url = fileRcd.url, abilityId = fileRcd.abilityId, taskId = fileRcd.taskId, nodeId = fileRcd.nodeId, done = fileRcd.done } }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<TeacherFile>(teacherFile, teacherFile.id, new PartitionKey($"TeacherFile-{_school}"));
|
|
|
+ }
|
|
|
+ catch (CosmosException)
|
|
|
+ {
|
|
|
+ teacherFile = new TeacherFile
|
|
|
+ {
|
|
|
+ id =$"{_tmdid}",
|
|
|
+ code= $"TeacherFile-{_school}",
|
|
|
+ fileRecords=new List<FileRecord> { new FileRecord {
|
|
|
+ hash= fileRcd.hash,
|
|
|
+ size=fileRcd.size,
|
|
|
+ duration=fileRcd.duration,
|
|
|
+ view=fileRcd.view,
|
|
|
+ type=fileRcd.type,
|
|
|
+ files= new List<FileAbility> { new FileAbility { url=fileRcd.url,abilityId=fileRcd.abilityId,taskId=fileRcd.taskId,nodeId=fileRcd.nodeId,done=fileRcd.done} }
|
|
|
+ } },
|
|
|
+ };
|
|
|
+ await client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync<TeacherFile>(teacherFile, new PartitionKey($"TeacherFile-{_school}"));
|
|
|
+ }
|
|
|
+ return Ok(new { status, teacherFile });
|
|
|
case "ReadSelfVideoRcd":
|
|
|
//获取视频学习记录
|
|
|
return Ok(new { abilitySub.videoRcds });
|