|
@@ -132,8 +132,8 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
if (!jsonElement.TryGetProperty("school_code", out JsonElement school_code)) return Ok(new { state = 1, message = "school_code参数错误!" });
|
|
|
if (!jsonElement.TryGetProperty("mode", out JsonElement mode)) return Ok(new { state = 1, message = "mode参数错误!" }); //del删除权限 up更新权限
|
|
|
if (!jsonElement.TryGetProperty("paramPower", out JsonElement paramPower)) return Ok(new { state = 1, message = "paramPower参数错误!" });
|
|
|
- if (!jsonElement.TryGetProperty("tmdId", out JsonElement _tmdId)) return BadRequest();
|
|
|
- if (!jsonElement.TryGetProperty("tmdName", out JsonElement _tmdName)) return BadRequest();
|
|
|
+
|
|
|
+ var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
|
|
|
List<Exist> havepower = new List<Exist>(); //已存在的
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
|
|
@@ -210,9 +210,10 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- List<BISchool> schools = new List<BISchool>();
|
|
|
+ var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
|
|
|
|
|
|
- StringBuilder stringBuilder = new StringBuilder($"{foundSchools.tmdName}【{foundSchools.tmdId}】使用批量创校功能:");
|
|
|
+ List<BISchool> schools = new List<BISchool>();
|
|
|
+ StringBuilder stringBuilder = new StringBuilder($"{_tmdName}【{_tmdId}】使用批量创校功能:");
|
|
|
|
|
|
if (foundSchools.biSchools.Count > 0)
|
|
|
{
|
|
@@ -396,29 +397,24 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
await foreach (var itemSchool in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: stringBuilder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
{
|
|
|
- SchoolAssist schoolAssist = new SchoolAssist();
|
|
|
- schoolAssist.id = itemSchool.id;
|
|
|
- schoolAssist.code = itemSchool.code;
|
|
|
- schoolAssist.pk = itemSchool.pk;
|
|
|
- schoolAssist.ttl = itemSchool.ttl;
|
|
|
- schoolAssist.schoolCode = itemSchool.schoolCode;
|
|
|
- schoolAssist.name = itemSchool.name;
|
|
|
- schoolAssist.period = itemSchool.period;
|
|
|
- schoolAssist.campuses = itemSchool.campuses;
|
|
|
- schoolAssist.region = itemSchool.region;
|
|
|
- schoolAssist.province = itemSchool.province;
|
|
|
- schoolAssist.city = itemSchool.city;
|
|
|
- schoolAssist.dist = itemSchool.dist;
|
|
|
- schoolAssist.areaId = itemSchool.areaId;
|
|
|
- schoolAssist.size = itemSchool.size;
|
|
|
- schoolAssist.address = itemSchool.address;
|
|
|
- schoolAssist.picture = itemSchool.picture;
|
|
|
- schoolAssist.timeZone = itemSchool.timeZone;
|
|
|
- schoolAssist.type = itemSchool.type;
|
|
|
- schoolAssist.standard = itemSchool.standard;
|
|
|
- schoolAssist.hpappraise = itemSchool.hpappraise;
|
|
|
- schoolAssist.standard = itemSchool.standard;
|
|
|
- schoolAssist.areaId = itemSchool.areaId;
|
|
|
+ SchoolAssist schoolAssist = new SchoolAssist()
|
|
|
+ {
|
|
|
+ id = itemSchool.id,
|
|
|
+ code = itemSchool.code,
|
|
|
+ schoolCode = itemSchool.schoolCode,
|
|
|
+ name = itemSchool.name,
|
|
|
+ region = itemSchool.region,
|
|
|
+ province = itemSchool.province,
|
|
|
+ city = itemSchool.city,
|
|
|
+ dist = itemSchool.dist,
|
|
|
+ size = itemSchool.size,
|
|
|
+ address = itemSchool.address,
|
|
|
+ picture = itemSchool.picture,
|
|
|
+ type = itemSchool.type,
|
|
|
+ scale = itemSchool.scale,
|
|
|
+ areaId = itemSchool.areaId,
|
|
|
+ standard = itemSchool.standard
|
|
|
+ };
|
|
|
|
|
|
List<Assist> assists = new List<Assist>();
|
|
|
//查询学校的顾问
|
|
@@ -560,18 +556,20 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
try
|
|
|
{
|
|
|
if (!jsonElement.TryGetProperty("schoolId", out JsonElement _schoolId)) return BadRequest();
|
|
|
- if (!jsonElement.TryGetProperty("period", out JsonElement period)) return BadRequest();
|
|
|
+ if (!jsonElement.TryGetProperty("name", out JsonElement schoolName)) return BadRequest();
|
|
|
+ if (!jsonElement.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
|
|
|
+ if (!jsonElement.TryGetProperty("standard", out JsonElement standard)) return BadRequest();
|
|
|
+ //if (!jsonElement.TryGetProperty("period", out JsonElement period)) return BadRequest();
|
|
|
if (!jsonElement.TryGetProperty("picture", out JsonElement picture)) return BadRequest();
|
|
|
if (!jsonElement.TryGetProperty("size", out JsonElement size)) return BadRequest();
|
|
|
if (!jsonElement.TryGetProperty("scale", out JsonElement scale)) return BadRequest();
|
|
|
if (!jsonElement.TryGetProperty("assistId", out JsonElement _assistId)) return BadRequest();
|
|
|
- //if (!jsonElement.TryGetProperty("tmdId", out JsonElement _tmdId)) return BadRequest();
|
|
|
- //if (!jsonElement.TryGetProperty("tmdName", out JsonElement _tmdName)) return BadRequest();
|
|
|
+ if (!jsonElement.TryGetProperty("type", out JsonElement _type)) return BadRequest();
|
|
|
|
|
|
var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
|
|
|
|
|
|
List<string> assistId = _assistId.ToObject<List<string>>();
|
|
|
- List<string> periodS = period.ToObject<List<string>>();
|
|
|
+ //List<string> periodS = period.ToObject<List<string>>();
|
|
|
|
|
|
Dictionary<string, List<Dictionary<string, string>>> haveSchoolManger = new Dictionary<string, List<Dictionary<string, string>>>();
|
|
|
|
|
@@ -581,15 +579,20 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
{
|
|
|
List<Period> periods = new List<Period>();
|
|
|
string campusId = Guid.NewGuid().ToString();
|
|
|
- periodS.ForEach(x =>
|
|
|
- {
|
|
|
- periods.Add(new Period { id = Guid.NewGuid().ToString(), name = x.ToString(), campusId = campusId });
|
|
|
- });
|
|
|
+ //periodS.ForEach(x =>
|
|
|
+ //{
|
|
|
+ // periods.Add(new Period { id = Guid.NewGuid().ToString(), name = x.ToString(), campusId = campusId });
|
|
|
+ //});
|
|
|
|
|
|
- tempShool.period = periods;
|
|
|
+ //tempShool.period = periods;
|
|
|
tempShool.size = !string.IsNullOrEmpty($"{size}") ? int.Parse($"{size}") : tempShool.size;
|
|
|
tempShool.scale = !string.IsNullOrEmpty($"{scale}") ? int.Parse($"{scale}") : tempShool.scale;
|
|
|
tempShool.picture = $"{picture}";
|
|
|
+ tempShool.type = int.Parse($"{_type}");
|
|
|
+ tempShool.name = $"{schoolName}";
|
|
|
+ tempShool.areaId = $"{areaId}";
|
|
|
+ tempShool.standard = $"{standard}";
|
|
|
+
|
|
|
//修改学校
|
|
|
await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(tempShool, tempShool.id, new PartitionKey("Base"));
|
|
|
|
|
@@ -613,8 +616,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
var tems = await cosmosClient.GetContainer("TEAMModelOS", "School").DeleteItemAsync<SchoolTeacher>(item.id, new PartitionKey(item.code));
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- //bool temp = item.roles.Contains("assist");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (assistId.Count > 0)
|
|
@@ -698,52 +700,10 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- //SchoolAssist schoolAssist = new();
|
|
|
- //schoolAssist.id = tempShool.id;
|
|
|
- //schoolAssist.code = tempShool.code;
|
|
|
- //schoolAssist.pk = tempShool.pk;
|
|
|
- //schoolAssist.ttl = tempShool.ttl;
|
|
|
- //schoolAssist.schoolCode = tempShool.schoolCode;
|
|
|
- //schoolAssist.name = tempShool.name;
|
|
|
- //schoolAssist.period = tempShool.period;
|
|
|
- //schoolAssist.campuses = tempShool.campuses;
|
|
|
- //schoolAssist.region = tempShool.region;
|
|
|
- //schoolAssist.province = tempShool.province;
|
|
|
- //schoolAssist.city = tempShool.city;
|
|
|
- //schoolAssist.dist = tempShool.dist;
|
|
|
- //schoolAssist.areaId = tempShool.areaId;
|
|
|
- //schoolAssist.size = tempShool.size;
|
|
|
- //schoolAssist.address = tempShool.address;
|
|
|
- //schoolAssist.picture = tempShool.picture;
|
|
|
- //schoolAssist.timeZone = tempShool.timeZone;
|
|
|
- //schoolAssist.type = tempShool.type;
|
|
|
- //schoolAssist.standard = tempShool.standard;
|
|
|
- //schoolAssist.hpappraise = tempShool.hpappraise;
|
|
|
-
|
|
|
- //List<Assist> assists = new List<Assist>();
|
|
|
- ////查询学校的顾问
|
|
|
- //string managerSql = $"SELECT DISTINCT REPLACE(c.code, 'Teacher-', '') AS schoolId, c.id, c.name FROM c WHERE ARRAY_CONTAINS(c.roles, 'assist', true) AND c.pk = 'Teacher' AND c.status = 'join' AND c.code = 'Teacher-{tempShool.id}'";
|
|
|
- //var cosmosClent = _azureCosmos.GetCosmosClient();
|
|
|
- //await foreach (var item in cosmosClent.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: managerSql, requestOptions: new QueryRequestOptions() { }))
|
|
|
- //{
|
|
|
- // using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- // foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
- // {
|
|
|
- // Assist assist = new Assist
|
|
|
- // {
|
|
|
- // tmdId = obj.GetProperty("id").GetString(),
|
|
|
- // tmdName = obj.GetProperty("name").GetString()
|
|
|
- // };
|
|
|
- // assists.Add(assist);
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
- //schoolAssist.assists = assists;
|
|
|
}
|
|
|
|
|
|
//保存操作记录
|
|
|
- await _azureStorage.SaveLog("TeacherRoles-update", $"{_tmdName}【{_tmdId}】修改学校功能,修改的学校:{_schoolId},{string.Join("|", periodS.ToArray())},{picture},{size},{string.Join("|", assistId.ToArray())}", _dingDing, httpContext: HttpContext);
|
|
|
+ await _azureStorage.SaveLog("TeacherRoles-update", $"{_tmdName}【{_tmdId}】修改学校功能,修改的学校:{_schoolId},{_type},{picture},{size},{string.Join("|", assistId.ToArray())}", _dingDing, httpContext: HttpContext);
|
|
|
|
|
|
|
|
|
return Ok(new { state = 200 });
|
|
@@ -756,277 +716,97 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 增加学段
|
|
|
+ /// 查询区域的学校
|
|
|
/// </summary>
|
|
|
+ /// <param name="jsonElement"></param>
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
- [AuthToken(Roles = "assist")]
|
|
|
- [HttpPost("upd-schoolperiod")]
|
|
|
- public async Task<IActionResult> UpdSchoolPeriod(JsonElement jsonElement)
|
|
|
+ [HttpPost("get-schooldist")]
|
|
|
+ public async Task<IActionResult> GetSchoolDist(JsonElement jsonElement)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- if (!jsonElement.TryGetProperty("schooId", out JsonElement _schoolCode)) return BadRequest(); //学校编号
|
|
|
- jsonElement.TryGetProperty("campusId", out JsonElement _campusId); //校区ID 新增时
|
|
|
- jsonElement.TryGetProperty("campusName", out JsonElement _campusName); //校区 新增时
|
|
|
- if (!jsonElement.TryGetProperty("periodName", out JsonElement _periodName)) return BadRequest(); //新增学段名称
|
|
|
- if (!jsonElement.TryGetProperty("tmdId", out JsonElement _tmdId)) return BadRequest(); //醍摩豆账户
|
|
|
- if (!jsonElement.TryGetProperty("tmdName", out JsonElement _tmdName)) return BadRequest(); //醍摩豆账号名称
|
|
|
-
|
|
|
- StringBuilder stringBuilder = new StringBuilder($"{_tmdId}【{_tmdName}】新增学校的学段,");
|
|
|
- School school = new();
|
|
|
+ if (!jsonElement.TryGetProperty("dist", out JsonElement _dist)) return BadRequest();
|
|
|
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
- try
|
|
|
- {
|
|
|
- school = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{_schoolCode}", new PartitionKey("Base"));
|
|
|
- }
|
|
|
- catch (Exception) { }
|
|
|
-
|
|
|
- if (school != null)
|
|
|
- {
|
|
|
- if (!string.IsNullOrEmpty($"{_campusId}"))
|
|
|
- {
|
|
|
- school.period.Add(new Period { id = Guid.NewGuid().ToString(), name = $"{_periodName}", campusId = $"{_campusId}" });
|
|
|
- stringBuilder.Append($"在原有校区中添加学段:学段ID:{_campusId}学段名称:{_periodName}");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- string campusId = Guid.NewGuid().ToString();
|
|
|
- school.period.Add(new Period { id = Guid.NewGuid().ToString(), name = $"{_periodName}", campusId = campusId });
|
|
|
- school.campuses.Add(new Campus { id = campusId, name = $"{_campusName}" });
|
|
|
- stringBuilder.Append($"新建校区中在添加学段:学段ID:{_campusId}学段名称:{_periodName}");
|
|
|
- }
|
|
|
-
|
|
|
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(school, school.id, new PartitionKey("Base"));
|
|
|
-
|
|
|
- //保存操作记录
|
|
|
- await _azureStorage.SaveLog("schoolperiod-add", stringBuilder?.ToString(), _dingDing, httpContext: HttpContext);
|
|
|
-
|
|
|
- return Ok(new { state = 200, school });
|
|
|
- }
|
|
|
- else return Ok(new { state = 400, school });
|
|
|
-
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- await _dingDing.SendBotMsg($"BI,{_option.Location} /batchschool/upd-schoolperiod \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
- return BadRequest();
|
|
|
- }
|
|
|
- }
|
|
|
+ string sqltxt = $"SELECT * FROM c where c.dist='{_dist}'";
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 修改学校学段信息
|
|
|
- /// </summary>
|
|
|
- /// <param name="jsonElement"></param>
|
|
|
- /// <returns></returns>
|
|
|
- [ProducesDefaultResponseType]
|
|
|
- [AuthToken(Roles = "assist")]
|
|
|
- [HttpPost("set-schoolperiod")]
|
|
|
- public async Task<IActionResult> SetSchoolPeriod(JsonElement jsonElement)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- if (!jsonElement.TryGetProperty("tmdId", out JsonElement _tmdId)) return BadRequest(); //醍摩豆账户
|
|
|
- if (!jsonElement.TryGetProperty("tmdName", out JsonElement _tmdName)) return BadRequest(); //醍摩豆账号名称
|
|
|
- if (!jsonElement.TryGetProperty("schooId", out JsonElement _schoolCode)) return BadRequest(); //学校编号
|
|
|
- if (!jsonElement.TryGetProperty("setId", out JsonElement _setId)) return BadRequest(); //修改学段的ID
|
|
|
- if (!jsonElement.TryGetProperty("setName", out JsonElement _setName)) return BadRequest(); //修改学段的名称
|
|
|
+ List<School> schools = new List<School>();
|
|
|
|
|
|
- var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
- School school = new();
|
|
|
- try
|
|
|
+ await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
{
|
|
|
- school = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{_schoolCode}", new PartitionKey("Base"));
|
|
|
+ schools.Add(item);
|
|
|
}
|
|
|
- catch (Exception) { }
|
|
|
-
|
|
|
- if (school != null)
|
|
|
- {
|
|
|
- school.period.Find(x => x.id.Equals($"{_setId}")).name = $"{_setName}";
|
|
|
-
|
|
|
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(school, school.id, new PartitionKey("Base"));
|
|
|
-
|
|
|
- //保存操作记录
|
|
|
- await _azureStorage.SaveLog("schoolperiod-update", $"{_tmdId}【{_tmdName}】修改学校学段信息,修改ID和名称:{_setId}{_setName}", _dingDing, httpContext: HttpContext);
|
|
|
|
|
|
- return Ok(new { state = 200, school });
|
|
|
- }
|
|
|
- else return Ok(new { state = 400, school });
|
|
|
+ return Ok(new { state = 200, schools });
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- await _dingDing.SendBotMsg($"BI,{_option.Location} /batchschool/set-schoolperiod \n {ex.Message}{ex.StackTrace} ", GroupNames.成都开发測試群組);
|
|
|
+ await _dingDing.SendBotMsg($"BI,{_option.Location} /batchschool/get-schooldist \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
return BadRequest();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 删除学校学段
|
|
|
+ /// 分页学校和顾问信息
|
|
|
/// </summary>
|
|
|
/// <param name="jsonElement"></param>
|
|
|
/// <returns></returns>
|
|
|
- [ProducesDefaultResponseType]
|
|
|
- [AuthToken(Roles = "assist")]
|
|
|
- [HttpPost("del-schoolperiod")]
|
|
|
- public async Task<IActionResult> DelSchoolPeriod(JsonElement jsonElement)
|
|
|
+ [HttpPost("get-schools")]
|
|
|
+ public async Task<IActionResult> GetSchools(JsonElement jsonElement)
|
|
|
{
|
|
|
- try
|
|
|
- {
|
|
|
- if (!jsonElement.TryGetProperty("tmdId", out JsonElement _tmdId)) return BadRequest(); //醍摩豆账户
|
|
|
- if (!jsonElement.TryGetProperty("tmdName", out JsonElement _tmdName)) return BadRequest(); //醍摩豆账号名称
|
|
|
- if (!jsonElement.TryGetProperty("schooId", out JsonElement _schoolCode)) return BadRequest(); //学校编号
|
|
|
- if (!jsonElement.TryGetProperty("delId", out JsonElement _delId)) return BadRequest(); //删除学段的ID
|
|
|
+ //List<School> schools = new List<School>();
|
|
|
+ List<SchoolAssist> schoolAssists = new List<SchoolAssist>();
|
|
|
+ var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
+ if (!jsonElement.TryGetProperty("endPosition", out JsonElement endPosition)) return BadRequest();
|
|
|
+ if (!jsonElement.TryGetProperty("pageSize", out JsonElement pageSize)) return BadRequest();
|
|
|
|
|
|
- var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
- School school = new();
|
|
|
- try
|
|
|
- {
|
|
|
- school = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{_schoolCode}", new PartitionKey("Base"));
|
|
|
- }
|
|
|
- catch (Exception) { }
|
|
|
-
|
|
|
- if (school != null)
|
|
|
- {
|
|
|
- school.period.Remove(school.period.Find(x => x.id.Equals($"{_delId}")));
|
|
|
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(school, school.id, new PartitionKey("Base"));
|
|
|
+ string sqltxt = $"SELECT * FROM c order by c.id offset {endPosition} limit {pageSize}";
|
|
|
|
|
|
- //保存操作记录
|
|
|
- await _azureStorage.SaveLog("ability-update", $"{_tmdId}【{_tmdName}】删除学校的学段", _dingDing, httpContext: HttpContext);
|
|
|
-
|
|
|
- return Ok(new { state = 200, school });
|
|
|
- }
|
|
|
- else return Ok(new { state = 400, school });
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
+ await foreach (var itemSchool in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
{
|
|
|
- await _dingDing.SendBotMsg($"BI,{_option.Location} /batchschool/del-schoolperiod \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
- return BadRequest();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 增加、修改、删除学段信息
|
|
|
- /// </summary>
|
|
|
- /// <param name="jsonElement"></param>
|
|
|
- /// <returns></returns>
|
|
|
- [ProducesDefaultResponseType]
|
|
|
- [AuthToken(Roles = "assist")]
|
|
|
- [HttpPost("set-schoolperiodinfo")]
|
|
|
- public async Task<IActionResult> SetSchoolPeriodInfo(JsonElement jsonElement)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- if (!jsonElement.TryGetProperty("tmdId", out JsonElement _tmdId)) return BadRequest(); //醍摩豆账户
|
|
|
- if (!jsonElement.TryGetProperty("tmdName", out JsonElement _tmdName)) return BadRequest(); //醍摩豆账号名称
|
|
|
- if (!jsonElement.TryGetProperty("schooId", out JsonElement _schoolCode)) return BadRequest(); //学校编号
|
|
|
- if (!jsonElement.TryGetProperty("mode", out JsonElement _mode)) return BadRequest(); //执行方式 upd 新增学段 set 修改学段 del删除学段
|
|
|
- jsonElement.TryGetProperty("campusId", out JsonElement _campusId); //校区ID 新增学段
|
|
|
- jsonElement.TryGetProperty("campusName", out JsonElement _campusName); //校区 新增学段
|
|
|
- jsonElement.TryGetProperty("periodName", out JsonElement _periodName); //新增学段名称
|
|
|
- jsonElement.TryGetProperty("setId", out JsonElement _setId); //修改学段的ID
|
|
|
- jsonElement.TryGetProperty("setName", out JsonElement _setName); //修改学段的名称
|
|
|
- jsonElement.TryGetProperty("delId", out JsonElement _delId); //删除学段的ID
|
|
|
-
|
|
|
- StringBuilder stringBuilder = new StringBuilder($"{_tmdId}【{_tmdName}】");
|
|
|
- string tempType = null;
|
|
|
- var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
-
|
|
|
- School school = new();
|
|
|
- try
|
|
|
+ SchoolAssist schoolAssist = new SchoolAssist()
|
|
|
{
|
|
|
- school = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{_schoolCode}", new PartitionKey("Base"));
|
|
|
- }
|
|
|
- catch (Exception) { }
|
|
|
-
|
|
|
- if (school != null)
|
|
|
+ id = itemSchool.id,
|
|
|
+ code = itemSchool.code,
|
|
|
+ schoolCode = itemSchool.schoolCode,
|
|
|
+ name = itemSchool.name,
|
|
|
+ region = itemSchool.region,
|
|
|
+ province = itemSchool.province,
|
|
|
+ city = itemSchool.city,
|
|
|
+ dist = itemSchool.dist,
|
|
|
+ size = itemSchool.size,
|
|
|
+ address = itemSchool.address,
|
|
|
+ picture = itemSchool.picture,
|
|
|
+ type = itemSchool.type,
|
|
|
+ scale = itemSchool.scale,
|
|
|
+ areaId = itemSchool.areaId,
|
|
|
+ standard = itemSchool.standard
|
|
|
+ };
|
|
|
+
|
|
|
+ List<Assist> assists = new List<Assist>();
|
|
|
+ //查询学校的顾问
|
|
|
+ string managerSql = $"SELECT DISTINCT REPLACE(c.code, 'Teacher-', '') AS schoolId, c.id, c.name FROM c WHERE ARRAY_CONTAINS(c.roles, 'assist', true) AND c.pk = 'Teacher' AND c.status = 'join' AND c.code = 'Teacher-{itemSchool.id}'";
|
|
|
+ var cosmosClent = _azureCosmos.GetCosmosClient();
|
|
|
+ await foreach (var item in cosmosClent.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: managerSql, requestOptions: new QueryRequestOptions() { }))
|
|
|
{
|
|
|
- switch ($"{_mode}")
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
{
|
|
|
- //新增学段
|
|
|
- case "upd":
|
|
|
-
|
|
|
- if (string.IsNullOrEmpty($"{_periodName}")) return Ok(new { state = 1 });
|
|
|
- if (!string.IsNullOrEmpty($"{_campusId}"))
|
|
|
- {
|
|
|
- school.period.Add(new Period { id = Guid.NewGuid().ToString(), name = $"{_periodName}", campusId = $"{_campusId}" });
|
|
|
- stringBuilder.Append($"新增学校学段,在原有校区中添加学段:学段ID:{_campusId}学段名称:{_periodName}");
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- string campusId = Guid.NewGuid().ToString();
|
|
|
- school.period.Add(new Period { id = Guid.NewGuid().ToString(), name = $"{_periodName}", campusId = campusId });
|
|
|
- school.campuses.Add(new Campus { id = campusId, name = $"{_campusName}" });
|
|
|
+ Assist assist = new Assist
|
|
|
+ {
|
|
|
+ tmdId = obj.GetProperty("id").GetString(),
|
|
|
+ tmdName = obj.GetProperty("name").GetString()
|
|
|
+ };
|
|
|
|
|
|
- stringBuilder.Append($"新增学校学段,新建校区中在添加学段:学段ID:{_campusId}学段名称:{_periodName}");
|
|
|
- }
|
|
|
- tempType = "schoolperiod-add";
|
|
|
- break;
|
|
|
- //修改学段
|
|
|
- case "set":
|
|
|
- school.period.Find(x => x.id.Equals($"{_setId}")).name = $"{_setName}";
|
|
|
- stringBuilder.Append($"修改学校学段,修改ID和名称:{_setId}{_setName}");
|
|
|
- tempType = "schoolperiod-set";
|
|
|
- break;
|
|
|
-
|
|
|
- //删除学段
|
|
|
- case "del":
|
|
|
- school.period.Remove(school.period.Find(x => x.id.Equals($"{_delId}")));
|
|
|
- stringBuilder.Append($"删除学校的学段,删除学段ID和名称:{_delId}");
|
|
|
- tempType = "schoolperiod-del";
|
|
|
- break;
|
|
|
- default:
|
|
|
- return Ok(new { state = 1, message = "mode参数错误" });
|
|
|
+ assists.Add(assist);
|
|
|
}
|
|
|
-
|
|
|
- //保存操作记录
|
|
|
- await _azureStorage.SaveLog(tempType?.ToString(), stringBuilder?.ToString(), _dingDing, httpContext: HttpContext);
|
|
|
-
|
|
|
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(school, school.id, new PartitionKey("Base"));
|
|
|
-
|
|
|
- return Ok(new { state = 200, school });
|
|
|
}
|
|
|
- else return Ok(new { state = 400, school });
|
|
|
-
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- await _dingDing.SendBotMsg($"BI,{_option.Location} /batchschool/set-schoolperiodinfo \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
- return BadRequest();
|
|
|
+ schoolAssist.assists = assists;
|
|
|
+ schoolAssists.Add(schoolAssist);
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 查询区域的学校
|
|
|
- /// </summary>
|
|
|
- /// <param name="jsonElement"></param>
|
|
|
- /// <returns></returns>
|
|
|
- [ProducesDefaultResponseType]
|
|
|
- [HttpPost("get-schooldist")]
|
|
|
- public async Task<IActionResult> GetSchoolDist(JsonElement jsonElement)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- if (!jsonElement.TryGetProperty("dist", out JsonElement _dist)) return BadRequest();
|
|
|
-
|
|
|
- var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
- string sqltxt = $"SELECT * FROM c where c.dist='{_dist}'";
|
|
|
-
|
|
|
- List<School> schools = new List<School>();
|
|
|
-
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
- {
|
|
|
- schools.Add(item);
|
|
|
- }
|
|
|
|
|
|
- return Ok(new { state = 200, schools });
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- await _dingDing.SendBotMsg($"BI,{_option.Location} /batchschool/get-schooldist \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
- return BadRequest();
|
|
|
- }
|
|
|
+ return Ok(new { state = 200, schoolAssists });
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1093,7 +873,6 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
return periods;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
public record SchoolConfig
|
|
|
{
|
|
|
public string Lang { get; set; }
|
|
@@ -1139,13 +918,27 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- public class SchoolAssist : School
|
|
|
+ public class SchoolAssist
|
|
|
{
|
|
|
+ public string id { get; set; }
|
|
|
+ public string code { get; set; }
|
|
|
+ public string schoolCode { get; set; }
|
|
|
+ public string name { get; set; }
|
|
|
+ public string region { get; set; }
|
|
|
+ public string province { get; set; }
|
|
|
+ public string city { get; set; }
|
|
|
+ public string dist { get; set; }
|
|
|
+ public int size { get; set; }
|
|
|
+ public string address { get; set; }
|
|
|
+ public string picture { get; set; }
|
|
|
+ public int type { get; set; }
|
|
|
+ public int scale { get; set; }
|
|
|
+ public string standard { get; set; }
|
|
|
+ public string areaId { get; set; }
|
|
|
public List<Assist> assists { get; set; }
|
|
|
|
|
|
}
|
|
|
+
|
|
|
public class Assist
|
|
|
{
|
|
|
public string tmdId { get; set; }
|
|
@@ -1158,16 +951,6 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
/// </summary>
|
|
|
public record FoundSchools()
|
|
|
{
|
|
|
- /// <summary>
|
|
|
- ///醍摩豆账户ID
|
|
|
- /// </summary>
|
|
|
- public string tmdId { get; set; }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 醍摩豆账户名称
|
|
|
- /// </summary>
|
|
|
- public string tmdName { get; set; }
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 语系
|
|
|
/// </summary>
|