|
@@ -31,6 +31,138 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
_option = option?.Value;
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 获取BI权限列表
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("get-teacher-authoritybilist")]
|
|
|
+ public async Task<IActionResult> GetAuthorityBIList()
|
|
|
+ {
|
|
|
+ Dictionary<string, object> dic = new Dictionary<string, object> { { "PartitionKey", "authority-bi" } };
|
|
|
+ List<Authority> authorityBIList = await _azureStorage.FindListByDict<Authority>(dic);
|
|
|
+
|
|
|
+ return Ok(new { authorityBIList });
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 通过教师的id和学校的code查询权限
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="jsonElement"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("get-teacherroles")]
|
|
|
+ public async Task<IActionResult> GetTeacherRoles(JsonElement jsonElement)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (!jsonElement.TryGetProperty("id", out JsonElement id)) return Ok(new { state = 1, message = "参数错误!" });
|
|
|
+ if (!jsonElement.TryGetProperty("schoolcode", out JsonElement schoolcode)) return Ok(new { state = 1, message = "参数错误!" });
|
|
|
+
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ string sqltxt = $"select * from c where c.id='{id}'";
|
|
|
+
|
|
|
+ List<string> roles = new List<string>();//角色列表
|
|
|
+ List<string> permissions = new List<string>();//权限列表
|
|
|
+
|
|
|
+ var schoolRoles = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{id}", new PartitionKey($"Teacher-{schoolcode}"));
|
|
|
+ if (schoolRoles.Status == 200)
|
|
|
+ {
|
|
|
+ using var json = await JsonDocument.ParseAsync(schoolRoles.ContentStream);
|
|
|
+ if (json.RootElement.TryGetProperty("roles", out JsonElement _roles) && _roles.ValueKind != JsonValueKind.Null)
|
|
|
+ {
|
|
|
+ foreach (var obj in _roles.EnumerateArray())
|
|
|
+ {
|
|
|
+ roles.Add(obj.GetString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (json.RootElement.TryGetProperty("permissions", out JsonElement _permissions) && _permissions.ValueKind != JsonValueKind.Null)
|
|
|
+ {
|
|
|
+ foreach (var obj in _permissions.EnumerateArray())
|
|
|
+ {
|
|
|
+ permissions.Add(obj.GetString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return Ok(new { state = 200, roles = roles, permissions = permissions });
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ await _dingDing.SendBotMsg($"BI,{_option.Location},batchchool/get-quitstaff \n{ex.Message}{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
|
|
|
+ return BadRequest();
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 依据传输的数据更新和删除权限
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="jsonElement"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("get-permissions")]
|
|
|
+ public async Task<IActionResult> SetSchoolPermissions(JsonElement jsonElement)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (!jsonElement.TryGetProperty("ids", out JsonElement ids)) return Ok(new { state = 1, message = "ids参数错误!" });
|
|
|
+ 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参数错误!" });
|
|
|
+
|
|
|
+ List<reoleds> havepower = new List<reoleds>(); //已存在的权限
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+
|
|
|
+ //更新權限
|
|
|
+ foreach (var id in ids.EnumerateArray())
|
|
|
+ {
|
|
|
+ SchoolTeacher st = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<SchoolTeacher>($"{id}", new PartitionKey($"Teacher-{school_code}"));
|
|
|
+
|
|
|
+ if (mode.GetString().Equals("del"))
|
|
|
+ {
|
|
|
+ foreach (var pm in paramPower.EnumerateArray())
|
|
|
+ {
|
|
|
+ var bools = st.permissions.Find(x => x.Equals($"{pm}"));
|
|
|
+ if (!string.IsNullOrEmpty($"{bools}"))
|
|
|
+ {
|
|
|
+ st.permissions.RemoveAll(x => x.Equals($"{bools}"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (mode.GetString().Equals("up"))
|
|
|
+ {
|
|
|
+ var stes = st.roles.Find(x => x.Equals("assistant"));
|
|
|
+ if (string.IsNullOrEmpty($"{stes}"))
|
|
|
+ {
|
|
|
+ st.roles.Add("assistant");
|
|
|
+ }
|
|
|
+ foreach (var pm in paramPower.EnumerateArray())
|
|
|
+ {
|
|
|
+ var bools = st.permissions.Find(x => x.Equals($"{pm}"));
|
|
|
+ if (!string.IsNullOrEmpty($"{bools}"))
|
|
|
+ {
|
|
|
+ havepower.Add(new reoleds { ID = id.GetString(), relos = bools });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ st.permissions.Add(pm.GetString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else { return Ok(new { state = 1, message = "mode参数错误!" }); }
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<SchoolTeacher>(st, id.GetString(), new PartitionKey($"Teacher-{school_code}"));
|
|
|
+ }
|
|
|
+ return Ok(new { state = 200, havepower = havepower });
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ await _dingDing.SendBotMsg($"BI,{_option.Location},batchchool/get-quitstaff \n{ex.Message}{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
|
|
|
+ return BadRequest();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 批量创校 --完成带测验
|
|
|
/// </summary>
|
|
@@ -38,7 +170,7 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpPost("batchUpsert")]
|
|
|
- public async Task<IActionResult> batchUpsert(School school,string number)
|
|
|
+ public async Task<IActionResult> batchUpsert(School school, string number)
|
|
|
{
|
|
|
List<School> school_list = new List<School>();
|
|
|
//创建多个学校
|
|
@@ -75,7 +207,7 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
{
|
|
|
school.code = "Base";
|
|
|
school.id = $"{school.id}_{i}";
|
|
|
- school = await schoolContainer.CreateItemAsync(school,new PartitionKey($"Base"));
|
|
|
+ school = await schoolContainer.CreateItemAsync(school, new PartitionKey($"Base"));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -115,69 +247,12 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
}
|
|
|
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 获取BI权限列表
|
|
|
- /// </summary>
|
|
|
- /// <returns></returns>
|
|
|
- [ProducesDefaultResponseType]
|
|
|
- [HttpPost("get-teacher-authoritybilist")]
|
|
|
- public async Task<IActionResult> GetAuthorityBIList()
|
|
|
- {
|
|
|
- Dictionary<string, object> dic = new Dictionary<string, object> { { "PartitionKey", "authority-bi" } };
|
|
|
- List<Authority> authorityBIList = await _azureStorage.FindListByDict<Authority>(dic);
|
|
|
|
|
|
- return Ok(new { authorityBIList });
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 通过教师的id和学校的code查询权限
|
|
|
- /// </summary>
|
|
|
- /// <param name="jsonElement"></param>
|
|
|
- /// <returns></returns>
|
|
|
- [ProducesDefaultResponseType]
|
|
|
- [HttpPost("get-teacherroles")]
|
|
|
- public async Task<IActionResult> GetTeacherRoles(JsonElement jsonElement)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- if (!jsonElement.TryGetProperty("id", out JsonElement id)) return Ok(new { state = 1, message = "参数错误!" });
|
|
|
- if (!jsonElement.TryGetProperty("schoolcode", out JsonElement schoolcode)) return Ok(new { state = 1, message = "参数错误!" });
|
|
|
-
|
|
|
- var client = _azureCosmos.GetCosmosClient();
|
|
|
- string sqltxt = $"select * from c where c.id='{id}'";
|
|
|
-
|
|
|
- List<string> roles = new List<string>();//角色列表
|
|
|
- List<string> permissions = new List<string>();//权限列表
|
|
|
-
|
|
|
- var schoolRoles = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{id}", new PartitionKey($"Teacher-{schoolcode}"));
|
|
|
- if (schoolRoles.Status == 200)
|
|
|
- {
|
|
|
- using var json = await JsonDocument.ParseAsync(schoolRoles.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("roles", out JsonElement _roles) && _roles.ValueKind != JsonValueKind.Null)
|
|
|
- {
|
|
|
- foreach (var obj in _roles.EnumerateArray())
|
|
|
- {
|
|
|
- roles.Add(obj.GetString());
|
|
|
- }
|
|
|
- }
|
|
|
- if (json.RootElement.TryGetProperty("permissions", out JsonElement _permissions) && _permissions.ValueKind != JsonValueKind.Null)
|
|
|
- {
|
|
|
- foreach (var obj in _permissions.EnumerateArray())
|
|
|
- {
|
|
|
- permissions.Add(obj.GetString());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return Ok(new { state = 200, roles = roles, permissions = permissions });
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- await _dingDing.SendBotMsg($"BI,{_option.Location},batchchool/get-quitstaff \n{ex.Message}{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
|
|
|
- return BadRequest();
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
+ public record reoleds()
|
|
|
+ {
|
|
|
+ public string ID { get; set; }
|
|
|
+ public string relos { get; set; }
|
|
|
}
|
|
|
|
|
|
|