|
@@ -19,6 +19,11 @@ using static TEAMModelOS.SDK.Models.Teacher;
|
|
|
using Microsoft.AspNetCore.Hosting; //引用读取文件
|
|
|
using TEAMModelOS.SDK.Models.Service;
|
|
|
using System.IO;
|
|
|
+using TEAMModelOS.SDK.Helper.Common.TableHelper;
|
|
|
+using System.Net.Http;
|
|
|
+using Microsoft.Extensions.Configuration;
|
|
|
+using System.Net.Http.Json;
|
|
|
+using System.Net;
|
|
|
|
|
|
namespace TEAMModeBI.Controllers.BISchool
|
|
|
{
|
|
@@ -31,14 +36,20 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
private readonly Option _option;
|
|
|
private readonly AzureStorageFactory _azureStorage;
|
|
|
private readonly IWebHostEnvironment _environment; //读取文件
|
|
|
+ private readonly IHttpClientFactory _http;
|
|
|
+ //读取配置信息
|
|
|
+ private readonly IConfiguration _configuration;
|
|
|
+ public readonly string mobel = "学校";
|
|
|
|
|
|
- public BatchSchoolController(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, IOptionsSnapshot<Option> option, IWebHostEnvironment hostingEnvironment)
|
|
|
+ public BatchSchoolController(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, IOptionsSnapshot<Option> option, IWebHostEnvironment hostingEnvironment, IConfiguration configuration, IHttpClientFactory http)
|
|
|
{
|
|
|
_azureCosmos = azureCosmos;
|
|
|
_dingDing = dingDing;
|
|
|
_azureStorage = azureStorage;
|
|
|
_option = option?.Value;
|
|
|
_environment = hostingEnvironment;
|
|
|
+ _configuration = configuration;
|
|
|
+ _http = http;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -124,19 +135,9 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
if (!jsonElement.TryGetProperty("tmdName", out JsonElement _tmdName)) return BadRequest();
|
|
|
List<Exist> havepower = new List<Exist>(); //已存在的
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
- //保存操作记录
|
|
|
- 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 = "/batchschool/get-quitstaff";
|
|
|
- operateLog.operateTime = DateTime.Now;
|
|
|
+
|
|
|
StringBuilder stringBuilder = new StringBuilder($"{_tmdName}【{_tmdId}】账户操作");
|
|
|
- //更新權限
|
|
|
+ //更新权限
|
|
|
foreach (var id in ids.EnumerateArray())
|
|
|
{
|
|
|
SchoolTeacher st = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<SchoolTeacher>($"{id}", new PartitionKey($"Teacher-{school_code}"));
|
|
@@ -184,14 +185,14 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<SchoolTeacher>(st, id.GetString(), new PartitionKey($"Teacher-{school_code}"));
|
|
|
}
|
|
|
|
|
|
- operateLog.operateDescribe = $"{stringBuilder}";
|
|
|
- await _azureStorage.Save<OperateLog>(operateLog); //保存操作记录
|
|
|
+ //保存操作记录
|
|
|
+ await OperateLogHelper.SaveTableLog(_azureStorage, platform: "BI", tmdId: $"{_tmdId}", tmdName: $"{_tmdName}", msg: stringBuilder?.ToString(), type: "ability-update", visitApi: "/batchschool/upd-permissions", funModel: mobel);
|
|
|
|
|
|
return Ok(new { state = 200, havepower = havepower });
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- await _dingDing.SendBotMsg($"BI,{_option.Location}, batchschool/get-quitstaff \n{ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
+ await _dingDing.SendBotMsg($"BI,{_option.Location}, /batchschool/upd-permissions \n{ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
return BadRequest();
|
|
|
}
|
|
|
}
|
|
@@ -208,17 +209,7 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
try
|
|
|
{
|
|
|
List<BISchool> schools = new List<BISchool>();
|
|
|
- //操作记录
|
|
|
- string blobOrTable = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
|
|
|
- OperateLog operateLog = new OperateLog();
|
|
|
- operateLog.PartitionKey = "OperateLog-BI";
|
|
|
- operateLog.RowKey = blobOrTable;
|
|
|
- operateLog.recordID = blobOrTable;
|
|
|
- operateLog.platformSource = "BI";
|
|
|
- operateLog.tmdId = $"{foundSchools.tmdId}";
|
|
|
- operateLog.tmdName = $"{foundSchools.tmdName}";
|
|
|
- operateLog.operateType = "新增";
|
|
|
- operateLog.funModule = "创校";
|
|
|
+
|
|
|
StringBuilder stringBuilder = new StringBuilder($"{foundSchools.tmdName}【{foundSchools.tmdId}】操作了批量创校功能:");
|
|
|
|
|
|
if (foundSchools.biSchools.Count > 0)
|
|
@@ -226,6 +217,23 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
foreach (BISchool bischool in foundSchools.biSchools)
|
|
|
{
|
|
|
+ string tempTmdId = null;
|
|
|
+ HttpClient httpClient = _http.CreateClient();
|
|
|
+ string url = _configuration.GetValue<string>("HaBookAuth:CoreId:userinfo");
|
|
|
+ List<string> mobile = new List<string>() { bischool.admin };
|
|
|
+ HttpResponseMessage responseMessage = await httpClient.PostAsJsonAsync(url, mobile);
|
|
|
+ if (responseMessage.StatusCode == HttpStatusCode.OK)
|
|
|
+ {
|
|
|
+ string temp = responseMessage.Content.ReadAsStringAsync().Result;
|
|
|
+ List<JsonElement> json_id = temp.ToObject<List<JsonElement>>();
|
|
|
+ foreach (var item in json_id)
|
|
|
+ {
|
|
|
+ tempTmdId = item.GetProperty("id").ToString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ string tmdId = !string.IsNullOrEmpty(tempTmdId) ? tempTmdId : bischool.admin;
|
|
|
+
|
|
|
CreateSchoolInfo createSchoolInfo = new CreateSchoolInfo()
|
|
|
{
|
|
|
province = bischool.province,
|
|
@@ -276,7 +284,7 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
try
|
|
|
{
|
|
|
//查询该教师是否存在
|
|
|
- teacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>($"{bischool.admin}", new PartitionKey("Base"));
|
|
|
+ teacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>($"{tmdId}", new PartitionKey("Base"));
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
@@ -285,10 +293,10 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
{
|
|
|
//教师存在,在该教师信息中添加要管理的学校信息
|
|
|
teacher.schools.Add(new Teacher.TeacherSchool { schoolId = createSchoolInfo.id, name = bischool.name, status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() });
|
|
|
- //await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, bischool.admin, new PartitionKey("Base"));
|
|
|
+ //await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, tmdId, new PartitionKey("Base"));
|
|
|
SchoolTeacher schoolTeacher = new SchoolTeacher
|
|
|
{
|
|
|
- id = bischool.admin,
|
|
|
+ id = tmdId,
|
|
|
code = $"Teacher-{createSchoolInfo.id}",
|
|
|
roles = new List<string> { "admin", "teacher" },
|
|
|
job = "管理员",
|
|
@@ -300,7 +308,7 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
ttl = -1
|
|
|
};
|
|
|
|
|
|
- stringBuilder.Append($"教师信息:{schoolTeacher.name}【{schoolTeacher.id}】,教师权限:{schoolTeacher.roles.ToString()}");
|
|
|
+ stringBuilder.Append($"教师信息:{schoolTeacher.name}【{schoolTeacher.id}】,教师权限:{string.Join(",", schoolTeacher.roles)}");
|
|
|
await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
|
|
|
await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(schoolTeacher, new PartitionKey(schoolTeacher.code));
|
|
|
}
|
|
@@ -309,7 +317,7 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
//不存在 新建教师和新建要管理的学校信息
|
|
|
Teacher addteacher = new Teacher
|
|
|
{
|
|
|
- id = bischool.admin,
|
|
|
+ id = tmdId,
|
|
|
pk = "Base",
|
|
|
code = "Base",
|
|
|
name = $"{bischool.name}-管理员"?.ToString(),
|
|
@@ -324,11 +332,11 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(addteacher, new PartitionKey("Base"));
|
|
|
SchoolTeacher schoolTeacher = new SchoolTeacher
|
|
|
{
|
|
|
- id = bischool.admin,
|
|
|
+ id = tmdId,
|
|
|
code = $"Teacher-{createSchoolInfo.id}",
|
|
|
roles = new List<string> { "admin", "teacher" },
|
|
|
job = "管理员",
|
|
|
- name = bischool.admin,
|
|
|
+ name = $"{tmdId}-管理员",
|
|
|
picture = "",
|
|
|
status = "join",
|
|
|
createTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
|
|
@@ -336,17 +344,16 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
ttl = -1
|
|
|
};
|
|
|
|
|
|
- stringBuilder.Append($"教师权限:{schoolTeacher.roles}");
|
|
|
+ stringBuilder.Append($"教师权限:{string.Join(",", schoolTeacher.roles)}");
|
|
|
await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(schoolTeacher, new PartitionKey(schoolTeacher.code));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else return Ok(new { state = 1, message = "创校信息为空" });
|
|
|
- operateLog.operateDescribe = $"{stringBuilder}";
|
|
|
- operateLog.visitApi = "/batchschool/batch-school";
|
|
|
- operateLog.operateTime = DateTime.Now;
|
|
|
- await _azureStorage.Save<OperateLog>(operateLog);
|
|
|
+
|
|
|
+ //保存操作记录
|
|
|
+ await OperateLogHelper.SaveTableLog(_azureStorage, platform: "BI", tmdId: $"{foundSchools.tmdId}", tmdName: $"{foundSchools.tmdName}", msg: stringBuilder?.ToString(), type: "school-batchAdd", visitApi: "/batchschool/batch-school", funModel: mobel);
|
|
|
|
|
|
if (schools.Count > 0)
|
|
|
return Ok(new { state = 201, message = "已有部分学校批量创建成功;学校编号已经重复!请检查学校编号!", schools = schools });
|
|
@@ -573,21 +580,8 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
|
|
|
schoolInfo = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(replaceSchool.school, replaceSchool.school.id, new PartitionKey("Base"));
|
|
|
|
|
|
- //操作记录
|
|
|
- string blobOrTable = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
|
|
|
- OperateLog operateLog = new OperateLog
|
|
|
- {
|
|
|
- PartitionKey = "OperateLog-BI",
|
|
|
- RowKey = blobOrTable,
|
|
|
- recordID = blobOrTable,
|
|
|
- platformSource = "BI",
|
|
|
- tmdId = $"{replaceSchool.tmdId}",
|
|
|
- tmdName = $"{replaceSchool.tmdName}",
|
|
|
- operateDescribe = $"{replaceSchool.tmdName}【{replaceSchool.tmdId}】已操作修改学校,修改的学校:{replaceSchool.school.name}【{replaceSchool.school.id}】",
|
|
|
- visitApi = "/batchschool/upd-school",
|
|
|
- operateTime = DateTime.Now
|
|
|
- };
|
|
|
- await _azureStorage.Save<OperateLog>(operateLog);
|
|
|
+ //保存操作记录
|
|
|
+ await OperateLogHelper.SaveTableLog(_azureStorage, platform: "BI", tmdId: $"{replaceSchool.tmdId}", tmdName: $"{replaceSchool.tmdName}", msg: $"{replaceSchool.tmdName}【{replaceSchool.tmdId}】已操作修改学校,修改的学校:{replaceSchool.school.name}【{replaceSchool.school.id}】", type: "school-update", visitApi: "/batchschool/upd-school", funModel: mobel);
|
|
|
|
|
|
return Ok(new { state = 200, schoolInfo });
|
|
|
}
|
|
@@ -627,19 +621,7 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
|
|
|
//操作记录
|
|
|
string blobOrTable = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
|
|
|
- OperateLog operateLog = new OperateLog
|
|
|
- {
|
|
|
- PartitionKey = "OperateLog-BI",
|
|
|
- RowKey = blobOrTable,
|
|
|
- recordID = blobOrTable,
|
|
|
- platformSource = "BI",
|
|
|
- tmdId = $"{_tmdId}",
|
|
|
- tmdName = $"{_tmdName}",
|
|
|
- operateDescribe = $"{_tmdName}【{_tmdId}】已操作修改学校功能,修改的学校:{_schoolId},{string.Join("|", periodS.ToArray())},{picture},{size},{string.Join("|", assistId.ToArray())}",
|
|
|
- visitApi = "batchschool/upd-schoolassist",
|
|
|
- operateTime = DateTime.Now
|
|
|
- };
|
|
|
- await _azureStorage.Save<OperateLog>(operateLog);
|
|
|
+
|
|
|
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
School tempShool = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{_schoolId}", new PartitionKey("Base"));
|
|
@@ -774,6 +756,9 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
schoolAssist.assists = assists;
|
|
|
}
|
|
|
|
|
|
+ //保存操作记录
|
|
|
+ await OperateLogHelper.SaveTableLog(_azureStorage, platform: "BI", tmdId: $"{_tmdId}", tmdName: $"{_tmdName}", msg: $"{_tmdName}【{_tmdId}】已操作修改学校功能,修改的学校:{_schoolId},{string.Join("|", periodS.ToArray())},{picture},{size},{string.Join("|", assistId.ToArray())}", type: "TeacherRoles-update", visitApi: "/batchschool/upd-schoolassist", funModel: mobel);
|
|
|
+
|
|
|
return Ok(new { state = 200, schoolAssist });
|
|
|
}
|
|
|
catch (Exception ex)
|
|
@@ -799,23 +784,11 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
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(); //醍摩豆账号名称
|
|
|
-
|
|
|
- var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
- //操作记录
|
|
|
- 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 = "/batchschool/upd-schoolPeriod ";
|
|
|
- operateLog.operateTime = DateTime.Now;
|
|
|
+
|
|
|
StringBuilder stringBuilder = new StringBuilder($"{_tmdId}【{_tmdName}】已操作新增学校的学段");
|
|
|
-
|
|
|
School school = new();
|
|
|
+
|
|
|
+ var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
try
|
|
|
{
|
|
|
school = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{_schoolCode}", new PartitionKey("Base"));
|
|
@@ -839,9 +812,9 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
|
|
|
await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(school, school.id, new PartitionKey("Base"));
|
|
|
|
|
|
- operateLog.operateDescribe = $"{stringBuilder}";
|
|
|
+ //保存操作记录
|
|
|
+ await OperateLogHelper.SaveTableLog(_azureStorage, platform: "BI", tmdId: $"{_tmdId}", tmdName: $"{_tmdName}", msg: stringBuilder?.ToString(), type: "schoolperiod-add", visitApi: "/batchschool/upd-schoolPeriod", funModel: mobel);
|
|
|
|
|
|
- await _azureStorage.Save<OperateLog>(operateLog);
|
|
|
return Ok(new { state = 200, school });
|
|
|
}
|
|
|
else return Ok(new { state = 400, school });
|
|
@@ -849,7 +822,7 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- await _dingDing.SendBotMsg($"BI,{_option.Location} /batchschool/upd-schoolPeriod \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
+ await _dingDing.SendBotMsg($"BI,{_option.Location} /batchschool/upd-schoolperiod \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
return BadRequest();
|
|
|
}
|
|
|
}
|
|
@@ -871,21 +844,6 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
if (!jsonElement.TryGetProperty("setId", out JsonElement _setId)) return BadRequest(); //修改学段的ID
|
|
|
if (!jsonElement.TryGetProperty("setName", out JsonElement _setName)) 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 = "/batchschool/set-schoolperiod";
|
|
|
- operateLog.operateTime = DateTime.Now;
|
|
|
- operateLog.operateDescribe = $"{_tmdId}【{_tmdName}】已操作修改学校学段信息,修改ID和名称:{_setId}{_setName}";
|
|
|
- await _azureStorage.Save<OperateLog>(operateLog);
|
|
|
-
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
School school = new();
|
|
|
try
|
|
@@ -899,6 +857,10 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
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 OperateLogHelper.SaveTableLog(_azureStorage, platform: "BI", tmdId: $"{_tmdId}", tmdName: $"{_tmdName}", msg: $"{_tmdId}【{_tmdName}】已操作修改学校学段信息,修改ID和名称:{_setId}{_setName}", type: "schoolperiod-update", visitApi: "/batchschool/set-schoolperiod", funModel: mobel);
|
|
|
+
|
|
|
return Ok(new { state = 200, school });
|
|
|
}
|
|
|
else return Ok(new { state = 400, school });
|
|
@@ -926,22 +888,6 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
if (!jsonElement.TryGetProperty("schooId", out JsonElement _schoolCode)) return BadRequest(); //学校编号
|
|
|
if (!jsonElement.TryGetProperty("delId", out JsonElement _delId)) return BadRequest(); //删除学段的ID
|
|
|
|
|
|
- //操作记录
|
|
|
- string blobOrTable = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
|
|
|
- OperateLog operateLog = new OperateLog
|
|
|
- {
|
|
|
- PartitionKey = "OperateLog-BI",
|
|
|
- RowKey = blobOrTable,
|
|
|
- recordID = blobOrTable,
|
|
|
- platformSource = "BI",
|
|
|
- tmdId = $"{_tmdId}",
|
|
|
- tmdName = $"{_tmdName}",
|
|
|
- visitApi = "/batchschool/del-schoolperiod",
|
|
|
- operateTime = DateTime.Now,
|
|
|
- operateDescribe = $"{_tmdId}【{_tmdName}】已操作删除学校的学段,删除学段ID和名称:{_delId}"
|
|
|
- };
|
|
|
- await _azureStorage.Save<OperateLog>(operateLog);
|
|
|
-
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
School school = new();
|
|
|
try
|
|
@@ -955,6 +901,9 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
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"));
|
|
|
|
|
|
+ //保存操作记录
|
|
|
+ await OperateLogHelper.SaveTableLog(_azureStorage, platform: "BI", tmdId: $"{_tmdId}", tmdName: $"{_tmdName}", msg: $"{_tmdId}【{_tmdName}】已操作删除学校的学段,删除学段ID和名称:{_delId}", type: "schoolperiod-del", visitApi: "/batchschool/del-schoolperiod", funModel: mobel);
|
|
|
+
|
|
|
return Ok(new { state = 200, school });
|
|
|
}
|
|
|
else return Ok(new { state = 400, school });
|
|
@@ -988,20 +937,8 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
jsonElement.TryGetProperty("setName", out JsonElement _setName); //修改学段的名称
|
|
|
jsonElement.TryGetProperty("delId", out JsonElement _delId); //删除学段的ID
|
|
|
|
|
|
-
|
|
|
- //操作记录
|
|
|
- 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 = "/batchschool/set-schoolperiodinfo";
|
|
|
- operateLog.operateTime = DateTime.Now;
|
|
|
StringBuilder stringBuilder = new StringBuilder($"{_tmdId}【{_tmdName}】已操作");
|
|
|
-
|
|
|
+ string tempType = null;
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
|
|
|
School school = new();
|
|
@@ -1023,6 +960,7 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
{
|
|
|
school.period.Add(new Period { id = Guid.NewGuid().ToString(), name = $"{_periodName}", campusId = $"{_campusId}" });
|
|
|
stringBuilder.Append($"新增学校学段,在原有校区中添加学段:学段ID:{_campusId}学段名称:{_periodName}");
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -1032,25 +970,30 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
|
|
|
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参数错误" });
|
|
|
}
|
|
|
- operateLog.operateDescribe = $"{stringBuilder}";
|
|
|
- await _azureStorage.Save<OperateLog>(operateLog);
|
|
|
+
|
|
|
+ //保存操作记录
|
|
|
+ await OperateLogHelper.SaveTableLog(_azureStorage, platform: "BI", tmdId: $"{_tmdId}", tmdName: $"{_tmdName}", msg: stringBuilder?.ToString(), type: tempType?.ToString(), visitApi: "/batchschool/set-schoolperiodinfo", funModel: mobel);
|
|
|
|
|
|
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 });
|