|
@@ -37,88 +37,152 @@ namespace TEAMModelOS.Controllers
|
|
|
|
|
|
/*
|
|
|
{
|
|
|
- "id": "hbcn108774752059002880",
|
|
|
- "code": "Syllabus-hbcn",
|
|
|
- "scope":"school/private",
|
|
|
- "trees": [
|
|
|
- {
|
|
|
- "id": "111111-111-44E7-8DD9-A6CB6D0D52F2",
|
|
|
- "pid": "hbcn108515325535981568",
|
|
|
- "title": "第一章",
|
|
|
- "order": 0,
|
|
|
- "type": tree,
|
|
|
- "rnodes":[
|
|
|
- {
|
|
|
- "type":"item/paper/image/video/pptx.../link"//试题 ,试卷,内容资源,外部链接(只有link,和name)
|
|
|
- "title":"显示名称",
|
|
|
- "id":"关联资源的id",
|
|
|
- "code":"关联资源的code",
|
|
|
- "link":["https;//www.xxx.com/xxx.json"],
|
|
|
- "cntr":"blob的容器名"
|
|
|
- }
|
|
|
- ],
|
|
|
- "children": [
|
|
|
- {
|
|
|
- "id": "22222-111-447E-8A52-BFCD63E61D33",
|
|
|
- "pid": "111111-111-44E7-8DD9-A6CB6D0D52F2",
|
|
|
- "title": "第一节333",
|
|
|
- "order": 0,
|
|
|
- "type": 1,
|
|
|
- "children": [
|
|
|
- {
|
|
|
- "id": "3333-111-447E-8A52-BFCD63E61D33",
|
|
|
- "pid": "22222-111-447E-8A52-BFCD63E61D33",
|
|
|
- "title": "第一节333",
|
|
|
- "order": 0,
|
|
|
- "type": 1
|
|
|
- },
|
|
|
- {
|
|
|
- "id": "4444-111-447E-8A52-BFCD63E61D33",
|
|
|
- "pid": "22222-111-447E-8A52-BFCD63E61D33",
|
|
|
- "title": "第一节333",
|
|
|
- "order": 0,
|
|
|
- "type": 1
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "id": "111111-222-44E7-8DD9-A6CB6D0D52F2",
|
|
|
- "pid": "hbcn108515325535981568",
|
|
|
- "title": "第一章",
|
|
|
- "order": 0,
|
|
|
- "type": 1,
|
|
|
- "children": [
|
|
|
- {
|
|
|
- "id": "22222-222-447E-8A52-BFCD63E61D33",
|
|
|
- "pid": "111111-222-44E7-8DD9-A6CB6D0D52F2",
|
|
|
- "title": "第一节333",
|
|
|
- "order": 0,
|
|
|
- "type": 1,
|
|
|
- "children": [
|
|
|
- {
|
|
|
- "id": "3333-222-447E-8A52-BFCD63E61D33",
|
|
|
- "pid": "22222-222-447E-8A52-BFCD63E61D33",
|
|
|
- "title": "第一节333",
|
|
|
- "order": 0,
|
|
|
- "type": 1
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "id": "5555-222-447E-8A52-BFCD63E61D33",
|
|
|
- "pid": "111111-222-44E7-8DD9-A6CB6D0D52F2",
|
|
|
- "title": "第一节333",
|
|
|
- "order": 0,
|
|
|
- "type": 1,
|
|
|
- "children": []
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- ]
|
|
|
+ "id": "0baf00db-0768-4b62-a8f7-280f6bcebf71",
|
|
|
+ "scope": "school",
|
|
|
+ "trees": [
|
|
|
+ {
|
|
|
+ "children": [
|
|
|
+ {
|
|
|
+ "children": [],
|
|
|
+ "id": "AC4BA269-541B-4DFC-92A5-D773068A6439",
|
|
|
+ "pid": "2dfcc62e-8eea-9881-dc79-384b2f0afbec",
|
|
|
+ "order": 0,
|
|
|
+ "rnodes": [
|
|
|
+ {
|
|
|
+ "type": "doc",
|
|
|
+ "id": "a2bee388-5584-72cc-1d9a-d8a77d255364",
|
|
|
+ "code": "hbcn",
|
|
|
+ "scope": "private",
|
|
|
+ "cntr": "1595321354",
|
|
|
+ "link": [
|
|
|
+ "https://teammodelstorage.blob.core.chinacloudapi.cn/1595321354/doc/2020智慧課堂與智慧教研.pptx"
|
|
|
+ ],
|
|
|
+ "title": "2020智慧課堂與智慧教研.pptx"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "cids": [],
|
|
|
+ "creatorId": null,
|
|
|
+ "updateTime": 0,
|
|
|
+ "title": "1-1 新冠疫情小贴士"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "id": "2dfcc62e-8eea-9881-dc79-384b2f0afbec",
|
|
|
+ "pid": "0baf00db-0768-4b62-a8f7-280f6bcebf71",
|
|
|
+ "order": 0,
|
|
|
+ "rnodes": [
|
|
|
+ {
|
|
|
+ "type": "doc",
|
|
|
+ "id": "cf1b4d21-66e1-e6c7-c944-30a03e419fa6",
|
|
|
+ "code": "hbcn",
|
|
|
+ "scope": "school",
|
|
|
+ "cntr": "hbcn",
|
|
|
+ "link": [
|
|
|
+ "https://teammodelstorage.blob.core.chinacloudapi.cn/hbcn/syllabus/IES5试卷模板制作说明(终).pdf"
|
|
|
+ ],
|
|
|
+ "title": "IES5试卷模板制作说明(终).pdf"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "type": "doc",
|
|
|
+ "id": "f3e82595-7340-a5fe-1004-04538ca09b86",
|
|
|
+ "code": "hbcn",
|
|
|
+ "scope": "school",
|
|
|
+ "cntr": "hbcn",
|
|
|
+ "link": [
|
|
|
+ "https://teammodelstorage.blob.core.chinacloudapi.cn/hbcn/syllabus/111.pdf"
|
|
|
+ ],
|
|
|
+ "title": "111.pdf"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "type": "doc",
|
|
|
+ "id": "e1b31639-dad9-9efb-020b-159dd045f238",
|
|
|
+ "code": "hbcn",
|
|
|
+ "scope": "school",
|
|
|
+ "cntr": "hbcn",
|
|
|
+ "link": [
|
|
|
+ "https://teammodelstorage.blob.core.chinacloudapi.cn/hbcn/doc/6789.pdf"
|
|
|
+ ],
|
|
|
+ "title": "6789.pdf"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "type": "doc",
|
|
|
+ "id": "aaeb4b5c-0450-cb4d-a1ac-244f3d115c4a",
|
|
|
+ "code": "hbcn",
|
|
|
+ "scope": "private",
|
|
|
+ "cntr": "1595321354",
|
|
|
+ "link": [
|
|
|
+ "https://teammodelstorage.blob.core.chinacloudapi.cn/1595321354/doc/422北京培新活动邀请函.pdf"
|
|
|
+ ],
|
|
|
+ "title": "422北京培新活动邀请函.pdf"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "type": "doc",
|
|
|
+ "id": "c5f5838c-5c2f-5e9b-a734-a473cd2cad2e",
|
|
|
+ "code": "hbcn",
|
|
|
+ "scope": "school",
|
|
|
+ "cntr": "hbcn",
|
|
|
+ "link": [
|
|
|
+ "https://teammodelstorage.blob.core.chinacloudapi.cn/hbcn/doc/6666.pdf"
|
|
|
+ ],
|
|
|
+ "title": "6666.pdf"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "type": "doc",
|
|
|
+ "id": "4a106c8e-6831-5f4b-4ec3-3c18f778cab2",
|
|
|
+ "code": "hbcn",
|
|
|
+ "scope": "school",
|
|
|
+ "cntr": "hbcn",
|
|
|
+ "link": [
|
|
|
+ "https://teammodelstorage.blob.core.chinacloudapi.cn/hbcn/doc/6.pdf"
|
|
|
+ ],
|
|
|
+ "title": "6.pdf"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "cids": [
|
|
|
+ "AC4BA269-541B-4DFC-92A5-D773068A6439"
|
|
|
+ ],
|
|
|
+ "creatorId": null,
|
|
|
+ "updateTime": 0,
|
|
|
+ "title": "第一单元 新冠疫情防控"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "children": [
|
|
|
+ {
|
|
|
+ "children": [],
|
|
|
+ "id": "FC5132E1-9723-4875-B3B5-D3DC98D194FA",
|
|
|
+ "pid": "4f12752c-852f-6e90-a3df-1f1f710af23d",
|
|
|
+ "order": 0,
|
|
|
+ "rnodes": [],
|
|
|
+ "cids": [],
|
|
|
+ "creatorId": null,
|
|
|
+ "updateTime": 0,
|
|
|
+ "title": "2-1 全球醍摩豆智慧教育研究院"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "children": [],
|
|
|
+ "id": "3CAD52BE-67B6-4EDB-8EFB-9122960D816A",
|
|
|
+ "pid": "4f12752c-852f-6e90-a3df-1f1f710af23d",
|
|
|
+ "order": 1,
|
|
|
+ "rnodes": [],
|
|
|
+ "cids": [],
|
|
|
+ "creatorId": null,
|
|
|
+ "updateTime": 0,
|
|
|
+ "title": "2-2 醍摩豆研究院课程体系"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "id": "4f12752c-852f-6e90-a3df-1f1f710af23d",
|
|
|
+ "pid": "0baf00db-0768-4b62-a8f7-280f6bcebf71",
|
|
|
+ "order": 1,
|
|
|
+ "rnodes": [],
|
|
|
+ "cids": [
|
|
|
+ "FC5132E1-9723-4875-B3B5-D3DC98D194FA",
|
|
|
+ "3CAD52BE-67B6-4EDB-8EFB-9122960D816A"
|
|
|
+ ],
|
|
|
+ "creatorId": null,
|
|
|
+ "updateTime": 0,
|
|
|
+ "title": "第二单元 醍摩豆手册学习"
|
|
|
}
|
|
|
-
|
|
|
+ ]
|
|
|
+}
|
|
|
*/
|
|
|
|
|
|
/// <summary>
|
|
@@ -131,42 +195,35 @@ namespace TEAMModelOS.Controllers
|
|
|
[HttpPost("upsert-tree")]
|
|
|
public async Task<IActionResult> SaveOrUpdateAsTree(SyllabusTreeNode request)
|
|
|
{
|
|
|
- List<Tnode> nodes = new List<Tnode>();
|
|
|
- Syllabus syllabus = new Syllabus();
|
|
|
- SyllabusService.TreeToList(request.trees, nodes);
|
|
|
- syllabus.children = nodes;
|
|
|
- syllabus.id = !string.IsNullOrEmpty(request.id) ? request.id : Guid.NewGuid().ToString();
|
|
|
- syllabus.code = $"Syllabus-{request.code}";
|
|
|
- syllabus.pk = "Syllabus";
|
|
|
- syllabus.ttl = -1;
|
|
|
- if (request.scope == "school")
|
|
|
- {
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").UpsertItemAsync<Syllabus>(syllabus, new Azure.Cosmos.PartitionKey(syllabus.code));
|
|
|
- }
|
|
|
- else {
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<Syllabus>(syllabus, new Azure.Cosmos.PartitionKey(syllabus.code));
|
|
|
+ List<List<SyllabusTree>> tts = new List<List<SyllabusTree>>();
|
|
|
+ foreach (var tree in request.trees) {
|
|
|
+ Syllabus syllabus = new Syllabus();
|
|
|
+ List<Tnode> nodes = new List<Tnode>();
|
|
|
+ SyllabusService.TreeToList(new List<SyllabusTree> { tree }, nodes);
|
|
|
+ syllabus.children = nodes;
|
|
|
+ syllabus.id = !string.IsNullOrEmpty(tree.id) ? tree.id : Guid.NewGuid().ToString();
|
|
|
+ syllabus.code = $"Syllabus-{request.id}";
|
|
|
+ syllabus.pk = "Syllabus";
|
|
|
+ syllabus.ttl = -1;
|
|
|
+ syllabus.volumeId = request.id;
|
|
|
+ if (request.scope == "school")
|
|
|
+ {
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").UpsertItemAsync<Syllabus>(syllabus, new Azure.Cosmos.PartitionKey($"Syllabus-{request.id}"));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<Syllabus>(syllabus, new Azure.Cosmos.PartitionKey($"Syllabus-{request.id}"));
|
|
|
+ }
|
|
|
+ List<SyllabusTree> trees = SyllabusService.ListToTree(nodes);
|
|
|
+ tts.Add(trees);
|
|
|
}
|
|
|
- List<SyllabusTree> trees = SyllabusService.ListToTree(nodes);
|
|
|
- request.trees = trees;
|
|
|
- return Ok(request);
|
|
|
- }
|
|
|
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 按节点新增课纲
|
|
|
- /// </summary>
|
|
|
- /// <param name="request"></param>
|
|
|
- /// <returns></returns>
|
|
|
- [ProducesDefaultResponseType]
|
|
|
- [HttpPost("upsert-nodes")]
|
|
|
- public async Task<IActionResult> SaveOrUpdateAsNodes(List<Tnode> request)
|
|
|
- {
|
|
|
- return Ok();
|
|
|
- // List<Syllabus> syllabuses = await SaveOrUpdateToNodes(request);
|
|
|
- //if (syllabuses.IsNotEmpty()) return Ok(request);
|
|
|
- //else return Ok(syllabuses);
|
|
|
+ request.trees = new List<SyllabusTree>() ;
|
|
|
+ tts.ForEach(x => request.trees.AddRange(x));
|
|
|
+ return Ok(request);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
|
|
|
/// <summary>
|
|
|
/// 查找课纲
|
|
@@ -178,32 +235,43 @@ namespace TEAMModelOS.Controllers
|
|
|
public async Task<IActionResult> Find(JsonElement request)
|
|
|
{
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
- if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
|
if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
|
if (!request.TryGetProperty("scope", out JsonElement scope)) return BadRequest();
|
|
|
SyllabusTreeNode tree = null;
|
|
|
+ string vcode = null;
|
|
|
+ List<List<SyllabusTree>> tts = new List<List<SyllabusTree>>();
|
|
|
try {
|
|
|
if (scope.ToString().Equals("school"))
|
|
|
{
|
|
|
- Syllabus syllabus = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Syllabus>(id.ToString(), new PartitionKey($"Syllabus-{code}"));
|
|
|
- List<SyllabusTree> trees = SyllabusService.ListToTree(syllabus.children);
|
|
|
- tree = new SyllabusTreeNode() { id = syllabus.id, code = syllabus.code, scope = "school", trees= trees };
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Syllabus>(queryText: $"select value(c) from c ",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Syllabus-{code}") }))
|
|
|
+ {
|
|
|
+ vcode = item.volumeId;
|
|
|
+ List<SyllabusTree> trees = SyllabusService.ListToTree(item.children);
|
|
|
+ tts.Add(trees);
|
|
|
+ }
|
|
|
+ tree = new SyllabusTreeNode() { id = vcode, scope = "school", trees= new List<SyllabusTree>() };
|
|
|
+ tts.ForEach(x => tree.trees.AddRange(x));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- Syllabus syllabus = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Syllabus>(id.ToString(), new PartitionKey($"Syllabus-{code}"));
|
|
|
- List<SyllabusTree> trees = SyllabusService.ListToTree(syllabus.children);
|
|
|
- tree = new SyllabusTreeNode() { id = syllabus.id, code = syllabus.code, scope = "private", trees = trees };
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Syllabus>(queryText: $"select value(c) from c ",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Syllabus-{code}") }))
|
|
|
+ {
|
|
|
+ vcode = item.volumeId;
|
|
|
+ List<SyllabusTree> trees = SyllabusService.ListToTree(item.children);
|
|
|
+ tts.Add(trees);
|
|
|
+ }
|
|
|
+ tree = new SyllabusTreeNode() { id = vcode, scope = "school", trees = new List<SyllabusTree>() };
|
|
|
+ tts.ForEach(x => tree.trees.AddRange(x));
|
|
|
}
|
|
|
-
|
|
|
return Ok(new { tree });
|
|
|
} catch (Exception ex) {
|
|
|
return Ok(new { tree});
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
/// <summary>
|
|
|
- /// 删除课纲
|
|
|
+ /// 删除章节
|
|
|
/// </summary>
|
|
|
/// <param name="request"></param>
|
|
|
/// <returns></returns>
|
|
@@ -217,12 +285,12 @@ namespace TEAMModelOS.Controllers
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
if (scope.ToString().Equals("school"))
|
|
|
{
|
|
|
- var response = await client.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Volume-{code}"));
|
|
|
+ var response = await client.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Syllabus-{code}"));
|
|
|
return Ok(new { code = response.Status });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- var response = await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Volume-{code}"));
|
|
|
+ var response = await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Syllabus-{code}"));
|
|
|
return Ok(new { code = response.Status });
|
|
|
}
|
|
|
}
|