|
@@ -6,6 +6,7 @@ using Microsoft.Extensions.Options;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
|
|
+using System.Text;
|
|
using System.Text.Json;
|
|
using System.Text.Json;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
using TEAMModelOS.Filter;
|
|
using TEAMModelOS.Filter;
|
|
@@ -42,15 +43,15 @@ namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
"school": "学校编码",
|
|
"school": "学校编码",
|
|
"scope":"school|private",
|
|
"scope":"school|private",
|
|
- "tmdid":"分享给谁,邀请谁的tmdid",
|
|
|
|
- "name":"分享给谁,邀请谁的name",
|
|
|
|
- "sid":"课纲的id",
|
|
|
|
- "scode":"课纲册别的分区键",
|
|
|
|
- "sname":"课纲分享节点的名称",
|
|
|
|
|
|
+ "tmdInfo":["tmdid":"id1","tmdname":"name1"],
|
|
"coedit":true,
|
|
"coedit":true,
|
|
"share":true,
|
|
"share":true,
|
|
"issuer":"权限颁发者tmdid",
|
|
"issuer":"权限颁发者tmdid",
|
|
- "snodes":["分享的节点 all 或者節點id"]
|
|
|
|
|
|
+ "opt":"add/del/edit"
|
|
|
|
+ "syllabusId":"分享的课纲章节id",
|
|
|
|
+ "syllabusName":"章节名称",
|
|
|
|
+ "volumeId":"册别id",
|
|
|
|
+ "volumeName":"册别name"
|
|
}
|
|
}
|
|
*/
|
|
*/
|
|
|
|
|
|
@@ -70,42 +71,67 @@ namespace TEAMModelOS.Controllers
|
|
//需要判断id== req.issuer 才能进行授权操作
|
|
//需要判断id== req.issuer 才能进行授权操作
|
|
if (request.scope.Equals("school"))
|
|
if (request.scope.Equals("school"))
|
|
{
|
|
{
|
|
- Volume volume = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Volume>(request.sid, new PartitionKey(request.scode));
|
|
|
|
|
|
+ Syllabus syllabusD = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Syllabus>(request.syllabusId, new PartitionKey($"Syllabus-{request.volumeId}"));
|
|
if (request.opt == "del")
|
|
if (request.opt == "del")
|
|
{
|
|
{
|
|
- if (volume.auth.IsNotEmpty())
|
|
|
|
|
|
+ if (syllabusD.auth.IsNotEmpty())
|
|
{
|
|
{
|
|
- var del = volume.auth.Where(x => x.tmdid == request.tmdid).FirstOrDefault();
|
|
|
|
- volume.auth.Remove(del);
|
|
|
|
- await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<Volume>(volume, request.sid, new PartitionKey(request.scode));
|
|
|
|
- await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<Share>(request.sid, new PartitionKey($"Share-{request.tmdid}"));
|
|
|
|
|
|
+ List<SyllabusAuth> syllabusAuths = new List<SyllabusAuth>();
|
|
|
|
+ syllabusD.auth.ForEach(x=> {
|
|
|
|
+ if (request.tmdInfo.Select(tmd=>tmd.tmdid).Contains(x.tmdid)) {
|
|
|
|
+ syllabusAuths.Add(x);
|
|
|
|
+ }
|
|
|
|
+ }) ;
|
|
|
|
+ syllabusAuths.ForEach(x => {
|
|
|
|
+ syllabusD.auth.Remove(x);
|
|
|
|
+ });
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<Syllabus>(syllabusD, request.volumeId, new PartitionKey($"Syllabus-{request.volumeId}"));
|
|
|
|
+ request.tmdInfo.ForEach(async x => {
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<Share>(request.syllabusId, new PartitionKey($"Share-{x.tmdid}"));
|
|
|
|
+ });
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (request.opt.Equals("add") || request.opt.Equals("edit"))
|
|
else if (request.opt.Equals("add") || request.opt.Equals("edit"))
|
|
{
|
|
{
|
|
- (Volume vlm, Share share) = DoAuth(request, volume);
|
|
|
|
- await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<Share>(share, new PartitionKey($"Share-{request.tmdid}"));
|
|
|
|
- await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync<Volume>(volume, new PartitionKey(request.scode));
|
|
|
|
|
|
+ (Syllabus syllabus, List<Share> shares) = DoAuth(request, syllabusD);
|
|
|
|
+ shares.ForEach(async x=> {
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<Share>(x, new PartitionKey($"Share-{x.code}"));
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync<Syllabus>(syllabus, new PartitionKey($"Syllabus-{request.volumeId}"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (request.scope.Equals("private"))
|
|
else if (request.scope.Equals("private"))
|
|
{
|
|
{
|
|
- Volume volume = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Volume>(request.sid, new PartitionKey(request.scode));
|
|
|
|
|
|
+ Syllabus syllabusD = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Syllabus>(request.syllabusId, new PartitionKey($"Syllabus-{request.volumeId}"));
|
|
if (request.opt == "del")
|
|
if (request.opt == "del")
|
|
{
|
|
{
|
|
- if (volume.auth.IsNotEmpty())
|
|
|
|
|
|
+ if (syllabusD.auth.IsNotEmpty())
|
|
{
|
|
{
|
|
- var del = volume.auth.Where(x => x.tmdid == request.tmdid).FirstOrDefault();
|
|
|
|
- volume.auth.Remove(del);
|
|
|
|
- await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Volume>(volume, request.sid, new PartitionKey(request.scode));
|
|
|
|
- await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<Share>(request.sid, new PartitionKey($"Share-{request.tmdid}"));
|
|
|
|
|
|
+ List<SyllabusAuth> syllabusAuths = new List<SyllabusAuth>();
|
|
|
|
+ syllabusD.auth.ForEach(x => {
|
|
|
|
+ if (request.tmdInfo.Select(tmd=>x.tmdid).Contains(x.tmdid))
|
|
|
|
+ {
|
|
|
|
+ syllabusAuths.Add(x);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ syllabusAuths.ForEach(x => {
|
|
|
|
+ syllabusD.auth.Remove(x);
|
|
|
|
+ });
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Syllabus>(syllabusD, request.syllabusId, new PartitionKey($"Syllabus-{request.volumeId}"));
|
|
|
|
+ request.tmdInfo.ForEach(async x => {
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<Share>(request.syllabusId, new PartitionKey($"Share-{x.tmdid}"));
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (request.opt.Equals("add") || request.opt.Equals("edit"))
|
|
else if (request.opt.Equals("add") || request.opt.Equals("edit"))
|
|
{
|
|
{
|
|
- (Volume vlm, Share share) = DoAuth(request, volume);
|
|
|
|
- await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<Share>(share, new PartitionKey($"Share-{request.tmdid}"));
|
|
|
|
- await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<Volume>(volume, new PartitionKey(request.scode));
|
|
|
|
|
|
+ (Syllabus vlm, List<Share> shares) = DoAuth(request, syllabusD);
|
|
|
|
+ shares.ForEach(async x => {
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<Share>(x, new PartitionKey($"Share-{x.code}"));
|
|
|
|
+ });
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<Syllabus>(syllabusD, new PartitionKey($"Syllabus-{request.volumeId}"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Ok(new { code=200});
|
|
return Ok(new { code=200});
|
|
@@ -116,77 +142,89 @@ namespace TEAMModelOS.Controllers
|
|
return Ok(new { code = 500 });
|
|
return Ok(new { code = 500 });
|
|
}
|
|
}
|
|
|
|
|
|
- private (Volume,Share) DoAuth(ShareData request,Volume volume) {
|
|
|
|
|
|
+ private (Syllabus, List<Share>) DoAuth(ShareData request, Syllabus syllabus)
|
|
|
|
+ {
|
|
long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
- var share = new Share
|
|
|
|
- {
|
|
|
|
- id = request.sid,
|
|
|
|
- code = $"Share-{request.tmdid}",
|
|
|
|
- pk = "Share",
|
|
|
|
- ttl = -1,
|
|
|
|
- scode = request.scode,
|
|
|
|
- issuer = request.issuer,
|
|
|
|
- createTime = now,
|
|
|
|
- school = request.school,
|
|
|
|
- scope = request.scope,
|
|
|
|
- coedit=request.coedit,
|
|
|
|
- share=request.share,
|
|
|
|
- sname=request.sname
|
|
|
|
- };
|
|
|
|
- if (volume.auth.IsNotEmpty())
|
|
|
|
- {
|
|
|
|
- bool flag = false;
|
|
|
|
- int indx = 0;
|
|
|
|
- for (int index = 0; index < volume.auth.Count; index++)
|
|
|
|
|
|
+ List<Share> shares = new List<Share>();
|
|
|
|
+ request.tmdInfo.ForEach(xmd => {
|
|
|
|
+ var share = new Share
|
|
{
|
|
{
|
|
- if (volume.auth[index].tmdid == request.tmdid)
|
|
|
|
|
|
+ id = request.syllabusId,
|
|
|
|
+ volumeId = request.volumeId,
|
|
|
|
+ volumeName = request.volumeName,
|
|
|
|
+ syllabusName = request.syllabusName,
|
|
|
|
+ code = $"Share-{xmd.tmdid}",
|
|
|
|
+ pk = "Share",
|
|
|
|
+ ttl = -1,
|
|
|
|
+ issuer = request.issuer,
|
|
|
|
+ createTime = now,
|
|
|
|
+ school = request.school,
|
|
|
|
+ scope = request.scope,
|
|
|
|
+ coedit = request.coedit,
|
|
|
|
+ share = request.share
|
|
|
|
+ };
|
|
|
|
+ shares.Add(share);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ if (syllabus.auth.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ request.tmdInfo.ForEach(xmd => {
|
|
|
|
+
|
|
|
|
+ bool flag = false;
|
|
|
|
+ int indx = 0;
|
|
|
|
+ for (int index = 0; index < syllabus.auth.Count; index++)
|
|
{
|
|
{
|
|
- flag = true;
|
|
|
|
- indx = index;
|
|
|
|
- break;
|
|
|
|
|
|
+ if (syllabus.auth[index].tmdid == xmd.tmdid)
|
|
|
|
+ {
|
|
|
|
+ flag = true;
|
|
|
|
+ indx = index;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- ///更新位置上的授权信息
|
|
|
|
- if (flag)
|
|
|
|
- {
|
|
|
|
- volume.auth[indx] = new SyllabusAuth
|
|
|
|
|
|
+ ///更新位置上的授权信息
|
|
|
|
+ if (flag)
|
|
{
|
|
{
|
|
- tmdid = request.tmdid,
|
|
|
|
- name = request.name,
|
|
|
|
- coedit = request.coedit,
|
|
|
|
- share = request.share,
|
|
|
|
- snodes = request.snodes
|
|
|
|
- };
|
|
|
|
- }
|
|
|
|
- //新增
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- volume.auth.Add(new SyllabusAuth
|
|
|
|
|
|
+ syllabus.auth[indx] = new SyllabusAuth
|
|
|
|
+ {
|
|
|
|
+ tmdid = xmd.tmdid,
|
|
|
|
+ tmdname = xmd.tmdname,
|
|
|
|
+ coedit = request.coedit,
|
|
|
|
+ share = request.share,
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+ //新增
|
|
|
|
+ else
|
|
{
|
|
{
|
|
- tmdid = request.tmdid,
|
|
|
|
- name = request.name,
|
|
|
|
- coedit = request.coedit,
|
|
|
|
- share = request.share,
|
|
|
|
- snodes = request.snodes
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
|
|
+ syllabus.auth.Add(new SyllabusAuth
|
|
|
|
+ {
|
|
|
|
+ tmdid = xmd.tmdid,
|
|
|
|
+ tmdname = xmd.tmdname,
|
|
|
|
+ coedit = request.coedit,
|
|
|
|
+ share = request.share,
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- volume.auth = new List<SyllabusAuth>() {
|
|
|
|
- new SyllabusAuth {
|
|
|
|
- tmdid=request.tmdid,
|
|
|
|
- name=request.name,
|
|
|
|
- coedit=request.coedit,
|
|
|
|
- share=request.share,
|
|
|
|
- snodes=request.snodes
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+ request.tmdInfo.ForEach(xmd => {
|
|
|
|
+ syllabus.auth = new List<SyllabusAuth>() {
|
|
|
|
+ new SyllabusAuth {
|
|
|
|
+ tmdid = xmd.tmdid,
|
|
|
|
+ tmdname = xmd.tmdname,
|
|
|
|
+ coedit=request.coedit,
|
|
|
|
+ share=request.share,
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ });
|
|
}
|
|
}
|
|
- return (volume, share);
|
|
|
|
|
|
+ return (syllabus, shares);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// {"code":"教师编码"}
|
|
|
|
|
|
+ /// {"code":"教师编码","type":"coedit/share"}
|
|
/// 教师拉取自己收到的分享及共编
|
|
/// 教师拉取自己收到的分享及共编
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <param name="request"></param>
|
|
@@ -200,14 +238,32 @@ namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
List<Share> shares = new List<Share>();
|
|
List<Share> shares = new List<Share>();
|
|
if (!request.TryGetProperty("code", out JsonElement code)) { return BadRequest(); }
|
|
if (!request.TryGetProperty("code", out JsonElement code)) { return BadRequest(); }
|
|
|
|
+ if (!request.TryGetProperty("type", out JsonElement type)) { return BadRequest(); }
|
|
|
|
+ if (!request.TryGetProperty("id", out JsonElement id)) { return BadRequest(); }
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
-
|
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Share>(queryText: $"select value(c) from c ",
|
|
|
|
|
|
+ StringBuilder queryText = new StringBuilder("select value(c) from c");
|
|
|
|
+ if (type.ValueKind.Equals(JsonValueKind.String) && type.GetString() == "coedit")
|
|
|
|
+ {
|
|
|
|
+ queryText.Append(" where c.coedit=true");
|
|
|
|
+ }
|
|
|
|
+ else if (type.ValueKind.Equals(JsonValueKind.String) && type.GetString() == "share")
|
|
|
|
+ {
|
|
|
|
+ queryText.Append(" where c.share=true");
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ await _dingDing.SendBotMsg($"OS,{_option.Location},teacher/share/find()\n type== coedit|share 参数必选一个", GroupNames.醍摩豆服務運維群組);
|
|
|
|
+ return BadRequest();
|
|
|
|
+ }
|
|
|
|
+ if (id.ValueKind.Equals(JsonValueKind.String) && !string.IsNullOrEmpty(id.GetString())) {
|
|
|
|
+ queryText.Append($" and c.id='{id}'");
|
|
|
|
+ }
|
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Share>(queryText: queryText.ToString(),
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Share-{code}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Share-{code}") }))
|
|
{
|
|
{
|
|
shares.Add(item);
|
|
shares.Add(item);
|
|
}
|
|
}
|
|
- return Ok(new { shares = shares });
|
|
|
|
|
|
+ var sharesGp = shares.GroupBy(x => new {id= x.volumeId ,code=x.scope=="school"?x.school:x.issuer}).Select(y=>new { id=y.Key.id,code=y.Key.code,list=y.ToList()});
|
|
|
|
+ return Ok(new { shares = sharesGp });
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
{
|
|
{
|
|
@@ -216,14 +272,24 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public record ShareView
|
|
|
|
+ {
|
|
|
|
+ public string scope { get; set; }
|
|
|
|
+ // public string code { get; set; }
|
|
|
|
+ public string school { get; set; }
|
|
|
|
+ public string issuer { get; set; }
|
|
|
|
+ public string volumeId { get; set; }
|
|
|
|
+ public List<string> syllabusId { get; set; }
|
|
|
|
+ }
|
|
|
|
+
|
|
/*
|
|
/*
|
|
{
|
|
{
|
|
"scope": "school/private",
|
|
"scope": "school/private",
|
|
"school": "学校编码",
|
|
"school": "学校编码",
|
|
"issuer": "权限颁发者",
|
|
"issuer": "权限颁发者",
|
|
- "id": "分享或共编的id",
|
|
|
|
- "code": "分享或共编的分区键",
|
|
|
|
- "scode": "分享或共编的scode"
|
|
|
|
|
|
+ "volumeId": "册别id",
|
|
|
|
+ "syllabusId": ["id1课纲章节节点id","id2课纲章节节点id"],
|
|
}
|
|
}
|
|
*/
|
|
*/
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -232,90 +298,107 @@ namespace TEAMModelOS.Controllers
|
|
/// <param name="request"></param>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
[ProducesDefaultResponseType]
|
|
[ProducesDefaultResponseType]
|
|
- [HttpPost("view")]
|
|
|
|
|
|
+ [HttpPost("view-share")]
|
|
// [AuthToken(Roles = "Teacher")]
|
|
// [AuthToken(Roles = "Teacher")]
|
|
- public async Task<IActionResult> View(Share request)
|
|
|
|
|
|
+ public async Task<IActionResult> View(ShareView request)
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- //var (id, _, _, school) = HttpContext.GetAuthTokenInfo();
|
|
|
|
- //if (!request.code.Equals($"Share-{id}"))
|
|
|
|
- //{
|
|
|
|
- // return BadRequest();
|
|
|
|
- //}
|
|
|
|
- Syllabus syllabus;
|
|
|
|
|
|
+ List<List<SyllabusTree>> tts = new List<List<SyllabusTree>>();
|
|
Volume volume;
|
|
Volume volume;
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
string code = null;
|
|
string code = null;
|
|
|
|
+ SyllabusTreeNode tree = null;
|
|
|
|
+ List<string> sid = new List<string>();
|
|
|
|
+ request.syllabusId.ForEach(x => { sid.Add($"'{x}'"); });
|
|
|
|
+ var sidSql= string.Join(",", sid);
|
|
if (request.scope == "school")
|
|
if (request.scope == "school")
|
|
{
|
|
{
|
|
code = request.school;
|
|
code = request.school;
|
|
- syllabus = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Syllabus>(request.id, new PartitionKey(request.scode));
|
|
|
|
- volume = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Volume>(request.id, new PartitionKey($"Volume-{code}"));
|
|
|
|
|
|
+ var queryslt = $"SELECT value(c) FROM c where c.id in ({sidSql})";
|
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Syllabus>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Syllabus-{request.volumeId}") }))
|
|
|
|
+ {
|
|
|
|
+ List<SyllabusTree> trees = SyllabusService.ListToTree(item.children);
|
|
|
|
+ tts.Add(trees);
|
|
|
|
+ }
|
|
|
|
+ volume = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Volume>(request.volumeId, new PartitionKey($"Volume-{code}"));
|
|
|
|
+ tree = new SyllabusTreeNode() { id = request.volumeId, scope = "school", trees = new List<SyllabusTree>() };
|
|
}
|
|
}
|
|
else if (request.scope == "private")
|
|
else if (request.scope == "private")
|
|
{
|
|
{
|
|
code = request.issuer;
|
|
code = request.issuer;
|
|
- syllabus = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Syllabus>(request.id, new PartitionKey(request.scode));
|
|
|
|
- volume = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Volume>(request.id, new PartitionKey($"Volume-{code}"));
|
|
|
|
|
|
+ var queryslt = $"SELECT value(c) FROM c ";
|
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Syllabus>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Syllabus-{request.volumeId}") }))
|
|
|
|
+ {
|
|
|
|
+ List<SyllabusTree> trees = SyllabusService.ListToTree(item.children);
|
|
|
|
+ tts.Add(trees);
|
|
|
|
+ }
|
|
|
|
+ volume = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Volume>(request.volumeId, new PartitionKey($"Volume-{code}"));
|
|
|
|
+ tree = new SyllabusTreeNode() { id = request.volumeId, scope = "private", trees = new List<SyllabusTree>() };
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
return BadRequest();
|
|
return BadRequest();
|
|
}
|
|
}
|
|
- bool coedit = false;
|
|
|
|
- bool share = false;
|
|
|
|
- SyllabusTreeNode etree = null;
|
|
|
|
- List<string> snodes = null;
|
|
|
|
- if (volume.auth.IsNotEmpty()) {
|
|
|
|
- foreach (var x in volume.auth) {
|
|
|
|
- if ($"Share-{x.tmdid }" == request.code)
|
|
|
|
- {
|
|
|
|
- coedit = x.coedit;
|
|
|
|
- share = x.share;
|
|
|
|
- snodes = x.snodes;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (coedit)
|
|
|
|
- {
|
|
|
|
- var treechd = SyllabusService.ListToTree(syllabus.children);
|
|
|
|
- etree = new SyllabusTreeNode() {
|
|
|
|
- id = syllabus.id,
|
|
|
|
- trees = treechd
|
|
|
|
- };
|
|
|
|
- }
|
|
|
|
- SyllabusTreeNode stree = new SyllabusTreeNode();
|
|
|
|
- if (share && snodes.IsNotEmpty()) {
|
|
|
|
- stree = new SyllabusTreeNode()
|
|
|
|
- {
|
|
|
|
- id = syllabus.id,
|
|
|
|
- };
|
|
|
|
- snodes.ForEach(x => {
|
|
|
|
- SyllabusTree syllabusTree = null;
|
|
|
|
- foreach (var node in syllabus.children) {
|
|
|
|
- if (node.id == x) {
|
|
|
|
- syllabusTree = new SyllabusTree {
|
|
|
|
- id=node.id,
|
|
|
|
- pid=node.pid,
|
|
|
|
- order=node.order,
|
|
|
|
- rnodes=node.rnodes,
|
|
|
|
- cids=node.cids
|
|
|
|
- };
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- HashSet<Tnode> newNodes = new HashSet<Tnode>();
|
|
|
|
- SyllabusService.GetNewNode(syllabus.children, x, newNodes);
|
|
|
|
- var trees = SyllabusService.ListToTree(newNodes.ToList());
|
|
|
|
- if (syllabusTree != null) {
|
|
|
|
- syllabusTree.children.AddRange(trees);
|
|
|
|
- stree.trees.Add(syllabusTree);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- return Ok(new { coedit, share, etree,stree });
|
|
|
|
|
|
+ //bool coedit = false;
|
|
|
|
+ //bool share = false;
|
|
|
|
+ //SyllabusTreeNode etree = null;
|
|
|
|
+ //if (syllabus.auth.IsNotEmpty())
|
|
|
|
+ //{
|
|
|
|
+ // foreach (var x in syllabus.auth)
|
|
|
|
+ // {
|
|
|
|
+ // if ($"Share-{x.tmdid }" == request.code)
|
|
|
|
+ // {
|
|
|
|
+ // coedit = x.coedit;
|
|
|
|
+ // share = x.share;
|
|
|
|
+ // break;
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
|
|
+ //if (coedit)
|
|
|
|
+ //{
|
|
|
|
+ // var treechd = SyllabusService.ListToTree(syllabus.children);
|
|
|
|
+ // etree = new SyllabusTreeNode() {
|
|
|
|
+ // id = syllabus.id,
|
|
|
|
+ // trees = treechd
|
|
|
|
+ // };
|
|
|
|
+ //}
|
|
|
|
+ //SyllabusTreeNode stree = new SyllabusTreeNode();
|
|
|
|
+ //if (share && snodes.IsNotEmpty())
|
|
|
|
+ //{
|
|
|
|
+ // stree = new SyllabusTreeNode()
|
|
|
|
+ // {
|
|
|
|
+ // id = syllabus.id,
|
|
|
|
+ // };
|
|
|
|
+ // snodes.ForEach(x =>
|
|
|
|
+ // {
|
|
|
|
+ // SyllabusTree syllabusTree = null;
|
|
|
|
+ // foreach (var node in syllabus.children)
|
|
|
|
+ // {
|
|
|
|
+ // if (node.id == x)
|
|
|
|
+ // {
|
|
|
|
+ // syllabusTree = new SyllabusTree
|
|
|
|
+ // {
|
|
|
|
+ // id = node.id,
|
|
|
|
+ // pid = node.pid,
|
|
|
|
+ // order = node.order,
|
|
|
|
+ // rnodes = node.rnodes,
|
|
|
|
+ // cids = node.cids
|
|
|
|
+ // };
|
|
|
|
+ // break;
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // HashSet<Tnode> newNodes = new HashSet<Tnode>();
|
|
|
|
+ // SyllabusService.GetNewNode(syllabus.children, x, newNodes);
|
|
|
|
+ // var trees = SyllabusService.ListToTree(newNodes.ToList());
|
|
|
|
+ // if (syllabusTree != null)
|
|
|
|
+ // {
|
|
|
|
+ // syllabusTree.children.AddRange(trees);
|
|
|
|
+ // stree.trees.Add(syllabusTree);
|
|
|
|
+ // }
|
|
|
|
+ // });
|
|
|
|
+ //}
|
|
|
|
+ return Ok(new { tree });
|
|
}
|
|
}
|
|
catch (Exception ex) {
|
|
catch (Exception ex) {
|
|
await _dingDing.SendBotMsg($"OS,{_option.Location},teacher/share/view()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
|
|
await _dingDing.SendBotMsg($"OS,{_option.Location},teacher/share/view()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
|
|
@@ -337,4 +420,5 @@ namespace TEAMModelOS.Controllers
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|