|
@@ -23,6 +23,7 @@ using Microsoft.AspNetCore.Hosting;
|
|
|
using static TEAMModelOS.SDK.GroupListService;
|
|
|
using TEAMModelOS.Controllers.Both;
|
|
|
using CourseDto = TEAMModelOS.Controllers.Both.CourseDto;
|
|
|
+using System.Net.Http;
|
|
|
|
|
|
namespace TEAMModelOS.Controllers
|
|
|
{
|
|
@@ -604,98 +605,110 @@ namespace TEAMModelOS.Controllers
|
|
|
case bool when $"{opt}".Equals("manage", StringComparison.OrdinalIgnoreCase):
|
|
|
{
|
|
|
List<GroupListGrp> groupLists = new List<GroupListGrp>();
|
|
|
- //包含,学校的行政班,教学班
|
|
|
- json.TryGetProperty("type", out JsonElement _type);
|
|
|
- List<string> types = null;
|
|
|
- if (_type.ValueKind.Equals(JsonValueKind.Array))
|
|
|
- {
|
|
|
- types = _type.ToObject<List<string>>();
|
|
|
- }
|
|
|
- else if (_type.ValueKind.Equals(JsonValueKind.String))
|
|
|
- {
|
|
|
- types = new List<string> { $"{_type}" };
|
|
|
+ var authData = HttpContext.GetAuthTokenKey("Roles");
|
|
|
+ object _roles = null;
|
|
|
+ HttpContext?.Items.TryGetValue("Roles", out _roles);
|
|
|
+ List<string> rolse = new List<string>();
|
|
|
+ if (_roles!= null) {
|
|
|
+ rolse= (List<string>)_roles;
|
|
|
}
|
|
|
- if (types.IsEmpty() || types.Contains("class"))
|
|
|
+
|
|
|
+ if (rolse.Contains("admin"))
|
|
|
{
|
|
|
- StringBuilder classsql = new StringBuilder($"SELECT c.id,c.name,c.periodId ,c.year,c.no FROM c where ( c.graduate = 0 or IS_DEFINED(c.graduate) = false )");
|
|
|
- if (!string.IsNullOrEmpty($"{periodId}"))
|
|
|
+ //包含,学校的行政班,教学班
|
|
|
+ json.TryGetProperty("type", out JsonElement _type);
|
|
|
+ List<string> types = null;
|
|
|
+ if (_type.ValueKind.Equals(JsonValueKind.Array))
|
|
|
+ {
|
|
|
+ types = _type.ToObject<List<string>>();
|
|
|
+ }
|
|
|
+ else if (_type.ValueKind.Equals(JsonValueKind.String))
|
|
|
{
|
|
|
- classsql.Append($" and c.periodId='{periodId}' ");
|
|
|
+ types = new List<string> { $"{_type}" };
|
|
|
}
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<ClassInfo>(queryText: classsql.ToString(),
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{school}") }))
|
|
|
+ if (types.IsEmpty() || types.Contains("class"))
|
|
|
{
|
|
|
- int scount = 0;
|
|
|
- HashSet<string> groupNames = new HashSet<string>();
|
|
|
- string gpsql = $"SELECT distinct c.id, c.groupId,c.groupName FROM c where c.classId='{item.id}' ";
|
|
|
- await foreach (var gp in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<Student>(queryText: gpsql,
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Base-{school}") }))
|
|
|
+ StringBuilder classsql = new StringBuilder($"SELECT c.id,c.name,c.periodId ,c.year,c.no FROM c where ( c.graduate = 0 or IS_DEFINED(c.graduate) = false )");
|
|
|
+ if (!string.IsNullOrEmpty($"{periodId}"))
|
|
|
{
|
|
|
- if (!string.IsNullOrWhiteSpace(gp.groupName))
|
|
|
+ classsql.Append($" and c.periodId='{periodId}' ");
|
|
|
+ }
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<ClassInfo>(queryText: classsql.ToString(),
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{school}") }))
|
|
|
+ {
|
|
|
+ int scount = 0;
|
|
|
+ HashSet<string> groupNames = new HashSet<string>();
|
|
|
+ string gpsql = $"SELECT distinct c.id, c.groupId,c.groupName FROM c where c.classId='{item.id}' ";
|
|
|
+ await foreach (var gp in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<Student>(queryText: gpsql,
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Base-{school}") }))
|
|
|
{
|
|
|
- groupNames.Add(gp.groupName);
|
|
|
+ if (!string.IsNullOrWhiteSpace(gp.groupName))
|
|
|
+ {
|
|
|
+ groupNames.Add(gp.groupName);
|
|
|
+ }
|
|
|
+ scount += 1;
|
|
|
}
|
|
|
- scount += 1;
|
|
|
+ ///行政班(学生搜寻classId动态返回)class
|
|
|
+ GroupListGrp group = new GroupListGrp
|
|
|
+ {
|
|
|
+ id = item.id,
|
|
|
+ code = $"GroupList-{school}",
|
|
|
+ name = item.name,
|
|
|
+ periodId = item.periodId,
|
|
|
+ scope = "school",
|
|
|
+ school = $"{school}",
|
|
|
+ type = "class",
|
|
|
+ year = item.year,
|
|
|
+ expire=0,
|
|
|
+ no=item.no,
|
|
|
+ groupName = groupNames,
|
|
|
+ scount= scount
|
|
|
+ };
|
|
|
+ groupLists.Add(group);
|
|
|
}
|
|
|
- ///行政班(学生搜寻classId动态返回)class
|
|
|
- GroupListGrp group = new GroupListGrp
|
|
|
- {
|
|
|
- id = item.id,
|
|
|
- code = $"GroupList-{school}",
|
|
|
- name = item.name,
|
|
|
- periodId = item.periodId,
|
|
|
- scope = "school",
|
|
|
- school = $"{school}",
|
|
|
- type = "class",
|
|
|
- year = item.year,
|
|
|
- expire=0,
|
|
|
- no=item.no,
|
|
|
- groupName = groupNames,
|
|
|
- scount= scount
|
|
|
- };
|
|
|
- groupLists.Add(group);
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if (types.IsEmpty() || types.Contains("teach"))
|
|
|
- {
|
|
|
- //教学班
|
|
|
- StringBuilder teachsql = new StringBuilder($" SELECT distinct value(c) FROM c where c.type='teach' and ( c.expire = 0 or IS_DEFINED(c.expire) = false or c.expire >={nowtime} ) ");
|
|
|
- if (!string.IsNullOrEmpty($"{periodId}"))
|
|
|
- {
|
|
|
- teachsql.Append($" and c.periodId='{periodId}'");
|
|
|
- }
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").
|
|
|
- GetItemQueryIterator<GroupList>(queryText: teachsql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"GroupList-{school}") }))
|
|
|
+ if (types.IsEmpty() || types.Contains("teach"))
|
|
|
{
|
|
|
- HashSet<string> groupName = item.members.Where(x => !string.IsNullOrEmpty(x.groupName)).Select(y => y.groupName).ToHashSet();
|
|
|
- groupLists.Add(new GroupListGrp(item, groupName));
|
|
|
+ //教学班
|
|
|
+ StringBuilder teachsql = new StringBuilder($" SELECT distinct value(c) FROM c where c.type='teach' and ( c.expire = 0 or IS_DEFINED(c.expire) = false or c.expire >={nowtime} ) ");
|
|
|
+ if (!string.IsNullOrEmpty($"{periodId}"))
|
|
|
+ {
|
|
|
+ teachsql.Append($" and c.periodId='{periodId}'");
|
|
|
+ }
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").
|
|
|
+ GetItemQueryIterator<GroupList>(queryText: teachsql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"GroupList-{school}") }))
|
|
|
+ {
|
|
|
+ HashSet<string> groupName = item.members.Where(x => !string.IsNullOrEmpty(x.groupName)).Select(y => y.groupName).ToHashSet();
|
|
|
+ groupLists.Add(new GroupListGrp(item, groupName));
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if (types.IsEmpty() || types.Contains("research"))
|
|
|
- {
|
|
|
- //教研组
|
|
|
- StringBuilder researchsql = new StringBuilder($"SELECT distinct value(c) FROM c where c.type='research'");
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").
|
|
|
- GetItemQueryIterator<GroupList>(queryText: researchsql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"GroupList-{school}") }))
|
|
|
+ if (types.IsEmpty() || types.Contains("research"))
|
|
|
{
|
|
|
- HashSet<string> groupName = item.members.Where(x => !string.IsNullOrEmpty(x.groupName)).Select(y => y.groupName).ToHashSet();
|
|
|
- groupLists.Add(new GroupListGrp(item, groupName));
|
|
|
+ //教研组
|
|
|
+ StringBuilder researchsql = new StringBuilder($"SELECT distinct value(c) FROM c where c.type='research'");
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").
|
|
|
+ GetItemQueryIterator<GroupList>(queryText: researchsql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"GroupList-{school}") }))
|
|
|
+ {
|
|
|
+ HashSet<string> groupName = item.members.Where(x => !string.IsNullOrEmpty(x.groupName)).Select(y => y.groupName).ToHashSet();
|
|
|
+ groupLists.Add(new GroupListGrp(item, groupName));
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if (types.IsEmpty() || types.Contains("yxtrain"))
|
|
|
- {
|
|
|
- //研修名单
|
|
|
- StringBuilder yxtrainsql = new StringBuilder($"SELECT distinct value(c) FROM c where c.type='yxtrain'");
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").
|
|
|
- GetItemQueryIterator<GroupList>(queryText: yxtrainsql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"GroupList-{school}") }))
|
|
|
+ if (types.IsEmpty() || types.Contains("yxtrain"))
|
|
|
{
|
|
|
- HashSet<string> groupName = item.members.Where(x => !string.IsNullOrEmpty(x.groupName)).Select(y => y.groupName).ToHashSet();
|
|
|
- groupLists.Add(new GroupListGrp(item, groupName));
|
|
|
+ //研修名单
|
|
|
+ StringBuilder yxtrainsql = new StringBuilder($"SELECT distinct value(c) FROM c where c.type='yxtrain'");
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").
|
|
|
+ GetItemQueryIterator<GroupList>(queryText: yxtrainsql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"GroupList-{school}") }))
|
|
|
+ {
|
|
|
+ HashSet<string> groupName = item.members.Where(x => !string.IsNullOrEmpty(x.groupName)).Select(y => y.groupName).ToHashSet();
|
|
|
+ groupLists.Add(new GroupListGrp(item, groupName));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
//long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
return Ok(new { groupLists });
|
|
|
}
|
|
@@ -809,7 +822,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
if (courseIds.Any())
|
|
|
{
|
|
|
- string sqlCourse = $"select value c from c where c.creatorId='{tmdid}' and c.id in ({string.Join(",", courseIds.Select(b => $"'{b}'"))})";
|
|
|
+ string sqlCourse = $"select value c from c where c.id in ({string.Join(",", courseIds.Select(b => $"'{b}'"))})";
|
|
|
var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetList<CourseBase>(sqlCourse, $"CourseBase");
|
|
|
if (result.list.IsNotEmpty())
|
|
|
{
|