|
@@ -63,7 +63,7 @@ namespace TEAMModelAPI.Controllers
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpPost("get-group-list")]
|
|
|
- [ApiToken(Auth = "109", Name = "学校名单列表", RW = "R", Limit = false)]
|
|
|
+ [ApiToken(Auth = "1201", Name = "学校名单列表", RW = "R", Limit = false)]
|
|
|
public async Task<IActionResult> GetGroupList(JsonElement json)
|
|
|
{
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
@@ -157,10 +157,9 @@ namespace TEAMModelAPI.Controllers
|
|
|
groupLists = groupLists.Select(x => new { x.id, x.type, x.name, x.periodId, x.school, x.scope, x.year })
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpPost("get-group-members")]
|
|
|
- [ApiToken(Auth = "110", Name = "获取名单详细信息和成员信息", RW = "R", Limit = false)]
|
|
|
+ [ApiToken(Auth = "1202", Name = "获取名单详细信息和成员信息", RW = "R", Limit = false)]
|
|
|
public async Task<IActionResult> GetGroupMembers(JsonElement json)
|
|
|
{
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
@@ -170,8 +169,6 @@ namespace TEAMModelAPI.Controllers
|
|
|
(List<RMember> members, List<RGroupList> groups) = await GroupListService.GetStutmdidListids(_coreAPIHttpService, client, _dingDing, listids, $"{school}");
|
|
|
return Ok(new { groups = groups.Select(x => new { x.name, x.no, x.periodId, x.school, x.type, x.year, x.tcount, x.scount, x.leader, x.members, x.id }), members });
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 导入行政班学生
|
|
|
/// </summary>
|
|
@@ -179,7 +176,7 @@ namespace TEAMModelAPI.Controllers
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpPost("import-class-members")]
|
|
|
- [ApiToken(Auth = "111", Name = "导入行政班学生", RW = "W", Limit = false)]
|
|
|
+ [ApiToken(Auth = "1203", Name = "导入行政班学生", RW = "W", Limit = false)]
|
|
|
public async Task<IActionResult> ImportClassMembers(JsonElement json)
|
|
|
{
|
|
|
var (id, school) = HttpContext.GetApiTokenInfo();
|
|
@@ -213,7 +210,7 @@ namespace TEAMModelAPI.Controllers
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpPost("update-class-members")]
|
|
|
- [ApiToken(Auth = "112", Name = "更新行政班学生", RW = "W", Limit = false)]
|
|
|
+ [ApiToken(Auth = "1204", Name = "更新行政班学生", RW = "W", Limit = false)]
|
|
|
public async Task<IActionResult> UpdateClassMembers(JsonElement json)
|
|
|
{
|
|
|
var (id, school) = HttpContext.GetApiTokenInfo();
|
|
@@ -249,7 +246,7 @@ namespace TEAMModelAPI.Controllers
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpPost("remove-class-members")]
|
|
|
- [ApiToken(Auth = "113", Name = "移除行政班学生", RW = "W", Limit = false)]
|
|
|
+ [ApiToken(Auth = "1205", Name = "移除行政班学生", RW = "W", Limit = false)]
|
|
|
public async Task<IActionResult> RemoveClassMembers(JsonElement json)
|
|
|
{
|
|
|
var (id, school) = HttpContext.GetApiTokenInfo();
|
|
@@ -291,46 +288,24 @@ namespace TEAMModelAPI.Controllers
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpPost("upsert-teach-group")]
|
|
|
- [ApiToken(Auth = "114", Name = "创建或更新教学班", RW = "W", Limit = false)]
|
|
|
+ [ApiToken(Auth = "1206", Name = "创建或更新教学班", RW = "W", Limit = false)]
|
|
|
public async Task<IActionResult> UpsertTeachGroup(JsonElement json) {
|
|
|
var (id, school) = HttpContext.GetApiTokenInfo();
|
|
|
if (!json.TryGetProperty("groupList", out JsonElement _groupList)) { return Ok(new { error=1,msg="名单对象不存在"}); }
|
|
|
var list= _groupList.ToObject<GroupListDto>();
|
|
|
GroupList groupList = null;
|
|
|
- if (list != null && list.Valid().isVaild) {
|
|
|
- if (string.IsNullOrWhiteSpace(list.id))
|
|
|
+
|
|
|
+ if (list != null && list.Valid().isVaild)
|
|
|
+ {
|
|
|
+ School data = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(school, new PartitionKey("Base"));
|
|
|
+ Period period = data.period.Find(x => x.id.Equals($"{list.periodId}"));
|
|
|
+ if (period != null)
|
|
|
{
|
|
|
- groupList = new GroupList()
|
|
|
+ if (string.IsNullOrWhiteSpace(list.id))
|
|
|
{
|
|
|
- id=Guid.NewGuid ().ToString(),
|
|
|
- code=$"GroupList-{school}",
|
|
|
- name=list.name,
|
|
|
- periodId=list.periodId,
|
|
|
- scope="school",
|
|
|
- school=school,
|
|
|
- type="teach",
|
|
|
- year=list.year,
|
|
|
- froms=3
|
|
|
- };
|
|
|
- groupList = await GroupListService.CheckListNo(groupList, _azureCosmos, _dingDing, _option);
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).CreateItemAsync(groupList,new PartitionKey(groupList.code));
|
|
|
- }
|
|
|
- else {
|
|
|
- Azure.Response response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{list.id}", new PartitionKey($"GroupList-{school}"));
|
|
|
- if (response.Status==200)
|
|
|
- {
|
|
|
- JsonDocument jsonDocument = JsonDocument.Parse(response.Content);
|
|
|
- groupList = jsonDocument.RootElement.ToObject<GroupList>();
|
|
|
- groupList.name=string.IsNullOrWhiteSpace(list.name)?groupList.name: list.name;
|
|
|
- groupList.periodId = string.IsNullOrWhiteSpace(list.periodId) ? groupList.periodId : list.periodId;
|
|
|
- groupList.school=school;
|
|
|
- groupList.scope = "school";
|
|
|
- groupList.froms=3;
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReplaceItemAsync(groupList, groupList.id, new PartitionKey(groupList.code));
|
|
|
- }
|
|
|
- else {
|
|
|
- groupList = new GroupList()
|
|
|
+ groupList = new GroupList()
|
|
|
{
|
|
|
+ pk = "GroupList",
|
|
|
id = Guid.NewGuid().ToString(),
|
|
|
code = $"GroupList-{school}",
|
|
|
name = list.name,
|
|
@@ -344,8 +319,47 @@ namespace TEAMModelAPI.Controllers
|
|
|
groupList = await GroupListService.CheckListNo(groupList, _azureCosmos, _dingDing, _option);
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).CreateItemAsync(groupList, new PartitionKey(groupList.code));
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Azure.Response response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{list.id}", new PartitionKey($"GroupList-{school}"));
|
|
|
+ if (response.Status == 200)
|
|
|
+ {
|
|
|
+ JsonDocument jsonDocument = JsonDocument.Parse(response.Content);
|
|
|
+ groupList = jsonDocument.RootElement.ToObject<GroupList>();
|
|
|
+ groupList.name = string.IsNullOrWhiteSpace(list.name) ? groupList.name : list.name;
|
|
|
+ groupList.periodId = string.IsNullOrWhiteSpace(list.periodId) ? groupList.periodId : list.periodId;
|
|
|
+ groupList.school = school;
|
|
|
+ groupList.scope = "school";
|
|
|
+ groupList.froms = 3;
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReplaceItemAsync(groupList, groupList.id, new PartitionKey(groupList.code));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ groupList = new GroupList()
|
|
|
+ {
|
|
|
+ id = Guid.NewGuid().ToString(),
|
|
|
+ code = $"GroupList-{school}",
|
|
|
+ name = list.name,
|
|
|
+ periodId = list.periodId,
|
|
|
+ scope = "school",
|
|
|
+ school = school,
|
|
|
+ type = "teach",
|
|
|
+ year = list.year,
|
|
|
+ froms = 3
|
|
|
+ };
|
|
|
+ groupList = await GroupListService.CheckListNo(groupList, _azureCosmos, _dingDing, _option);
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).CreateItemAsync(groupList, new PartitionKey(groupList.code));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return Ok(new { error = 2, msg ="学段不存在!" });
|
|
|
}
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return Ok(new { error = 3, msg = list.Valid() });
|
|
|
+ }
|
|
|
return Ok(new { groupList });
|
|
|
}
|
|
|
|
|
@@ -356,7 +370,7 @@ namespace TEAMModelAPI.Controllers
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpPost("import-teach-members")]
|
|
|
- [ApiToken(Auth = "115", Name = "导入教学班学生", RW = "W", Limit = false)]
|
|
|
+ [ApiToken(Auth = "1207", Name = "导入教学班学生", RW = "W", Limit = false)]
|
|
|
public async Task<IActionResult> ImportTeachMembers(JsonElement json)
|
|
|
{
|
|
|
var (id, school) = HttpContext.GetApiTokenInfo();
|
|
@@ -426,7 +440,7 @@ namespace TEAMModelAPI.Controllers
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- return Ok(new { error = valid, msg = "名单列表格式错误!" });
|
|
|
+ return Ok(new { error = 3, msg = valid });
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -442,7 +456,7 @@ namespace TEAMModelAPI.Controllers
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpPost("remove-teach-members")]
|
|
|
- [ApiToken(Auth = "116", Name = "移除教学班学生", RW = "W", Limit = false)]
|
|
|
+ [ApiToken(Auth = "1208", Name = "移除教学班学生", RW = "W", Limit = false)]
|
|
|
public async Task<IActionResult> RemoveTeachMembers(JsonElement json) {
|
|
|
var (id, school) = HttpContext.GetApiTokenInfo();
|
|
|
json.TryGetProperty("stuids", out JsonElement _stuids);
|