|
@@ -21,6 +21,9 @@ using Microsoft.AspNetCore.Authorization;
|
|
|
using TEAMModelOS.SDK;
|
|
|
using static TEAMModelOS.SDK.ValidatorHelper;
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
+using static SKIT.FlurlHttpClient.Wechat.TenpayV3.Models.CreateApplyForSubjectApplymentRequest.Types;
|
|
|
+using TEAMModelOS.SDK.Models.Service;
|
|
|
+using DocumentFormat.OpenXml.Drawing.Charts;
|
|
|
|
|
|
namespace TEAMModelOS.Controllers
|
|
|
{
|
|
@@ -326,18 +329,40 @@ namespace TEAMModelOS.Controllers
|
|
|
public async Task<IActionResult> Find(JsonElement request)
|
|
|
{
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
- request.TryGetProperty("periodId", out JsonElement periodId);
|
|
|
- if (!request.TryGetProperty("subjectId", out JsonElement subjectId)) return BadRequest();
|
|
|
- if (!request.TryGetProperty("school_code", out JsonElement school_code)) return BadRequest();
|
|
|
- string code = $"Knowledge-{school_code}-{subjectId}";
|
|
|
+ request.TryGetProperty("scope", out JsonElement _scope);
|
|
|
+
|
|
|
+
|
|
|
+ string scope = "school";
|
|
|
+ if (_scope.ValueKind.Equals(JsonValueKind.String))
|
|
|
+ {
|
|
|
+ scope =$"{_scope}";
|
|
|
+ }
|
|
|
StringBuilder sql = new StringBuilder($"select value(c) from c");
|
|
|
- if (periodId.ValueKind.Equals(JsonValueKind.String))
|
|
|
+ string code = "";
|
|
|
+ if (scope.Equals("school"))
|
|
|
{
|
|
|
- sql.Append($" where c.periodId = '{periodId}'");
|
|
|
+ request.TryGetProperty("periodId", out JsonElement periodId);
|
|
|
+ if (!request.TryGetProperty("subjectId", out JsonElement subjectId)) return BadRequest();
|
|
|
+ if (!request.TryGetProperty("school_code", out JsonElement school_code)) return BadRequest();
|
|
|
+ code = $"Knowledge-{school_code}-{subjectId}";
|
|
|
+ if (periodId.ValueKind.Equals(JsonValueKind.String))
|
|
|
+ {
|
|
|
+ sql.Append($" where c.periodId = '{periodId}'");
|
|
|
+ }
|
|
|
}
|
|
|
+ else {
|
|
|
+ if (!request.TryGetProperty("owner", out JsonElement owner)) return BadRequest();
|
|
|
+ request.TryGetProperty("kid", out JsonElement kid);
|
|
|
+ code = $"Knowledge-{owner}";
|
|
|
+ if (kid.ValueKind.Equals(JsonValueKind.String))
|
|
|
+ {
|
|
|
+ sql.Append($" where c.id = '{kid}'");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
List<Knowledge> knowledges = new List<Knowledge>();
|
|
|
List<string> keywords = new List<string>();
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<Knowledge>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, scope.Equals("school")?Constant.School:Constant.Teacher).GetItemQueryIteratorSql<Knowledge>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
|
|
|
{
|
|
|
item.blocks.ForEach(x =>
|
|
|
{
|