|
@@ -61,7 +61,7 @@ namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- (string id ,_,_,string school ) = HttpContext.GetAuthTokenInfo();
|
|
|
|
|
|
+ (string id, _, _, string school) = HttpContext.GetAuthTokenInfo();
|
|
Course course = new Course();
|
|
Course course = new Course();
|
|
if (!requert.TryGetProperty("course", out JsonElement _course)) return BadRequest();
|
|
if (!requert.TryGetProperty("course", out JsonElement _course)) return BadRequest();
|
|
if (!requert.TryGetProperty("option", out JsonElement option)) return BadRequest();
|
|
if (!requert.TryGetProperty("option", out JsonElement option)) return BadRequest();
|
|
@@ -74,7 +74,8 @@ namespace TEAMModelOS.Controllers
|
|
course.school = school;
|
|
course.school = school;
|
|
course.creatorId = id;
|
|
course.creatorId = id;
|
|
}
|
|
}
|
|
- else {
|
|
|
|
|
|
+ else
|
|
|
|
+ {
|
|
course.creatorId = id;
|
|
course.creatorId = id;
|
|
}
|
|
}
|
|
string code = course.code;
|
|
string code = course.code;
|
|
@@ -229,14 +230,54 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
|
+ [HttpPost("check")]
|
|
|
|
+ public async Task<IActionResult> check(JsonElement json)
|
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ if (!json.TryGetProperty("tId", out JsonElement tId)) return BadRequest();
|
|
|
|
+ if (!json.TryGetProperty("timeId", out JsonElement timeId)) return BadRequest();
|
|
|
|
+ if (!json.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
|
+ var query = $"SELECT A0 FROM c join A0 in c.schedule join A1 in A0.time where A0.teacherId = '{tId}' and A1.id = '{timeId}'";
|
|
|
|
+ List<object> courses = new();
|
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
|
|
|
|
+ {
|
|
|
|
+ using var jsonCheck = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
|
+ if (jsonCheck.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (var obj in jsonCheck.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
+ {
|
|
|
|
+ courses.Add(obj.ToObject<object>());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (courses.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ return Ok(new { status = -1 });
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ return Ok(new { status = 0 });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex)
|
|
|
|
+ {
|
|
|
|
+ await _dingDing.SendBotMsg($"OS,{_option.Location},course/get-list-by-no()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
|
|
|
|
+ return BadRequest();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
/*
|
|
/*
|
|
{
|
|
{
|
|
"stuListNo": "1124582",
|
|
"stuListNo": "1124582",
|
|
"studentId": "19990005",//tmdId/studentId 只能是其中一个有值
|
|
"studentId": "19990005",//tmdId/studentId 只能是其中一个有值
|
|
"tmdId":"1538614518",
|
|
"tmdId":"1538614518",
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
*/
|
|
*/
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 扫码加入名单
|
|
/// 扫码加入名单
|
|
@@ -251,7 +292,7 @@ namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
|
|
|
|
if (!json.TryGetProperty("stuListNo", out JsonElement _stuListNo)) return BadRequest();
|
|
if (!json.TryGetProperty("stuListNo", out JsonElement _stuListNo)) return BadRequest();
|
|
-
|
|
|
|
|
|
+
|
|
json.TryGetProperty("school", out JsonElement _school);
|
|
json.TryGetProperty("school", out JsonElement _school);
|
|
string school = $"{_school}";
|
|
string school = $"{_school}";
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
@@ -259,7 +300,7 @@ namespace TEAMModelOS.Controllers
|
|
StuList stuList = null;
|
|
StuList stuList = null;
|
|
json.TryGetProperty("studentId", out JsonElement _studentId);
|
|
json.TryGetProperty("studentId", out JsonElement _studentId);
|
|
json.TryGetProperty("tmdId", out JsonElement _tmdId);
|
|
json.TryGetProperty("tmdId", out JsonElement _tmdId);
|
|
- if (!string.IsNullOrEmpty(school)&&!string.IsNullOrEmpty($"{_studentId}") )
|
|
|
|
|
|
+ if (!string.IsNullOrEmpty(school) && !string.IsNullOrEmpty($"{_studentId}"))
|
|
{
|
|
{
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: queryNo,
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: queryNo,
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList-{school}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList-{school}") }))
|
|
@@ -320,8 +361,10 @@ namespace TEAMModelOS.Controllers
|
|
[ProducesDefaultResponseType]
|
|
[ProducesDefaultResponseType]
|
|
[AuthToken(Roles = "admin,teacher,student")]
|
|
[AuthToken(Roles = "admin,teacher,student")]
|
|
[HttpPost("get-list-by-no")]
|
|
[HttpPost("get-list-by-no")]
|
|
- public async Task<IActionResult> GetListByNo(JsonElement json) {
|
|
|
|
- try {
|
|
|
|
|
|
+ public async Task<IActionResult> GetListByNo(JsonElement json)
|
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
|
|
if (!json.TryGetProperty("stuListNo", out JsonElement _stuListNo)) return BadRequest();
|
|
if (!json.TryGetProperty("stuListNo", out JsonElement _stuListNo)) return BadRequest();
|
|
var (userid, _, _, school) = HttpContext.GetAuthTokenInfo();
|
|
var (userid, _, _, school) = HttpContext.GetAuthTokenInfo();
|
|
@@ -346,7 +389,7 @@ namespace TEAMModelOS.Controllers
|
|
if (stuList != null)
|
|
if (stuList != null)
|
|
{
|
|
{
|
|
(int status, StuList stuLis) = JoinList(stuList, $"{_studentId}", $"{_tmdId}", school);
|
|
(int status, StuList stuLis) = JoinList(stuList, $"{_studentId}", $"{_tmdId}", school);
|
|
- stuLis=await upsertList(stuList, "school");
|
|
|
|
|
|
+ stuLis = await upsertList(stuList, "school");
|
|
return Ok(new { status, stuLis });
|
|
return Ok(new { status, stuLis });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -373,20 +416,22 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return Ok(new { status= - 1 });
|
|
|
|
- } catch (Exception ex) {
|
|
|
|
|
|
+ return Ok(new { status = -1 });
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex)
|
|
|
|
+ {
|
|
await _dingDing.SendBotMsg($"OS,{_option.Location},course/get-list-by-no()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
|
|
await _dingDing.SendBotMsg($"OS,{_option.Location},course/get-list-by-no()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
|
|
return BadRequest();
|
|
return BadRequest();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public (int status, StuList stuList) JoinList(StuList stuList, string _studentId,string _tmdId,string school)
|
|
|
|
- {
|
|
|
|
|
|
+ public (int status, StuList stuList) JoinList(StuList stuList, string _studentId, string _tmdId, string school)
|
|
|
|
+ {
|
|
int status = -1;
|
|
int status = -1;
|
|
if (string.IsNullOrEmpty($"{_studentId}") && string.IsNullOrEmpty($"{_tmdId}"))
|
|
if (string.IsNullOrEmpty($"{_studentId}") && string.IsNullOrEmpty($"{_tmdId}"))
|
|
{
|
|
{
|
|
//加入学生或醍摩豆ID为空
|
|
//加入学生或醍摩豆ID为空
|
|
- status=1;
|
|
|
|
|
|
+ status = 1;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -397,7 +442,7 @@ namespace TEAMModelOS.Controllers
|
|
if (student != null)
|
|
if (student != null)
|
|
{
|
|
{
|
|
//重复加入
|
|
//重复加入
|
|
- status= 2 ;
|
|
|
|
|
|
+ status = 2;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -421,7 +466,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return (status,stuList);
|
|
|
|
|
|
+ return (status, stuList);
|
|
}
|
|
}
|
|
//处理通用名单
|
|
//处理通用名单
|
|
[ProducesDefaultResponseType]
|
|
[ProducesDefaultResponseType]
|
|
@@ -452,7 +497,7 @@ namespace TEAMModelOS.Controllers
|
|
try
|
|
try
|
|
{
|
|
{
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
-
|
|
|
|
|
|
+
|
|
//todo 需要校验是否重复
|
|
//todo 需要校验是否重复
|
|
if (string.IsNullOrEmpty(stuList.no))
|
|
if (string.IsNullOrEmpty(stuList.no))
|
|
{
|
|
{
|
|
@@ -510,17 +555,17 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- stuList.code = stuList.pk + "-" + stuList.code.Replace("StuList-","");
|
|
|
|
|
|
+ stuList.code = stuList.pk + "-" + stuList.code.Replace("StuList-", "");
|
|
if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
|
|
if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
{
|
|
stuList.scope = "school";
|
|
stuList.scope = "school";
|
|
StuListChange change = new StuListChange()
|
|
StuListChange change = new StuListChange()
|
|
{
|
|
{
|
|
- listid= stuList.id,
|
|
|
|
|
|
+ listid = stuList.id,
|
|
scope = $"{scope}",
|
|
scope = $"{scope}",
|
|
originCode = stuList.school,
|
|
originCode = stuList.school,
|
|
- school=stuList.school,
|
|
|
|
- creatorId=stuList.creatorId
|
|
|
|
|
|
+ school = stuList.school,
|
|
|
|
+ creatorId = stuList.creatorId
|
|
};
|
|
};
|
|
var query = $"SELECT distinct value(c) FROM c where c.id='{stuList.id}'";
|
|
var query = $"SELECT distinct value(c) FROM c where c.id='{stuList.id}'";
|
|
List<StuList> odlStus = new List<StuList>();
|
|
List<StuList> odlStus = new List<StuList>();
|
|
@@ -557,7 +602,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
if (stuList.tmids != null)
|
|
if (stuList.tmids != null)
|
|
{
|
|
{
|
|
- if (odlStus[0].tmids!=null)
|
|
|
|
|
|
+ if (odlStus[0].tmids != null)
|
|
{
|
|
{
|
|
StuList oldStu = odlStus[0];
|
|
StuList oldStu = odlStus[0];
|
|
foreach (var tmdid in stuList.tmids)
|
|
foreach (var tmdid in stuList.tmids)
|
|
@@ -593,7 +638,7 @@ namespace TEAMModelOS.Controllers
|
|
stuList.scope = "private";
|
|
stuList.scope = "private";
|
|
StuListChange change = new StuListChange()
|
|
StuListChange change = new StuListChange()
|
|
{
|
|
{
|
|
- listid= stuList.id,
|
|
|
|
|
|
+ listid = stuList.id,
|
|
scope = $"{scope}",
|
|
scope = $"{scope}",
|
|
originCode = stuList.creatorId,
|
|
originCode = stuList.creatorId,
|
|
school = stuList.school,
|
|
school = stuList.school,
|
|
@@ -609,10 +654,10 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
if (odlStus.Count > 0)
|
|
if (odlStus.Count > 0)
|
|
{
|
|
{
|
|
- if (stuList.students!=null)
|
|
|
|
|
|
+ if (stuList.students != null)
|
|
{
|
|
{
|
|
|
|
|
|
- if (odlStus[0].students!=null)
|
|
|
|
|
|
+ if (odlStus[0].students != null)
|
|
{
|
|
{
|
|
StuList oldStu = odlStus[0];
|
|
StuList oldStu = odlStus[0];
|
|
foreach (var stu in stuList.students)
|
|
foreach (var stu in stuList.students)
|
|
@@ -633,9 +678,9 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (stuList.tmids!=null)
|
|
|
|
|
|
+ if (stuList.tmids != null)
|
|
{
|
|
{
|
|
- if (odlStus[0].tmids!=null)
|
|
|
|
|
|
+ if (odlStus[0].tmids != null)
|
|
{
|
|
{
|
|
StuList oldStu = odlStus[0];
|
|
StuList oldStu = odlStus[0];
|
|
foreach (var tmdid in stuList.tmids)
|
|
foreach (var tmdid in stuList.tmids)
|
|
@@ -655,11 +700,13 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- else {
|
|
|
|
-
|
|
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (change.tmdjoin.Count != 0 || change.tmdhleave.Count != 0 || change.stujoin.Count != 0 || change.stuleave.Count != 0) {
|
|
|
|
|
|
+ if (change.tmdjoin.Count != 0 || change.tmdhleave.Count != 0 || change.stujoin.Count != 0 || change.stuleave.Count != 0)
|
|
|
|
+ {
|
|
var messageChange = new ServiceBusMessage(change.ToJsonString());
|
|
var messageChange = new ServiceBusMessage(change.ToJsonString());
|
|
messageChange.ApplicationProperties.Add("name", "StuList");
|
|
messageChange.ApplicationProperties.Add("name", "StuList");
|
|
var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
|
|
var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
|
|
@@ -1444,7 +1491,7 @@ namespace TEAMModelOS.Controllers
|
|
newCla.id = cla.id;
|
|
newCla.id = cla.id;
|
|
newCla.code = cla.pk + "-" + code;
|
|
newCla.code = cla.pk + "-" + code;
|
|
newCla.name = classSimple.name;
|
|
newCla.name = classSimple.name;
|
|
- // newCla.scope = classSimple.scope;
|
|
|
|
|
|
+ // newCla.scope = classSimple.scope;
|
|
/*foreach (StudentSimple student in cla.students)
|
|
/*foreach (StudentSimple student in cla.students)
|
|
{
|
|
{
|
|
StudentSimple studentSimple = new StudentSimple();
|
|
StudentSimple studentSimple = new StudentSimple();
|