瀏覽代碼

优化钉钉权限传参数

Li 3 年之前
父節點
當前提交
ef9343e395
共有 1 個文件被更改,包括 11 次插入2 次删除
  1. 11 2
      TEAMModelBI/Controllers/DingDingStruc/TableDingDingInfoController.cs

+ 11 - 2
TEAMModelBI/Controllers/DingDingStruc/TableDingDingInfoController.cs

@@ -462,7 +462,7 @@ namespace TEAMModelBI.Controllers.DingDingStruc
             {
                 if (!jsonElement.TryGetProperty("partitionKey", out JsonElement partitionKey)) return BadRequest();
                 jsonElement.TryGetProperty("userId", out JsonElement userId);
-                if (!jsonElement.TryGetProperty("tmdId", out JsonElement tmdId)) return BadRequest();
+                jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
                 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);
@@ -474,11 +474,20 @@ namespace TEAMModelBI.Controllers.DingDingStruc
                 List<string> roles = new();//角色列表
                 List<string> permissions = new();//权限列表
                 StringBuilder stringBuilder = new($"{_tmdName}【{_tmdId}】醍摩豆账号");
-                Dictionary<string, object> dic = new() { { "PartitionKey", $"{partitionKey}" }, { "tmdId", $"{tmdId}" } };
+                Dictionary<string, object> dic = new() { { "PartitionKey", $"{partitionKey}" } };
                 if (!string.IsNullOrEmpty($"{userId}"))
                 {
                     dic.Add("userId", $"{userId}");
                 }
+                if (!string.IsNullOrEmpty($"{tmdId}"))
+                {
+                    dic.Add("tmdId", $"{tmdId}");
+                }
+
+                if (string.IsNullOrEmpty($"{userId}") && string.IsNullOrEmpty($"{tmdId}")) 
+                {
+                    return BadRequest();                
+                }
 
                 var tempUser = await table.FindListByDict<DingDingUserInfo>(dic);