|
@@ -26,6 +26,7 @@ using TEAMModelBI.Tool.Extension;
|
|
|
using TEAMModelBI.Models;
|
|
|
using TEAMModelBI.Tool.CosmosBank;
|
|
|
using TEAMModelBI.Tool.Context;
|
|
|
+using TEAMModelBI.DI.BIAzureStorage;
|
|
|
|
|
|
namespace TEAMModelBI.Controllers.DingDingStruc
|
|
|
{
|
|
@@ -59,18 +60,21 @@ namespace TEAMModelBI.Controllers.DingDingStruc
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
- [AuthToken(Roles = "admin")]
|
|
|
+ [AuthToken(Roles = "admin,rdc")]
|
|
|
[HttpPost("get-dingdingusers")]
|
|
|
public async Task<IActionResult> GetDingDingUser(JsonElement jsonElement)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
- var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
|
|
|
+ var tableClient = _azureStorage.GetCloudTableClient();
|
|
|
+ var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
|
|
|
if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
{
|
|
|
- table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("BIDDUserInfo");
|
|
|
+ tableClient = _azureStorage.GetCloudTableClient(BIConst.GlobalSite);
|
|
|
+ blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public", BIConst.GlobalSite);
|
|
|
}
|
|
|
+ var table = tableClient.GetTableReference("BIDDUserInfo");
|
|
|
|
|
|
string appKey = _configuration["DingDingAuth:appKey"];
|
|
|
string appSecret = _configuration["DingDingAuth:appSecret"];
|
|
@@ -171,8 +175,8 @@ namespace TEAMModelBI.Controllers.DingDingStruc
|
|
|
}
|
|
|
|
|
|
//保存操作记录
|
|
|
- await _azureStorage.SaveBILog("tabledd-update", $"{_tmdName}【{_tmdId}】从钉钉组织结构更新至Azure Table表【DDUserInfo】中。", _dingDing, httpContext: HttpContext);
|
|
|
-
|
|
|
+ //await _azureStorage.SaveBILog("tabledd-update", $"{_tmdName}【{_tmdId}】从钉钉组织结构更新至Azure Table表【DDUserInfo】中。", _dingDing, httpContext: HttpContext);
|
|
|
+ await BIAzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "tabledd-update", $"{_tmdName}【{_tmdId}】从钉钉组织结构更新至Azure Table表【DDUserInfo】中。", _dingDing, httpContext: HttpContext);
|
|
|
var tempddUserInfos = ddUserInfos.GroupBy(c => c.userId).Select(c => c.First()).ToList();//去重
|
|
|
//List<DingDingUserInfo> TempdingDingUserInfos = await _azureStorage.SaveOrUpdateAll(dingDingUserInfos); //只是保存至Table
|
|
|
//查询数据的数据 并和钉钉查询的数据对比,找出不同的数据,并删除 待后期测试
|
|
@@ -328,18 +332,21 @@ namespace TEAMModelBI.Controllers.DingDingStruc
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
- [AuthToken(Roles = "admin,assist")]
|
|
|
+ [AuthToken(Roles = "admin,rdc")]
|
|
|
[HttpPost("set-ddinductionuser")]
|
|
|
public async Task<IActionResult> SetDingDingInductionUser(JsonElement jsonElement)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
- var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
|
|
|
+ var tableClient = _azureStorage.GetCloudTableClient();
|
|
|
+ var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
|
|
|
if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
{
|
|
|
- table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("BIDDUserInfo");
|
|
|
+ tableClient = _azureStorage.GetCloudTableClient(BIConst.GlobalSite);
|
|
|
+ blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public", BIConst.GlobalSite);
|
|
|
}
|
|
|
+ var table = tableClient.GetTableReference("BIDDUserInfo");
|
|
|
|
|
|
string appKey = _configuration["DingDingAuth:appKey"];
|
|
|
string appSecret = _configuration["DingDingAuth:appSecret"];
|
|
@@ -379,8 +386,8 @@ namespace TEAMModelBI.Controllers.DingDingStruc
|
|
|
List<DingDingUserInfo> tempddUserInfos = await table.SaveAll(ddUserInfos);
|
|
|
|
|
|
//保存操作记录
|
|
|
- await _azureStorage.SaveBILog("tabledd-add", $"{_tmdName}【{_tmdId}】添加待入职员工至table数据表中", _dingDing, httpContext: HttpContext);
|
|
|
-
|
|
|
+ //await _azureStorage.SaveBILog("tabledd-add", $"{_tmdName}【{_tmdId}】添加待入职员工至table数据表中", _dingDing, httpContext: HttpContext);
|
|
|
+ await BIAzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "tabledd-add", $"{_tmdName}【{_tmdId}】添加待入职员工至table数据表中", _dingDing, httpContext: HttpContext);
|
|
|
if (ddUserInfos.Count == tempddUserInfos.Count)
|
|
|
{
|
|
|
return Ok(new { state = 200, UserInfo = tempddUserInfos });
|
|
@@ -408,18 +415,21 @@ namespace TEAMModelBI.Controllers.DingDingStruc
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
- [AuthToken(Roles = "admin,assist")]
|
|
|
+ [AuthToken(Roles = "admin,rdc")]
|
|
|
[HttpPost("del-ddquituser")]
|
|
|
public async Task<IActionResult> DeleteDDQuitUser(JsonElement jsonElement)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
- var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
|
|
|
+ var tableClient = _azureStorage.GetCloudTableClient();
|
|
|
+ var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
|
|
|
if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
{
|
|
|
- table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("BIDDUserInfo");
|
|
|
+ tableClient = _azureStorage.GetCloudTableClient(BIConst.GlobalSite);
|
|
|
+ blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public", BIConst.GlobalSite);
|
|
|
}
|
|
|
+ var table = tableClient.GetTableReference("BIDDUserInfo");
|
|
|
|
|
|
string appKey = _configuration["DingDingAuth:appKey"];
|
|
|
string appSecret = _configuration["DingDingAuth:appSecret"];
|
|
@@ -453,8 +463,8 @@ namespace TEAMModelBI.Controllers.DingDingStruc
|
|
|
}
|
|
|
|
|
|
//保存操作记录
|
|
|
- await _azureStorage.SaveBILog("tabledd-del", $"{_tmdName}【{_tmdId}】从table数据表中删除离职员工", _dingDing, httpContext: HttpContext);
|
|
|
-
|
|
|
+ //await _azureStorage.SaveBILog("tabledd-del", $"{_tmdName}【{_tmdId}】从table数据表中删除离职员工", _dingDing, httpContext: HttpContext);
|
|
|
+ await BIAzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "tabledd-del", $"{_tmdName}【{_tmdId}】从table数据表中删除离职员工", _dingDing, httpContext: HttpContext);
|
|
|
return Ok(new { state = 200 });
|
|
|
}
|
|
|
else
|
|
@@ -476,7 +486,7 @@ namespace TEAMModelBI.Controllers.DingDingStruc
|
|
|
/// <param name="jsonElement"></param>
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
- [AuthToken(Roles = "admin")]
|
|
|
+ [AuthToken(Roles = "admin,rdc")]
|
|
|
[HttpPost("set-rolesper")]
|
|
|
public async Task<IActionResult> SetPermissions(JsonElement jsonElement)
|
|
|
{
|
|
@@ -489,11 +499,15 @@ namespace TEAMModelBI.Controllers.DingDingStruc
|
|
|
if (!jsonElement.TryGetProperty("roles", out JsonElement _roles)) return BadRequest();
|
|
|
jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
|
|
|
- var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
|
|
|
+ var tableClient = _azureStorage.GetCloudTableClient();
|
|
|
+ var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
|
|
|
if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
{
|
|
|
- table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("BIDDUserInfo");
|
|
|
+ tableClient = _azureStorage.GetCloudTableClient(BIConst.GlobalSite);
|
|
|
+ blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public", BIConst.GlobalSite);
|
|
|
}
|
|
|
+
|
|
|
+ var table = tableClient.GetTableReference("BIDDUserInfo");
|
|
|
var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
|
|
|
|
|
|
List<DingDingUserInfo> ddUserInfo = new();
|
|
@@ -535,8 +549,8 @@ namespace TEAMModelBI.Controllers.DingDingStruc
|
|
|
ddUserInfo = await table.UpdateAll<DingDingUserInfo>(ddUserInfo);
|
|
|
|
|
|
//保存操作记录
|
|
|
- await _azureStorage.SaveBILog("tabledd-update", stringBuilder?.ToString(), _dingDing, httpContext: HttpContext);
|
|
|
-
|
|
|
+ //await _azureStorage.SaveBILog("tabledd-update", stringBuilder?.ToString(), _dingDing, httpContext: HttpContext);
|
|
|
+ await BIAzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "tabledd-update", stringBuilder?.ToString(), _dingDing, httpContext: HttpContext);
|
|
|
return Ok(new { state = 200, ddUserInfo, roles, permissions });
|
|
|
}
|
|
|
catch (Exception ex)
|
|
@@ -557,16 +571,20 @@ namespace TEAMModelBI.Controllers.DingDingStruc
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- var cosmosCliet = _azureCosmos.GetCosmosClient();
|
|
|
if (!jsonElement.TryGetProperty("deptId", out JsonElement deptId)) return BadRequest();
|
|
|
jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
|
|
|
- var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
|
|
|
+ var cosmosCliet = _azureCosmos.GetCosmosClient();
|
|
|
+ var tableClient = _azureStorage.GetCloudTableClient();
|
|
|
+ var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
|
|
|
if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
{
|
|
|
- table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("BIDDUserInfo");
|
|
|
cosmosCliet = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
|
|
|
+ tableClient = _azureStorage.GetCloudTableClient(BIConst.GlobalSite);
|
|
|
+ blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public", BIConst.GlobalSite);
|
|
|
};
|
|
|
+
|
|
|
+ var table = tableClient.GetTableReference("BIDDUserInfo");
|
|
|
//string divide = _configuration["CustomParam:SiteScope"];
|
|
|
string divide = _option.Location;
|
|
|
Dictionary<string, object> dic = new Dictionary<string, object> { { "PartitionKey", $"{divide}" } };
|
|
@@ -703,7 +721,7 @@ namespace TEAMModelBI.Controllers.DingDingStruc
|
|
|
/// <param name="jsonElement"></param>
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
- [AuthToken(Roles = "admin,assist")]
|
|
|
+ [AuthToken(Roles = "admin,rdc")]
|
|
|
[HttpPost("set-backenbind")]
|
|
|
public async Task<IActionResult> SetBackenBind(JsonElement jsonElement)
|
|
|
{
|
|
@@ -714,12 +732,17 @@ namespace TEAMModelBI.Controllers.DingDingStruc
|
|
|
jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
|
|
|
var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
|
|
|
- var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
|
|
|
+
|
|
|
+ var tableClient = _azureStorage.GetCloudTableClient();
|
|
|
+ var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
|
|
|
if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
{
|
|
|
- table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("BIDDUserInfo");
|
|
|
+ tableClient = _azureStorage.GetCloudTableClient(BIConst.GlobalSite);
|
|
|
+ blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public", BIConst.GlobalSite);
|
|
|
}
|
|
|
|
|
|
+ var table = tableClient.GetTableReference("BIDDUserInfo");
|
|
|
+
|
|
|
List<DingDingUserInfo> tempddUsers = null;
|
|
|
List<DingDingUserInfo> ddUsers = new();
|
|
|
StringBuilder tableSql = new();
|
|
@@ -777,8 +800,8 @@ namespace TEAMModelBI.Controllers.DingDingStruc
|
|
|
if (ddUsers.Count > 0) ddUsers = await table.SaveOrUpdateAll(ddUsers);
|
|
|
|
|
|
//保存操作记录
|
|
|
- await _azureStorage.SaveBILog("tabledd-update", $"{_tmdName}【{_tmdId}】操作:绑定钉钉账户[{rowKey}]和醍摩豆账户[{tmdId}]", _dingDing, httpContext: HttpContext);
|
|
|
-
|
|
|
+ //await _azureStorage.SaveBILog("tabledd-update", $"{_tmdName}【{_tmdId}】操作:绑定钉钉账户[{rowKey}]和醍摩豆账户[{tmdId}]", _dingDing, httpContext: HttpContext);
|
|
|
+ await BIAzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "tabledd-update", $"{_tmdName}【{_tmdId}】操作:绑定钉钉账户[{rowKey}]和醍摩豆账户[{tmdId}]", _dingDing, httpContext: HttpContext);
|
|
|
return Ok(new { state = 200, ddUsers });
|
|
|
}
|
|
|
catch (Exception ex)
|
|
@@ -794,7 +817,7 @@ namespace TEAMModelBI.Controllers.DingDingStruc
|
|
|
/// <param name="jsonElement"></param>
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
- [AuthToken(Roles = "admin")]
|
|
|
+ [AuthToken(Roles = "admin,rdc")]
|
|
|
[HttpPost("set-backend")]
|
|
|
public async Task<IActionResult> SetBackendAdmin(JsonElement jsonElement)
|
|
|
{
|
|
@@ -805,11 +828,18 @@ namespace TEAMModelBI.Controllers.DingDingStruc
|
|
|
if (!jsonElement.TryGetProperty("isAdmin", out JsonElement isAdmin)) return BadRequest();
|
|
|
jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
|
|
|
- var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
|
|
|
+
|
|
|
+
|
|
|
+ var tableClient = _azureStorage.GetCloudTableClient();
|
|
|
+ var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
|
|
|
if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
{
|
|
|
- table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("BIDDUserInfo");
|
|
|
+ tableClient = _azureStorage.GetCloudTableClient(BIConst.GlobalSite);
|
|
|
+ blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public", BIConst.GlobalSite);
|
|
|
}
|
|
|
+
|
|
|
+ var table = tableClient.GetTableReference("BIDDUserInfo");
|
|
|
+
|
|
|
var tempUser = await table.FindListByDict<DingDingUserInfo>(new Dictionary<string, object> { { "PartitionKey", $"{partitionKey}" }, { "RowKey", $"{rowKey}" } });
|
|
|
|
|
|
List<DDUserInfo> ddUserInfos = new();
|
|
@@ -879,8 +909,8 @@ namespace TEAMModelBI.Controllers.DingDingStruc
|
|
|
}
|
|
|
|
|
|
//保存操作记录
|
|
|
- await _azureStorage.SaveBILog("tabledd-update", msg.ToString(), _dingDing, httpContext: HttpContext);
|
|
|
-
|
|
|
+ //await _azureStorage.SaveBILog("tabledd-update", msg.ToString(), _dingDing, httpContext: HttpContext);
|
|
|
+ await BIAzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "tabledd-update", msg.ToString(), _dingDing, httpContext: HttpContext);
|
|
|
return Ok(new { state = 200, roles });
|
|
|
|
|
|
}
|
|
@@ -898,7 +928,7 @@ namespace TEAMModelBI.Controllers.DingDingStruc
|
|
|
/// <param name="jsonElement"></param>
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
- [AuthToken(Roles = "admin")]
|
|
|
+ [AuthToken(Roles = "admin,rdc")]
|
|
|
[HttpPost("set-tmdadmin")]
|
|
|
public async Task<IActionResult> SetTmdBackendAdmin(JsonElement jsonElement)
|
|
|
{
|
|
@@ -912,13 +942,16 @@ namespace TEAMModelBI.Controllers.DingDingStruc
|
|
|
jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
|
|
|
var cosmosCliet = _azureCosmos.GetCosmosClient();
|
|
|
- var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
|
|
|
+
|
|
|
+ var tableClient = _azureStorage.GetCloudTableClient();
|
|
|
+ var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
|
|
|
if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
{
|
|
|
cosmosCliet = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
|
|
|
- table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("BIDDUserInfo");
|
|
|
+ tableClient = _azureStorage.GetCloudTableClient(BIConst.GlobalSite);
|
|
|
+ blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public", BIConst.GlobalSite);
|
|
|
}
|
|
|
-
|
|
|
+ var table = tableClient.GetTableReference("BIDDUserInfo");
|
|
|
|
|
|
List<DDUserInfo> ddUserInfos = new();
|
|
|
List<string> roles = new();//角色列表
|
|
@@ -1032,8 +1065,8 @@ namespace TEAMModelBI.Controllers.DingDingStruc
|
|
|
}
|
|
|
|
|
|
//保存操作记录
|
|
|
- await _azureStorage.SaveBILog("tabledd-update",msg.ToString(), _dingDing, httpContext: HttpContext);
|
|
|
-
|
|
|
+ //await _azureStorage.SaveBILog("tabledd-update",msg.ToString(), _dingDing, httpContext: HttpContext);
|
|
|
+ await BIAzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "tabledd-update", msg.ToString(), _dingDing, httpContext: HttpContext);
|
|
|
return Ok(new { state = 200, ddUserInfos });
|
|
|
}
|
|
|
catch (Exception ex)
|