|
@@ -35,7 +35,6 @@ using TEAMModelOS.SDK.Models;
|
|
|
using TEAMModelOS.SDK.Models.Cosmos.BI;
|
|
|
using TEAMModelOS.SDK.Models.Cosmos.Common;
|
|
|
using TEAMModelOS.SDK.Models.Service.BI;
|
|
|
-using static TEAMModelBI.Controllers.BISchool.SchoolController;
|
|
|
|
|
|
namespace TEAMModelBI.Controllers.BISchool
|
|
|
{
|
|
@@ -258,14 +257,16 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
foreach (var item in teachers)
|
|
|
{
|
|
|
msg.Append($"{item.name}[{item.id}]");
|
|
|
- var tchSchool = item.schools.Find(f => f.schoolId.Equals($"{school.id}"));
|
|
|
+ var tchSchool = item.schools.Where(f => f.schoolId.Equals($"{school.id}")).FirstOrDefault();
|
|
|
if (tchSchool == null)
|
|
|
{
|
|
|
Teacher.TeacherSchool teacherSchool = new() { schoolId = school.id, name = school.name, status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), picture = school.picture, areaId = school.areaId };
|
|
|
item.schools.Add(teacherSchool);
|
|
|
- await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(item, item.id, new PartitionKey("Base"));
|
|
|
}
|
|
|
+ else
|
|
|
+ tchSchool.areaId = school.areaId;
|
|
|
|
|
|
+ await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(item, item.id, new PartitionKey("Base"));
|
|
|
}
|
|
|
await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(school, school.id, new PartitionKey(school.code));
|
|
|
}
|
|
@@ -741,6 +742,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
if (!schoolTeacher.roles.Contains("admin"))
|
|
|
{
|
|
|
schoolTeacher.roles.Add("admin");
|
|
|
+ schoolTeacher.status = "join";
|
|
|
schoolTeacher = await cosmosClient.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<SchoolTeacher>(schoolTeacher, schoolTeacher.id, new PartitionKey($"Teacher-{schoolId}"));
|
|
|
strMsg.Append($"并设置管理员,学校信息{schoolName}【{schoolId}】");
|
|
|
}
|
|
@@ -1852,7 +1854,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
if (!string.IsNullOrEmpty($"{areaId}"))
|
|
|
{
|
|
|
List<string> schools = new();
|
|
|
- schools = await CommonFind.FindSchoolIds(cosmosClient, $"select c.id from c where c.areaId='{areaId}'", "Base");
|
|
|
+ schools = await CommonFind.FindScIds(cosmosClient, $"select c.id from c where c.areaId='{areaId}'", "Base");
|
|
|
|
|
|
allSize = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"select value(sum(c.size)) from c where c.areaId='{areaId}'", "Base"); //区域所有学校空间
|
|
|
|
|
@@ -2061,6 +2063,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
/// </summary>
|
|
|
/// <param name="jsonElement"></param>
|
|
|
/// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
[HttpPost("get-managescs")]
|
|
|
public async Task<IActionResult> GetManageSclist(JsonElement jsonElement)
|
|
|
{
|
|
@@ -2092,7 +2095,32 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
return Ok(new { state = RespondCode.Ok, mScInfos });
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 查询学校简单信息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="jsonElement"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("get-scsimple")]
|
|
|
+ public async Task<IActionResult> GetScSimple(JsonElement jsonElement)
|
|
|
+ {
|
|
|
+ var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
+ jsonElement.TryGetProperty("scName", out JsonElement scName);
|
|
|
|
|
|
+ StringBuilder scSql = new("select c.id,c.name,c.picture,c.createTime from c");
|
|
|
+ if (!string.IsNullOrEmpty($"{scName}"))
|
|
|
+ scSql.Append($" where c.name='{scName}'");
|
|
|
+
|
|
|
+ List<ScSimple> scSimple = new();
|
|
|
+
|
|
|
+ await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<ScSimple>(queryText: scSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
+ {
|
|
|
+ scSimple.Add(itemSchool);
|
|
|
+ }
|
|
|
+
|
|
|
+ return Ok(new { state = RespondCode.Ok, scSimple });
|
|
|
+ }
|
|
|
|
|
|
#region 购买记录
|
|
|
|
|
@@ -2224,6 +2252,14 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
public Dictionary<string, double?> catalogSize { get; set; }
|
|
|
}
|
|
|
|
|
|
+ public record ScSimple
|
|
|
+ {
|
|
|
+ public string id { get; set; }
|
|
|
+ public string name { get; set; }
|
|
|
+ public string picture { get; set; }
|
|
|
+ public long createTime { get; set; }
|
|
|
+ }
|
|
|
+
|
|
|
public record DelSchoolRel
|
|
|
{
|
|
|
public string id { get; set; }
|