|
@@ -453,38 +453,40 @@ namespace TEAMModelBI.Controllers.DingDingStruc
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
[ProducesDefaultResponseType]
|
|
[ProducesDefaultResponseType]
|
|
[AuthToken(Roles = "admin")]
|
|
[AuthToken(Roles = "admin")]
|
|
- [HttpPost("set-permissions")]
|
|
|
|
|
|
+ [HttpPost("set-rolesper")]
|
|
public async Task<IActionResult> SetPermissions(JsonElement jsonElement)
|
|
public async Task<IActionResult> SetPermissions(JsonElement jsonElement)
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
if (!jsonElement.TryGetProperty("partitionKey", out JsonElement partitionKey)) return BadRequest();
|
|
if (!jsonElement.TryGetProperty("partitionKey", out JsonElement partitionKey)) return BadRequest();
|
|
- if (!jsonElement.TryGetProperty("rowKey", out JsonElement userId)) return BadRequest();
|
|
|
|
|
|
+ jsonElement.TryGetProperty("userId", out JsonElement userId);
|
|
|
|
+ if (!jsonElement.TryGetProperty("tmdId", out JsonElement tmdId)) return BadRequest();
|
|
if (!jsonElement.TryGetProperty("permissions", out JsonElement _permissions)) return BadRequest();
|
|
if (!jsonElement.TryGetProperty("permissions", out JsonElement _permissions)) return BadRequest();
|
|
|
|
+ if (!jsonElement.TryGetProperty("roles", out JsonElement _roles)) return BadRequest();
|
|
var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
|
|
var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
|
|
|
|
|
|
var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
|
|
var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
|
|
- StringBuilder stringBuilder = new($"{_tmdName}【{_tmdId}】醍摩豆账号");
|
|
|
|
List<DingDingUserInfo> ddUserInfo = new();
|
|
List<DingDingUserInfo> ddUserInfo = new();
|
|
- var tempUser = await table.FindListByDict<DingDingUserInfo>(new Dictionary<string, object> { { "PartitionKey", $"{partitionKey}" }, { "RowKey", $"{userId}" } });
|
|
|
|
List<string> listper = _permissions.ToObject<List<string>>();
|
|
List<string> listper = _permissions.ToObject<List<string>>();
|
|
|
|
+ List<string> listroles = _roles.ToObject<List<string>>();
|
|
List<string> roles = new();//角色列表
|
|
List<string> roles = new();//角色列表
|
|
- List<string> permissions = new ();//权限列表
|
|
|
|
|
|
+ List<string> permissions = new();//权限列表
|
|
|
|
+ StringBuilder stringBuilder = new($"{_tmdName}【{_tmdId}】醍摩豆账号");
|
|
|
|
+ Dictionary<string, object> dic = new() { { "PartitionKey", $"{partitionKey}" }, { "tmdId", $"{tmdId}" } };
|
|
|
|
+ if (!string.IsNullOrEmpty($"{userId}"))
|
|
|
|
+ {
|
|
|
|
+ dic.Add("userId", $"{userId}");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var tempUser = await table.FindListByDict<DingDingUserInfo>(dic);
|
|
|
|
|
|
foreach (var item in tempUser)
|
|
foreach (var item in tempUser)
|
|
{
|
|
{
|
|
stringBuilder.Append($"操作醍摩豆账户{item.tmdName}【{item.tmdId}】修改权限:{string.Join("|", listper.ToArray())}");
|
|
stringBuilder.Append($"操作醍摩豆账户{item.tmdName}【{item.tmdId}】修改权限:{string.Join("|", listper.ToArray())}");
|
|
- if (string.IsNullOrEmpty($"{item.roles}"))
|
|
|
|
- {
|
|
|
|
- item.roles = "assist";
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ item.roles = listroles.Count > 0 ? string.Join(",", listroles) : "assist";
|
|
|
|
+ item.permissions = string.Join(",", listper);
|
|
|
|
|
|
- string tempPermissions = "";
|
|
|
|
- foreach (var itemPer in listper)
|
|
|
|
- {
|
|
|
|
- tempPermissions += !string.IsNullOrEmpty($"{tempPermissions}") ? $",{itemPer}" : $"{itemPer}";
|
|
|
|
- }
|
|
|
|
- item.permissions = tempPermissions;
|
|
|
|
ddUserInfo.Add(item);
|
|
ddUserInfo.Add(item);
|
|
|
|
|
|
roles = !string.IsNullOrEmpty($"{item.roles}") ? new List<string>(item.roles.Split(",")) : new List<string>();
|
|
roles = !string.IsNullOrEmpty($"{item.roles}") ? new List<string>(item.roles.Split(",")) : new List<string>();
|