|
@@ -19,6 +19,8 @@ using Azure.Messaging.ServiceBus;
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
using TEAMModelOS.Filter;
|
|
|
using HTEXLib.COMM.Helpers;
|
|
|
+using System.Text;
|
|
|
+
|
|
|
namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
@@ -46,12 +48,61 @@ namespace TEAMModelOS.Controllers
|
|
|
//处理通用名单
|
|
|
[ProducesDefaultResponseType]
|
|
|
[AuthToken(Roles = "teacher,admin")]
|
|
|
+ [HttpPost("get-grouplists-members")]
|
|
|
+ public async Task<IActionResult> GetGrouplistsMembers(JsonElement json)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (!json.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
|
|
|
+ if (!json.TryGetProperty("schoolId", out JsonElement _schoolId)) return BadRequest();
|
|
|
+ if (!json.TryGetProperty("scope", out JsonElement scope)) return BadRequest();
|
|
|
+ if (!json.TryGetProperty("type", out JsonElement type)) return BadRequest();
|
|
|
+ json.TryGetProperty("periodId", out JsonElement periodId);
|
|
|
+ json.TryGetProperty("no", out JsonElement no);
|
|
|
+
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ }
|
|
|
+ catch (CosmosException)
|
|
|
+ {
|
|
|
+ }
|
|
|
+ return Ok();
|
|
|
+ }
|
|
|
+ //处理通用名单
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [AuthToken(Roles = "teacher,admin")]
|
|
|
[HttpPost("get-grouplists")]
|
|
|
public async Task<IActionResult> GetGrouplists(JsonElement json)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
+ if (!json.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
|
|
|
+ if (!json.TryGetProperty("schoolId", out JsonElement _schoolId)) return BadRequest();
|
|
|
+ if (!json.TryGetProperty("scope", out JsonElement scope)) return BadRequest();
|
|
|
+ if (!json.TryGetProperty("type", out JsonElement type)) return BadRequest();
|
|
|
+ json.TryGetProperty("periodId", out JsonElement periodId);
|
|
|
+ json.TryGetProperty("no", out JsonElement no);
|
|
|
+ StringBuilder sql = new StringBuilder($"SELECT distinct c.id,c.code,c.name,c.no,c.periodId,c.scope,c.school,c.creatorId,c.type FROM c where c.type='{type}'");
|
|
|
+ if (!string.IsNullOrEmpty($"{periodId}")) {
|
|
|
+ sql.Append($" and c.periodId='{periodId}'");
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrEmpty($"{no}"))
|
|
|
+ {
|
|
|
+ sql.Append($" and c.no='{no}'");
|
|
|
+ }
|
|
|
+ List<dynamic> groups = new List<dynamic>();
|
|
|
+ string tbname = "Teacher";
|
|
|
+ string code =$"GroupList";
|
|
|
+ if ($"{scope}".Equals("school", StringComparison.OrdinalIgnoreCase)) {
|
|
|
+ tbname = "School";
|
|
|
+ code = $"GroupList-{_schoolId}";
|
|
|
+ }
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, tbname).GetItemQueryIterator<dynamic>(queryText: sql.ToString(),
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
|
|
|
+ {
|
|
|
+ groups.Add(item);
|
|
|
+ }
|
|
|
+ return Ok(new { groups });
|
|
|
}
|
|
|
catch (CosmosException)
|
|
|
{
|