|
@@ -7,10 +7,12 @@ using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text.Json;
|
|
|
using System.Threading.Tasks;
|
|
|
+using TEAMModeBI.Filter;
|
|
|
using TEAMModelOS.Models;
|
|
|
using TEAMModelOS.SDK.DI;
|
|
|
using TEAMModelOS.SDK.Extension;
|
|
|
using TEAMModelOS.SDK.Models;
|
|
|
+using TEAMModelOS.SDK.Models.Cosmos.BI;
|
|
|
|
|
|
namespace TEAMModeBI.Controllers.BISchool
|
|
|
{
|
|
@@ -78,6 +80,52 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 学校移出区域
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="jsonElement"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("set-areashiftschool")]
|
|
|
+ //[AuthToken(Roles = "assist")]
|
|
|
+ public async Task<IActionResult> SetAreaShiftSchool(JsonElement jsonElement)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (!jsonElement.TryGetProperty("tmdId", out JsonElement _tmdId)) return BadRequest(); //醍摩豆账户
|
|
|
+ if (!jsonElement.TryGetProperty("tmdName", out JsonElement _tmdName)) return BadRequest(); //醍摩豆账号名称
|
|
|
+ //if (!jsonElement.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
|
|
|
+ if (!jsonElement.TryGetProperty("schoolId", out JsonElement schoolId)) return BadRequest();
|
|
|
+
|
|
|
+ //操作记录
|
|
|
+ OperateLog operateLog = new OperateLog();
|
|
|
+ string blobOrTable = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
|
|
|
+ operateLog.PartitionKey = "OperateLog-BI";
|
|
|
+ operateLog.RowKey = blobOrTable;
|
|
|
+ operateLog.recordID = blobOrTable;
|
|
|
+ operateLog.platformSource = "BI";
|
|
|
+ operateLog.tmdId = $"{_tmdId}";
|
|
|
+ operateLog.tmdName = $"{_tmdName}";
|
|
|
+ operateLog.visitApi = "/tabledd/set-permissions";
|
|
|
+ operateLog.operateTime = DateTime.Now;
|
|
|
+ operateLog.operateDescribe = $"{_tmdName}【{_tmdId}】已操作学校({schoolId})移除该区域";
|
|
|
+
|
|
|
+ var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
+ School tempSchool = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{schoolId}", new PartitionKey("Base"));
|
|
|
+
|
|
|
+ tempSchool.areaId = null;
|
|
|
+ tempSchool.standard = null;
|
|
|
+
|
|
|
+ School school = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(tempSchool, tempSchool.id, new PartitionKey("Base"));
|
|
|
+
|
|
|
+ return Ok(new { state = 200, school });
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ await _dingDing.SendBotMsg($"BI, {_option.Location} /area/set-areashiftschool \n {ex.Message}{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
|
|
|
+ return BadRequest();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 已加入区域的学校
|