|
@@ -20,6 +20,7 @@ using TEAMModelOS.SDK.Models;
|
|
|
using TEAMModelOS.SDK.Models.Cosmos.Common;
|
|
|
using TEAMModelOS.SDK.Models.Service;
|
|
|
using TEAMModelOS.Services.Common;
|
|
|
+using HTEXLib.COMM.Helpers;
|
|
|
|
|
|
namespace TEAMModelOS.Controllers
|
|
|
{
|
|
@@ -27,6 +28,7 @@ namespace TEAMModelOS.Controllers
|
|
|
[ApiController]
|
|
|
public class DataMigrationController : ControllerBase
|
|
|
{
|
|
|
+
|
|
|
///Teacher表
|
|
|
///
|
|
|
/// 复制的数据
|
|
@@ -46,6 +48,124 @@ namespace TEAMModelOS.Controllers
|
|
|
_azureStorage = azureStorage;
|
|
|
_dingDing = dingDing;
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 迁移教师基础信息,并处理历史数据。
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="data"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ //[AuthToken(Roles = "teacher")]
|
|
|
+ [HttpGet("restore-stulist")]
|
|
|
+ public async Task<IActionResult> RestoreStulist() {
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ List<School> schools = new List<School>(0);
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: "SELECT value(c) FROM c", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
|
|
|
+ {
|
|
|
+ schools.Add(item);
|
|
|
+ }
|
|
|
+ foreach (var school in schools) {
|
|
|
+ List<GroupList> teachlists = new List<GroupList>();
|
|
|
+ List<GroupList> reschlists = new List<GroupList>();
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<StuList>(queryText: "SELECT value(c) FROM c", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"StuList-{school.id}") }))
|
|
|
+ {
|
|
|
+ List<Member> members = new List<Member>();
|
|
|
+ if (item.students.IsNotEmpty()) {
|
|
|
+ item.students.ForEach(x => {
|
|
|
+ members.Add(new Member { id = x.id, code = school.id, type = 2});
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (item.tmids.IsNotEmpty()) {
|
|
|
+ item.tmids.ForEach(x => {
|
|
|
+ members.Add(new Member { id = x, type =1 });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ GroupList group = new GroupList
|
|
|
+ {
|
|
|
+ pk = "GroupList",
|
|
|
+ id = item.id,
|
|
|
+ code = $"GroupList-{school.id}",
|
|
|
+ name = item.id,
|
|
|
+ ttl = -1,
|
|
|
+ no = item.no,
|
|
|
+ periodId = string.IsNullOrEmpty(item.periodId) ? school.period[0]?.id : item.periodId,
|
|
|
+ scope = "school",
|
|
|
+ creatorId = item.creatorId,
|
|
|
+ type = "teach",
|
|
|
+ members = members,
|
|
|
+ school = school.id
|
|
|
+ };
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync(group, new PartitionKey(group.code));
|
|
|
+ teachlists.Add(group);
|
|
|
+ }
|
|
|
+ await GroupListService.GetGroupListMemberInfo(client, "teach", teachlists, "School");
|
|
|
+
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<TchList>(queryText: "SELECT value(c) FROM c", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"TchList-{school.id}") }))
|
|
|
+ {
|
|
|
+ List<Member> members = new List<Member>();
|
|
|
+
|
|
|
+ if (item.teachers.IsNotEmpty())
|
|
|
+ {
|
|
|
+ item.teachers.ForEach(x => {
|
|
|
+ members.Add(new Member { id = x, type = 1 });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ GroupList group = new GroupList
|
|
|
+ {
|
|
|
+ pk = "GroupList",
|
|
|
+ id = item.id,
|
|
|
+ code = $"GroupList-{school.id}",
|
|
|
+ name = item.id,
|
|
|
+ ttl = -1,
|
|
|
+ no = item.no,
|
|
|
+ scope = "school",
|
|
|
+ creatorId = item.creatorId,
|
|
|
+ type = "research",
|
|
|
+ members = members,
|
|
|
+ school=school.id
|
|
|
+ };
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync(group, new PartitionKey(group.code));
|
|
|
+ reschlists.Add(group);
|
|
|
+ }
|
|
|
+ await GroupListService.GetGroupListMemberInfo(client, "research", teachlists, "School");
|
|
|
+ }
|
|
|
+ List<GroupList> groupLists = new List<GroupList>();
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<StuList>(queryText: "SELECT value(c) FROM c", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"StuList") }))
|
|
|
+ {
|
|
|
+ List<Member> members = new List<Member>();
|
|
|
+ if (item.students.IsNotEmpty())
|
|
|
+ {
|
|
|
+ item.students.ForEach(x => {
|
|
|
+ members.Add(new Member { id = x.id, code =x.id.Replace("Base-",""), type = 2 });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (item.tmids.IsNotEmpty())
|
|
|
+ {
|
|
|
+ item.tmids.ForEach(x => {
|
|
|
+ members.Add(new Member { id = x, type = 1 });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ GroupList group = new GroupList
|
|
|
+ {
|
|
|
+ pk = "GroupList",
|
|
|
+ id = item.id,
|
|
|
+ code = $"GroupList",
|
|
|
+ name = item.id,
|
|
|
+ ttl = -1,
|
|
|
+ no = item.no,
|
|
|
+ scope = "school",
|
|
|
+ creatorId = item.creatorId,
|
|
|
+ type = "teach",
|
|
|
+ members = members,
|
|
|
+
|
|
|
+ };
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync(group, new PartitionKey(group.code));
|
|
|
+ groupLists.Add(group);
|
|
|
+ }
|
|
|
+ await GroupListService.GetGroupListMemberInfo(client, "teach", groupLists, "Teacher");
|
|
|
+
|
|
|
+ return Ok();
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 迁移教师基础信息,并处理历史数据。
|
|
|
/// </summary>
|