|
@@ -265,7 +265,54 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
return (syllabus, shares);
|
|
|
}
|
|
|
-
|
|
|
+ /// <summary>
|
|
|
+ /// {"code":"教师编码","id":"章节id"}
|
|
|
+ /// 教师删除自己收到的
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("del-share")]
|
|
|
+ // [AuthToken(Roles = "Teacher")]
|
|
|
+ public async Task<IActionResult> DelShare(JsonElement request) {
|
|
|
+ try {
|
|
|
+ if (!request.TryGetProperty("code", out JsonElement code)) { return BadRequest(); }
|
|
|
+ if (!request.TryGetProperty("id", out JsonElement id)) { return BadRequest(); }
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ Share share = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Share>($"{id}", new PartitionKey($"Share-{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.sagree = 0;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ 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) {
|
|
|
+ await _dingDing.SendBotMsg($"OS,{_option.Location},teacher/share/del-share()\n{ex.Message}{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
|
|
|
+ return Ok(new { status = 500 });
|
|
|
+ }
|
|
|
+ }
|
|
|
/// <summary>
|
|
|
/// {"code":"教师编码","id":"章节id","agree":1共编同意,2共编拒绝,3分享同意,4分享拒绝}
|
|
|
/// 教师拉取自己收到的分享及共编
|