|
@@ -15,6 +15,7 @@ using TEAMModelOS.SDK.DI;
|
|
|
using TEAMModelOS.SDK.Extension;
|
|
|
using TEAMModelOS.SDK.Models;
|
|
|
using TEAMModelOS.SDK.Models.Cosmos.Common;
|
|
|
+using TEAMModelOS.SDK.Services;
|
|
|
|
|
|
|
|
|
namespace TEAMModelOS.Controllers
|
|
@@ -386,9 +387,33 @@ namespace TEAMModelOS.Controllers
|
|
|
return Ok(new { datas });
|
|
|
}
|
|
|
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("tec-activity")]
|
|
|
+ [Authorize(Roles = "IES")]
|
|
|
+ [AuthToken(Roles = "student,admin,teacher")]
|
|
|
+ public async Task<IActionResult> TecActivity(JsonElement request)
|
|
|
+ {
|
|
|
+ if (!request.TryGetProperty("type", out JsonElement _type)) return BadRequest();
|
|
|
+ var (id, name, pic, school) = HttpContext.GetAuthTokenInfo();
|
|
|
+ List<StuActivity> datas = new List<StuActivity>();
|
|
|
+ var queryc = $"SELECT value(c) from c where c.school = '{school}' and c.type='{_type}' ";
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<StuActivity>(queryText: queryc, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Activity-{id}") }))
|
|
|
+ {
|
|
|
+ datas.Add(item);
|
|
|
+ /*using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ {
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
+ {
|
|
|
+ courses.Add(obj.ToObject<object>());
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ }
|
|
|
+ //(List<StuActivity> datas, string continuationToken) = await ActivityStudentService.FindActivity(request, id, school, _azureCosmos, _azureRedis);
|
|
|
+ return Ok(new { datas });
|
|
|
+ }
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
/// <summary>
|
|
|
///
|
|
@@ -411,11 +436,11 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
if (role.GetString().Equals("teacher") || role.GetString().Equals("admin"))
|
|
|
{
|
|
|
- // await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemAsync<StuActivity>($"{id}", new PartitionKey($"{code}"));
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemAsync<StuActivity>($"{id}", new PartitionKey($"{code}"));
|
|
|
}
|
|
|
else if (role.GetString().Equals("student"))
|
|
|
{
|
|
|
- //await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemAsync<StuActivity>($"{id}", new PartitionKey($"{code}"));
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemAsync<StuActivity>($"{id}", new PartitionKey($"{code}"));
|
|
|
}
|
|
|
else
|
|
|
{
|