|
@@ -752,34 +752,14 @@ namespace TEAMModelOS.Controllers
|
|
|
if (_scope.GetString().Equals("school") && _owner.GetString().Equals(school))
|
|
|
{
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).DeleteItemStreamAsync(activity.id, new PartitionKey("Activity"));
|
|
|
- //删除模块,Contest, Training ,Research, ReviewRule规则(ReviewRule-disposable"; 存为活动)
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).DeleteItemStreamAsync(activity.id, new PartitionKey("Contest"));
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).DeleteItemStreamAsync(activity.id, new PartitionKey("Training"));
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).DeleteItemStreamAsync(activity.id, new PartitionKey("Research"));
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).DeleteItemStreamAsync(activity.id, new PartitionKey("ReviewRule-disposable"));
|
|
|
- //删除邀请教师 ActivityTeacher,
|
|
|
- var resultTeacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher)
|
|
|
- .GetList<IdCode>("select c.id ,c.code from c where c.pk='ActivityEnroll' and c.", $"ActivityTeacher-{activity.id}");
|
|
|
- if (resultTeacher.list.IsNotEmpty())
|
|
|
- {
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).DeleteItemsStreamAsync(resultTeacher.list.Select(z => z.id).ToList(), $"ActivityTeacher-{activity.id}");
|
|
|
- }
|
|
|
- //删除报名数据 ActivityEnroll
|
|
|
- var resultEnroll = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher)
|
|
|
- .GetList<IdCode>("select c.id ,c.code from c where c.pk='ActivityEnroll' and c.", $"ActivityEnroll-{activity.id}");
|
|
|
- if (resultEnroll.list.IsNotEmpty())
|
|
|
- {
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).DeleteItemsStreamAsync(resultEnroll.list.Select(z => z.id).ToList(), $"ActivityEnroll-{activity.id}");
|
|
|
- }
|
|
|
- //删除专家数据 ActivityExpert
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).DeleteItemStreamAsync(activity.id, new PartitionKey("ActivityExpert"));
|
|
|
+ await ActivityService.DeleteActivityRelated(_azureCosmos, activity);
|
|
|
return Ok(new { code = 201, activity }); //删除成功
|
|
|
}
|
|
|
else {
|
|
|
if ((_scope.GetString().Equals("area") || _scope.GetString().Equals("public")) && !_owner.GetString().Equals(school))
|
|
|
{
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).DeleteItemStreamAsync(activity.id, new PartitionKey("Activity"));
|
|
|
-
|
|
|
+ await ActivityService.DeleteActivityRelated(_azureCosmos, activity);
|
|
|
return Ok(new { code = 201, activity });//删除成功
|
|
|
}
|
|
|
}
|
|
@@ -1001,6 +981,30 @@ namespace TEAMModelOS.Controllers
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).DeleteItemStreamAsync(_ruleId.GetString(), new PartitionKey("ReviewRule-template"));
|
|
|
return Ok(new { code = 200 });
|
|
|
}
|
|
|
+
|
|
|
+ case bool when $"{grant_type}".Equals("invite-remove-school", StringComparison.OrdinalIgnoreCase):
|
|
|
+ {
|
|
|
+ if (!request.TryGetProperty("activityId", out JsonElement _activityId)) return BadRequest();
|
|
|
+ if (!request.TryGetProperty("invitedSchools", out JsonElement _invitedSchools)) return BadRequest();
|
|
|
+ Azure.Response response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).ReadItemStreamAsync(_activityId.GetString(), new PartitionKey("Activity"));
|
|
|
+ if (response.Status==200)
|
|
|
+ {
|
|
|
+ List<ActivityInvitedSchool> invitedSchools = _invitedSchools.ToObject<List<ActivityInvitedSchool>>();
|
|
|
+ Activity activity = JsonDocument.Parse(response.Content).RootElement.ToObject<Activity>();
|
|
|
+ foreach (var invitedSchool in invitedSchools)
|
|
|
+ {
|
|
|
+ if (!activity.invitedSchools.Exists(z => z.id.Equals(invitedSchool.id)))
|
|
|
+ {
|
|
|
+ activity.invitedSchools.Add(invitedSchool);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Ok(new { code = 200, activity});
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return Ok(new { code = 1, msg = "活动不存在" });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
//学校确认参加本次活动
|
|
|
case bool when $"{grant_type}".Equals("school-confirm", StringComparison.OrdinalIgnoreCase):
|
|
|
{
|
|
@@ -1684,6 +1688,8 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
//分配评审作品任务-检查
|
|
|
case bool when $"{grant_type}".Equals("allocation-task-check", StringComparison.OrdinalIgnoreCase): {
|
|
|
+ if (!request.TryGetProperty("activityId", out JsonElement _activityId)) return BadRequest();
|
|
|
+
|
|
|
break;
|
|
|
}
|
|
|
//分配评审作品任务-自动
|
|
@@ -2357,7 +2363,8 @@ namespace TEAMModelOS.Controllers
|
|
|
enrollTime= z.contest.enrollTime,
|
|
|
leader= z.contest.leader,
|
|
|
teamName= z.contest.teamName,
|
|
|
- type=z.contest.type
|
|
|
+ type=z.contest.type,
|
|
|
+ enrollInfos= z.contest.enrollInfos
|
|
|
}).ToList();
|
|
|
return Ok(new
|
|
|
{
|
|
@@ -2374,7 +2381,8 @@ namespace TEAMModelOS.Controllers
|
|
|
z.enrollTime,
|
|
|
z.leader,
|
|
|
z.teamName,
|
|
|
- z.type
|
|
|
+ z.type,
|
|
|
+ z.enrollInfos
|
|
|
})
|
|
|
});
|
|
|
}
|
|
@@ -2677,7 +2685,8 @@ namespace TEAMModelOS.Controllers
|
|
|
enrollTime= z.contest.enrollTime,
|
|
|
leader= z.contest.leader,
|
|
|
teamName= z.contest.teamName,
|
|
|
- type=z.contest.type
|
|
|
+ type=z.contest.type,
|
|
|
+ enrollInfos= z.contest.enrollInfos,
|
|
|
}).ToList();
|
|
|
}
|
|
|
foreach (var activityTeacher in activityTeachers)
|
|
@@ -2702,7 +2711,7 @@ namespace TEAMModelOS.Controllers
|
|
|
z.enrollTime,
|
|
|
z.leader,
|
|
|
z.teamName,
|
|
|
- z.type
|
|
|
+ z.type,z.enrollInfos
|
|
|
})
|
|
|
});
|
|
|
}
|