|
@@ -23,6 +23,7 @@ using static TEAMModelOS.SDK.Models.Teacher;
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
using TEAMModelOS.Filter;
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
+using HTEXLib.COMM.Helpers;
|
|
|
|
|
|
namespace TEAMModelAPI.Controllers
|
|
|
{
|
|
@@ -37,9 +38,6 @@ namespace TEAMModelAPI.Controllers
|
|
|
private readonly AzureRedisFactory _azureRedis;
|
|
|
private readonly DingDing _dingDing;
|
|
|
private readonly Option _option;
|
|
|
- int baseSpaceSize = 1; //學校保底空間大小(1G)
|
|
|
- private readonly double bytes = 1073741824;
|
|
|
- private readonly int redisAclassoneDbNum = 8; //AclassOne Redis DB號
|
|
|
private readonly IConfiguration _configuration;
|
|
|
public SchoolController(AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, DingDing dingDing, IOptionsSnapshot<Option> option, IConfiguration configuration)
|
|
|
{
|
|
@@ -52,13 +50,13 @@ namespace TEAMModelAPI.Controllers
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 学校信息
|
|
|
+ /// 学校基础信息
|
|
|
/// </summary>
|
|
|
/// <param name="request"></param>
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpGet("get-school-info")]
|
|
|
- [ApiToken(Auth = "1",Name = "学校信息", Limit=false)]
|
|
|
+ [ApiToken(Auth = "1",Name = "学校基础信息", Limit=false)]
|
|
|
public async Task<IActionResult> GetSchoolInfo()
|
|
|
{
|
|
|
var (id, school) = HttpContext.GetApiTokenInfo();
|
|
@@ -72,5 +70,169 @@ namespace TEAMModelAPI.Controllers
|
|
|
period
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取学校教师列表
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpGet("get-teacher-list")]
|
|
|
+ [ApiToken(Auth = "2", Name = "学校教师列表", Limit = false)]
|
|
|
+ public async Task<IActionResult> GetTeacherList()
|
|
|
+ {
|
|
|
+ var (id, school) = HttpContext.GetApiTokenInfo();
|
|
|
+ List<dynamic> teachers= new List<dynamic>();
|
|
|
+ string sql = $"select c.id,c.name ,c.picture,c.job ,c.subjectIds,c.roles from c where c.status='join' ";
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<dynamic>
|
|
|
+ (queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Teacher-{school}") })) {
|
|
|
+ teachers.Add(item);
|
|
|
+ }
|
|
|
+ return Ok(new
|
|
|
+ {
|
|
|
+ teachers
|
|
|
+ });
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ "periodId":"学段(选填)"
|
|
|
+ */
|
|
|
+ /// <summary>
|
|
|
+ /// 获取学校的行政班,教学班,教研组,研修名单
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("get-group-list")]
|
|
|
+ [ApiToken(Auth = "3", Name = "学校教师列表", Limit = false)]
|
|
|
+ public async Task<IActionResult> GetGroupList(JsonElement json)
|
|
|
+ {
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ var (id, school) = HttpContext.GetApiTokenInfo();
|
|
|
+ json.TryGetProperty("periodId", out JsonElement periodId);
|
|
|
+ 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> { $"{types}" };
|
|
|
+ }
|
|
|
+ if (types.IsEmpty() || types.Contains("class"))
|
|
|
+ {
|
|
|
+ StringBuilder classsql = new StringBuilder($"SELECT c.id,c.name,c.periodId ,c.year FROM c ");
|
|
|
+ if (!string.IsNullOrEmpty($"{periodId}"))
|
|
|
+ {
|
|
|
+ classsql.Append($" where 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}") }))
|
|
|
+ {
|
|
|
+ HashSet<string> groupNames = new HashSet<string>();
|
|
|
+ string gpsql = $"SELECT distinct c.groupId,c.groupName FROM c where c.classId='{item.id}'and c.groupName <>null";
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ ///行政班(学生搜寻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,
|
|
|
+ groupName = groupNames
|
|
|
+ };
|
|
|
+ groupLists.Add(group);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (types.IsEmpty() || types.Contains("teach"))
|
|
|
+ {
|
|
|
+ //教学班
|
|
|
+ StringBuilder teachsql = new StringBuilder($" SELECT distinct value(c) FROM c where c.type='teach'");
|
|
|
+ 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}") }))
|
|
|
+ {
|
|
|
+ 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}") }))
|
|
|
+ {
|
|
|
+ HashSet<string> groupName = item.members.Where(x => !string.IsNullOrEmpty(x.groupName)).Select(y => y.groupName).ToHashSet();
|
|
|
+ groupLists.Add(new GroupListGrp(item, groupName));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Ok(new
|
|
|
+ {
|
|
|
+ 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 = "4", Name = "获取名单详细信息和成员信息", Limit = false)]
|
|
|
+ public async Task<IActionResult> GetGroupMembers(JsonElement json)
|
|
|
+ {
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ if (!json.TryGetProperty("ids", out JsonElement ids)) return BadRequest();
|
|
|
+ var (id, school) = HttpContext.GetApiTokenInfo();
|
|
|
+ List<string> listids = ids.ToObject<List<string>>();
|
|
|
+ (List<RMember> members, List<RGroupList> groups) = await GroupListService.GetStutmdidListids(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 });
|
|
|
+ }
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("get-course-list")]
|
|
|
+ [ApiToken(Auth = "5", Name = "获取课程列表信息", Limit = false)]
|
|
|
+ public async Task<IActionResult> GetCourseList(JsonElement json) {
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ var (id, school) = HttpContext.GetApiTokenInfo();
|
|
|
+ json.TryGetProperty("periodId", out JsonElement periodId);
|
|
|
+ json.TryGetProperty("subjectId", out JsonElement subjectId);
|
|
|
+ StringBuilder sql = new StringBuilder($"SELECT c.id,c.name,c.subject,c.period,c.scope,c.no,c.school FROM c where 1=1 ");
|
|
|
+ if (!string.IsNullOrWhiteSpace($"{periodId}")) {
|
|
|
+ sql.Append($" and c.period.id='{periodId}'");
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrWhiteSpace($"{subjectId}"))
|
|
|
+ {
|
|
|
+ sql.Append($" and c.subject.id='{subjectId}'");
|
|
|
+ }
|
|
|
+ List<dynamic> courses = new List<dynamic>();
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").
|
|
|
+ GetItemQueryIterator<dynamic>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{school}") }))
|
|
|
+ {
|
|
|
+ courses.Add(item);
|
|
|
+ }
|
|
|
+ return Ok(new { courses });
|
|
|
+ }
|
|
|
}
|
|
|
}
|