|
@@ -20,6 +20,7 @@ using TEAMModelOS.Services.Common;
|
|
|
using TEAMModelOS.SDK.Models.Cosmos.Common.Inner;
|
|
|
using HTEXLib.COMM.Helpers;
|
|
|
using TEAMModelOS.Filter;
|
|
|
+using System.ComponentModel.DataAnnotations;
|
|
|
|
|
|
namespace TEAMModelOS.Controllers.Research
|
|
|
{
|
|
@@ -52,7 +53,8 @@ namespace TEAMModelOS.Controllers.Research
|
|
|
[AuthToken(Roles = "area")]
|
|
|
public async Task<IActionResult> CheckLink(JsonElement request)
|
|
|
{
|
|
|
- if (!HttpContext.Items.TryGetValue("Standard", out object standard)) return BadRequest();
|
|
|
+ //if (!HttpContext.Items.TryGetValue("Standard", out object standard)) return BadRequest();
|
|
|
+ if (!request.TryGetProperty("standard", out JsonElement standard)) return BadRequest();
|
|
|
if (!request.TryGetProperty("links", out JsonElement _links)) return BadRequest();
|
|
|
//if (!request.TryGetProperty("code", out JsonElement _code)) return BadRequest();
|
|
|
//if (!request.TryGetProperty("scope", out JsonElement _scope)) return BadRequest();
|
|
@@ -109,6 +111,13 @@ namespace TEAMModelOS.Controllers.Research
|
|
|
}
|
|
|
]
|
|
|
*/
|
|
|
+
|
|
|
+ public class UpdateAsTree {
|
|
|
+ public List<AbilityTaskTreeNode> taskTrees { get; set; }
|
|
|
+ [Required(ErrorMessage = "standard 必须设置")]
|
|
|
+ public string standard { get; set; }
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 批量保存或更新课纲
|
|
|
///
|
|
@@ -118,11 +127,12 @@ namespace TEAMModelOS.Controllers.Research
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpPost("upsert-tree")]
|
|
|
[AuthToken(Roles = "area")]
|
|
|
- public async Task<IActionResult> SaveOrUpdateAsTree(List<AbilityTaskTreeNode> request)
|
|
|
+ public async Task<IActionResult> SaveOrUpdateAsTree(UpdateAsTree request)
|
|
|
{
|
|
|
- if (!HttpContext.Items.TryGetValue("Standard", out object standard)) return BadRequest();
|
|
|
+ //if (!HttpContext.Items.TryGetValue("Standard", out object standard)) return BadRequest();
|
|
|
+ //if (!request.TryGetProperty("standard", out JsonElement standard)) return BadRequest();
|
|
|
long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
- foreach (AbilityTaskTreeNode abilityTaskTree in request)
|
|
|
+ foreach (AbilityTaskTreeNode abilityTaskTree in request.taskTrees)
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrEmpty(abilityTaskTree.id))
|
|
@@ -130,7 +140,7 @@ namespace TEAMModelOS.Controllers.Research
|
|
|
AbilityTask abilityTask = null;
|
|
|
try
|
|
|
{
|
|
|
- abilityTask = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReadItemAsync<AbilityTask>(abilityTaskTree.id, new Azure.Cosmos.PartitionKey($"AbilityTask-{standard}"));
|
|
|
+ abilityTask = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReadItemAsync<AbilityTask>(abilityTaskTree.id, new Azure.Cosmos.PartitionKey($"AbilityTask-{request.standard}"));
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
@@ -146,14 +156,14 @@ namespace TEAMModelOS.Controllers.Research
|
|
|
abilityTask = new AbilityTask();
|
|
|
abilityTask.id = abilityTaskTree.id;
|
|
|
abilityTask.children = nodes;
|
|
|
- abilityTask.code = $"AbilityTask-{standard}";
|
|
|
+ abilityTask.code = $"AbilityTask-{request.standard}";
|
|
|
abilityTask.pk = "AbilityTask";
|
|
|
abilityTask.ttl = -1;
|
|
|
abilityTask.abilityId = abilityTaskTree.abilityId;
|
|
|
abilityTask.scope = abilityTaskTree.scope;
|
|
|
- abilityTask.codeval = $"{standard}";
|
|
|
- abilityTask.standard = $"{standard}";
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").CreateItemAsync<AbilityTask>(abilityTask, new Azure.Cosmos.PartitionKey($"AbilityTask-{standard}"));
|
|
|
+ abilityTask.codeval = $"{request.standard}";
|
|
|
+ abilityTask.standard = $"{request.standard}";
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").CreateItemAsync<AbilityTask>(abilityTask, new Azure.Cosmos.PartitionKey($"AbilityTask-{request.standard}"));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -165,7 +175,7 @@ namespace TEAMModelOS.Controllers.Research
|
|
|
AbilityService.TreeToList(abilityTaskTree.trees, nodes, now);
|
|
|
abilityTask.children = nodes;
|
|
|
abilityTaskTree.auth = abilityTask.auth;
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReplaceItemAsync<AbilityTask>(abilityTask, abilityTask.id, new Azure.Cosmos.PartitionKey($"AbilityTask-{standard}"));
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReplaceItemAsync<AbilityTask>(abilityTask, abilityTask.id, new Azure.Cosmos.PartitionKey($"AbilityTask-{request.standard}"));
|
|
|
}
|
|
|
|
|
|
|
|
@@ -183,15 +193,15 @@ namespace TEAMModelOS.Controllers.Research
|
|
|
AbilityTask abilityTask = new AbilityTask
|
|
|
{
|
|
|
id = id,
|
|
|
- code = $"AbilityTask-{standard}",
|
|
|
+ code = $"AbilityTask-{request.standard}",
|
|
|
pk = "AbilityTask",
|
|
|
ttl = -1,
|
|
|
abilityId = abilityTaskTree.abilityId,
|
|
|
children = nodes,
|
|
|
scope = abilityTaskTree.scope,
|
|
|
- codeval= $"{standard}",standard = $"{standard}"
|
|
|
+ codeval= $"{request.standard}",standard = $"{request.standard}"
|
|
|
};
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").CreateItemAsync<AbilityTask>(abilityTask, new Azure.Cosmos.PartitionKey($"AbilityTask-{standard}"));
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").CreateItemAsync<AbilityTask>(abilityTask, new Azure.Cosmos.PartitionKey($"AbilityTask-{request.standard}"));
|
|
|
}
|
|
|
}
|
|
|
return Ok(request);
|
|
@@ -211,7 +221,8 @@ namespace TEAMModelOS.Controllers.Research
|
|
|
[AuthToken(Roles = "teacher,student,admin,area")]
|
|
|
public async Task<IActionResult> Find(JsonElement request)
|
|
|
{
|
|
|
- if (!HttpContext.Items.TryGetValue("Standard", out object standard)) return BadRequest();
|
|
|
+ //if (!HttpContext.Items.TryGetValue("Standard", out object standard)) return BadRequest();
|
|
|
+ if (!request.TryGetProperty("standard", out JsonElement standard)) return BadRequest();
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
if (!request.TryGetProperty("abilityId", out JsonElement abilityId)) return BadRequest();
|
|
|
// if (!request.TryGetProperty("abilityCode", out JsonElement abilityCode)) return BadRequest();
|
|
@@ -287,7 +298,8 @@ namespace TEAMModelOS.Controllers.Research
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- if (!HttpContext.Items.TryGetValue("Standard", out object standard)) return BadRequest();
|
|
|
+ //if (!HttpContext.Items.TryGetValue("Standard", out object standard)) return BadRequest();
|
|
|
+ if (!request.TryGetProperty("standard", out JsonElement standard)) return BadRequest();
|
|
|
if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
|
//if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
|
var client = _azureCosmos.GetCosmosClient();
|