|
@@ -14,8 +14,9 @@ using Azure.Messaging.ServiceBus;
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
using TEAMModelOS.SDK.Models.Service;
|
|
|
using System.Text.RegularExpressions;
|
|
|
+using TEAMModelOS.SDK.Models;
|
|
|
|
|
|
-namespace TEAMModelOS.SDK.Models
|
|
|
+namespace TEAMModelOS.SDK
|
|
|
{
|
|
|
public class GroupListService
|
|
|
{
|
|
@@ -571,7 +572,44 @@ namespace TEAMModelOS.SDK.Models
|
|
|
}
|
|
|
return (members,groupLists);
|
|
|
}
|
|
|
-
|
|
|
+ public static async Task< List<RGroupList> > GetGroupListMemberByType(CosmosClient client,string type, List<string> scopes, string school, DingDing _dingDing)
|
|
|
+ {
|
|
|
+ StringBuilder sql = new StringBuilder($"SELECT distinct value(c) FROM c where c.type='{type}'");
|
|
|
+
|
|
|
+ Dictionary<string, List<RGroupList>> groups = new Dictionary<string, List<RGroupList>>();
|
|
|
+ if (scopes.Contains("school"))
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(school))
|
|
|
+ {
|
|
|
+ List<RGroupList> groupLists= new List<RGroupList>();
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<RGroupList>(queryText: sql.ToString(),
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList-{school}") }))
|
|
|
+ {
|
|
|
+ groupLists.Add(item);
|
|
|
+ }
|
|
|
+ groups.Add("School", groupLists);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (scopes.Contains("private")) {
|
|
|
+ List<RGroupList> groupLists = new List<RGroupList>();
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<RGroupList>(queryText: sql.ToString(),
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList") }))
|
|
|
+ {
|
|
|
+ groupLists.Add(item);
|
|
|
+ }
|
|
|
+ groups.Add("Teacher", groupLists);
|
|
|
+ }
|
|
|
+ foreach (var item in groups)
|
|
|
+ {
|
|
|
+ var list = item.Value.GroupBy(x => x.type).Select(y => new { key = y.Key, list = y.ToList() });
|
|
|
+ foreach (var group in list)
|
|
|
+ {
|
|
|
+ (List<RGroupList> rgroups, List<RMember> rmembers) = await GetGroupListMemberInfo(client, group.key, group.list, item.Key, _dingDing);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var lists= groups.SelectMany(x => x.Value).ToList() ;
|
|
|
+ return lists;
|
|
|
+ }
|
|
|
public static async Task<(List<RGroupList> groups, List<RMember> members)> GetGroupListMemberInfo(CosmosClient client, string type, List<RGroupList> groups, string groupTbname, DingDing _dingDing)
|
|
|
{
|
|
|
|