|
@@ -24,7 +24,7 @@ namespace TEAMModelOS.Controllers
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
//[Authorize(Roles = "IES5")]
|
|
|
- [Route("group-list")]
|
|
|
+ [Route("grouplist")]
|
|
|
[ApiController]
|
|
|
public class GroupListController : ControllerBase
|
|
|
{
|
|
@@ -46,7 +46,56 @@ namespace TEAMModelOS.Controllers
|
|
|
//处理通用名单
|
|
|
[ProducesDefaultResponseType]
|
|
|
[AuthToken(Roles = "teacher,admin")]
|
|
|
- [HttpPost("upsert-group-list")]
|
|
|
+ [HttpPost("get-grouplists")]
|
|
|
+ public async Task<IActionResult> GetGrouplists(JsonElement json)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ }
|
|
|
+ catch (CosmosException)
|
|
|
+ {
|
|
|
+ }
|
|
|
+ return Ok();
|
|
|
+ }
|
|
|
+ //处理通用名单
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [AuthToken(Roles = "teacher,admin")]
|
|
|
+ [HttpPost("get-grouplist-idcode")]
|
|
|
+ public async Task<IActionResult> GetGrouplistIdcode(JsonElement json) {
|
|
|
+ GroupList groupList = null;
|
|
|
+ try {
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ if (!json.TryGetProperty("code", out JsonElement _code)) return BadRequest();
|
|
|
+ if (!json.TryGetProperty("scope", out JsonElement scope)) return BadRequest();
|
|
|
+ if (!json.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
|
+ string tbname = $"{scope}".Equals("private") ? "Teacher" : "School";
|
|
|
+ string code = "";
|
|
|
+ if ( $"{scope}".Equals("private"))
|
|
|
+ {
|
|
|
+ //私人名单
|
|
|
+ code = "GroupList";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //学校自定义名单
|
|
|
+ code = !code.StartsWith("GroupList-") ? $"GroupList-{code}" : code;
|
|
|
+ }
|
|
|
+ groupList= await client.GetContainer(Constant.TEAMModelOS, tbname).ReadItemAsync<GroupList>($"{id}", new PartitionKey($"{code}"));
|
|
|
+ } catch (CosmosException) {
|
|
|
+ groupList = null;
|
|
|
+ }
|
|
|
+ return Ok(new { groupList });
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 保存或更新通用名单
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="json"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [AuthToken(Roles = "teacher,admin")]
|
|
|
+ [HttpPost("upsert-grouplist")]
|
|
|
public async Task<IActionResult> UpsertGroupList(JsonElement json)
|
|
|
{
|
|
|
try
|
|
@@ -62,8 +111,9 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
GroupList list = _list.ToObject<GroupList>();
|
|
|
if (list != null) {
|
|
|
+ list.ttl = -1;
|
|
|
list.creatorId = userid;
|
|
|
- list.school = school;
|
|
|
+ list.school =string.IsNullOrEmpty(list.school)?school: list.school;
|
|
|
list.pk = "GroupList";
|
|
|
if (list.scope.Equals("private"))
|
|
|
{
|
|
@@ -77,22 +127,27 @@ namespace TEAMModelOS.Controllers
|
|
|
switch (true)
|
|
|
{
|
|
|
//普通学生名单(包含学校教学班名单,个人课程名单),其中学生成员账号类型可以是学校学生账号和醍摩豆ID,分区键为GroupList-hbcn 分区键为GroupList
|
|
|
- case bool when $"{_type}".Equals("student", StringComparison.OrdinalIgnoreCase):
|
|
|
- list.type = "student";
|
|
|
+ case bool when $"{_type}".Equals("teach", StringComparison.OrdinalIgnoreCase):
|
|
|
+ list.type = "teach";
|
|
|
list = await CheckListNo(list);
|
|
|
+ list = await UpsertList(list);
|
|
|
break;
|
|
|
//教研组名单,只有加入学校的老师名单 成员账号类型是醍摩豆ID,保存在学校表,分区键为GroupList-hbcn
|
|
|
case bool when $"{_type}".Equals("research", StringComparison.OrdinalIgnoreCase):
|
|
|
list.type = "research";
|
|
|
+ list.scope = "school";
|
|
|
+ list = await UpsertList(list);
|
|
|
break;
|
|
|
//个人好友名单,成员账号类型可以是学校学生账号和醍摩豆ID,分区键为GroupList
|
|
|
case bool when $"{_type}".Equals("friend", StringComparison.OrdinalIgnoreCase):
|
|
|
list.type = "friend";
|
|
|
+ list = await UpsertList(list);
|
|
|
break;
|
|
|
//社交群组类型(包含学校交流群组,个人交流群组),成员账号类型可以是学校学生账号和醍摩豆ID,,分区键为GroupList-hbcn 分区键为GroupList
|
|
|
case bool when $"{_type}".Equals("group", StringComparison.OrdinalIgnoreCase):
|
|
|
list.type = "group";
|
|
|
list = await CheckListNo(list);
|
|
|
+ list = await UpsertList(list);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -114,7 +169,7 @@ namespace TEAMModelOS.Controllers
|
|
|
string tbname = list.scope.Equals("private") ? "Teacher" : "School";
|
|
|
await client.GetContainer(Constant.TEAMModelOS, tbname).UpsertItemAsync(list, new PartitionKey(list.code));
|
|
|
//学生名单,教研组会触发活动中间表刷新
|
|
|
- if (list.type.Equals("student") || list.type.Equals("research")) {
|
|
|
+ if (list.type.Equals("teach") || list.type.Equals("research")) {
|
|
|
GroupChange change = new GroupChange()
|
|
|
{
|
|
|
type = list.type,
|