|
@@ -238,6 +238,80 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
|
|
|
*/
|
|
|
+ /// <summary>
|
|
|
+ /// 扫码加入名单
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="json"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("scan-code-join-list")]
|
|
|
+ public async Task<IActionResult> ScanCodeJoinList(JsonElement json)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ if (!json.TryGetProperty("stuListNo", out JsonElement _stuListNo)) return BadRequest();
|
|
|
+ if (!json.TryGetProperty("userid", out JsonElement _userid)) return BadRequest();
|
|
|
+ json.TryGetProperty("school", out JsonElement _school);
|
|
|
+ string userid = $"{_userid}";
|
|
|
+ string school = $"{_school}";
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ var queryNo = $"SELECT * FROM c where c.no ='{_stuListNo}'";
|
|
|
+ StuList stuList = null;
|
|
|
+ json.TryGetProperty("studentId", out JsonElement _studentId);
|
|
|
+ json.TryGetProperty("tmdId", out JsonElement _tmdId);
|
|
|
+ if (!string.IsNullOrEmpty(school))
|
|
|
+ {
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: queryNo,
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList-{school}") }))
|
|
|
+ {
|
|
|
+ using var jsonNo = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ if (jsonNo.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ {
|
|
|
+ var stuDoc = jsonNo.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ while (stuDoc.MoveNext())
|
|
|
+ {
|
|
|
+ JsonElement data = stuDoc.Current;
|
|
|
+ stuList = data.ToObject<StuList>();
|
|
|
+ if (stuList != null)
|
|
|
+ {
|
|
|
+ (int status, StuList stuLis) = JoinList(stuList, $"{_studentId}", $"{_tmdId}", school);
|
|
|
+ stuLis = await upsertList(stuList, "school");
|
|
|
+ return Ok(new { status, stuLis });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: queryNo,
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList") }))
|
|
|
+ {
|
|
|
+ using var jsonNo = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ if (jsonNo.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ {
|
|
|
+ var stuDoc = jsonNo.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ while (stuDoc.MoveNext())
|
|
|
+ {
|
|
|
+ JsonElement data = stuDoc.Current;
|
|
|
+ stuList = data.ToObject<StuList>();
|
|
|
+ if (stuList != null)
|
|
|
+ {
|
|
|
+ (int status, StuList stuLis) = JoinList(stuList, $"{_studentId}", $"{_tmdId}", school);
|
|
|
+ stuLis = await upsertList(stuList, "private");
|
|
|
+ return Ok(new { status, stuLis });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Ok(new { status = -1 });
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ await _dingDing.SendBotMsg($"OS,{_option.Location},course/get-list-by-no()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
|
|
|
+ return BadRequest();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据邀请码加入名单
|