|
@@ -166,44 +166,33 @@ namespace TEAMModelBI.Controllers
|
|
{
|
|
{
|
|
if (string.IsNullOrEmpty(item.tmdId))
|
|
if (string.IsNullOrEmpty(item.tmdId))
|
|
{
|
|
{
|
|
- List<string> mobiles = new() { $"{ item.mobile}" };
|
|
|
|
- var content = new StringContent(mobiles.ToJsonString(), Encoding.UTF8, "application/json");
|
|
|
|
- string json = await _coreAPIHttpService.GetUserInfos(content);
|
|
|
|
- if (!string.IsNullOrEmpty(json))
|
|
|
|
|
|
+ var coreUser = await _coreAPIHttpService.GetUserInfo(new Dictionary<string, string> { { "key", $"{item.mobile}" } }, _option.Location, _configuration);
|
|
|
|
+ if (coreUser.id != null)
|
|
{
|
|
{
|
|
- List<JsonElement> json_id = json.ToObject<List<JsonElement>>();
|
|
|
|
- foreach (var tmd in json_id)
|
|
|
|
- {
|
|
|
|
- item.tmdId = tmd.GetProperty("id").ToString();
|
|
|
|
- item.tmdName = tmd.GetProperty("name").ToString();
|
|
|
|
- item.tmdMobile = tmd.GetProperty("mobile").ToString();
|
|
|
|
- item.picture = tmd.GetProperty("picture").ToString();
|
|
|
|
- item.mail = tmd.GetProperty("mail").ToString();
|
|
|
|
- }
|
|
|
|
|
|
+ item.tmdId = coreUser.id;
|
|
|
|
+ item.tmdName = coreUser.name;
|
|
|
|
+ item.tmdMobile = coreUser.mobile;
|
|
|
|
+ item.picture = coreUser.picture;
|
|
|
|
+ item.mail = coreUser.mail;
|
|
}
|
|
}
|
|
else return Ok(new { state = 404, msg = "依据钉钉手机号未找到醍摩豆账号!" });
|
|
else return Ok(new { state = 404, msg = "依据钉钉手机号未找到醍摩豆账号!" });
|
|
|
|
|
|
- //HttpClient httpClient = _http.CreateClient();
|
|
|
|
- //string url = _configuration.GetValue<string>("HaBookAuth:CoreId:userinfo");
|
|
|
|
//List<string> mobiles = new() { $"{ item.mobile}" };
|
|
//List<string> mobiles = new() { $"{ item.mobile}" };
|
|
- //HttpResponseMessage responseMessage = await httpClient.PostAsJsonAsync(url, mobiles);
|
|
|
|
- //if (responseMessage.StatusCode == HttpStatusCode.OK)
|
|
|
|
|
|
+ //var content = new StringContent(mobiles.ToJsonString(), Encoding.UTF8, "application/json");
|
|
|
|
+ //string json = await _coreAPIHttpService.GetUserInfos(content);
|
|
|
|
+ //if (!string.IsNullOrEmpty(json))
|
|
//{
|
|
//{
|
|
- // string temp = responseMessage.Content.ReadAsStringAsync().Result;
|
|
|
|
- // List<JsonElement> json_id = temp.ToObject<List<JsonElement>>();
|
|
|
|
- // if (json_id.Count > 0)
|
|
|
|
|
|
+ // List<JsonElement> json_id = json.ToObject<List<JsonElement>>();
|
|
|
|
+ // foreach (var tmd in json_id)
|
|
// {
|
|
// {
|
|
- // foreach (var tmd in json_id)
|
|
|
|
- // {
|
|
|
|
- // item.tmdId = tmd.GetProperty("id").ToString();
|
|
|
|
- // item.tmdName = tmd.GetProperty("name").ToString();
|
|
|
|
- // item.tmdMobile = tmd.GetProperty("mobile").ToString();
|
|
|
|
- // item.picture = tmd.GetProperty("picture").ToString();
|
|
|
|
- // item.mail = tmd.GetProperty("mail").ToString();
|
|
|
|
- // }
|
|
|
|
|
|
+ // item.tmdId = tmd.GetProperty("id").ToString();
|
|
|
|
+ // item.tmdName = tmd.GetProperty("name").ToString();
|
|
|
|
+ // item.tmdMobile = tmd.GetProperty("mobile").ToString();
|
|
|
|
+ // item.picture = tmd.GetProperty("picture").ToString();
|
|
|
|
+ // item.mail = tmd.GetProperty("mail").ToString();
|
|
// }
|
|
// }
|
|
- // else return Ok(new { state = 404, msg = "依据钉钉手机号未找到醍摩豆账号!" });
|
|
|
|
//}
|
|
//}
|
|
|
|
+ //else return Ok(new { state = 404, msg = "依据钉钉手机号未找到醍摩豆账号!" });
|
|
|
|
|
|
strMsg.Append($"{item.tmdName}【{item.tmdId}】醍摩豆账号和{item.name}【{item.userId}】钉钉账户绑定成功");
|
|
strMsg.Append($"{item.tmdName}【{item.tmdId}】醍摩豆账号和{item.name}【{item.userId}】钉钉账户绑定成功");
|
|
|
|
|
|
@@ -259,28 +248,39 @@ namespace TEAMModelBI.Controllers
|
|
|
|
|
|
if (!string.IsNullOrEmpty($"{ddUserInfo.mobile}"))
|
|
if (!string.IsNullOrEmpty($"{ddUserInfo.mobile}"))
|
|
{
|
|
{
|
|
- HttpClient httpClient = _http.CreateClient();
|
|
|
|
- string url = _configuration.GetValue<string>("HaBookAuth:CoreId:userinfo");
|
|
|
|
-
|
|
|
|
- List<string> mobiles = new() { $"{ ddUserInfo.mobile}" };
|
|
|
|
- HttpResponseMessage responseMessage = await httpClient.PostAsJsonAsync(url, mobiles);
|
|
|
|
- if (responseMessage.StatusCode == HttpStatusCode.OK)
|
|
|
|
- {
|
|
|
|
- string temp = responseMessage.Content.ReadAsStringAsync().Result;
|
|
|
|
- List<JsonElement> json_id = temp.ToObject<List<JsonElement>>();
|
|
|
|
- if (json_id.Count > 0)
|
|
|
|
- {
|
|
|
|
- foreach (var tmd in json_id)
|
|
|
|
- {
|
|
|
|
- ddUserInfo.tmdId = tmd.GetProperty("id").ToString();
|
|
|
|
- ddUserInfo.tmdName = tmd.GetProperty("name").ToString();
|
|
|
|
- ddUserInfo.tmdMobile = tmd.GetProperty("mobile").ToString();
|
|
|
|
- ddUserInfo.picture = tmd.GetProperty("picture").ToString();
|
|
|
|
- ddUserInfo.mail = tmd.GetProperty("mail").ToString();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else return Ok(new { state = 404, msg = "依据钉钉手机号未找到醍摩豆账号!" });
|
|
|
|
|
|
+ var coreUser = await _coreAPIHttpService.GetUserInfo(new Dictionary<string, string> { { "key", $"{ddUserInfo.mobile}" } }, _option.Location, _configuration);
|
|
|
|
+ if (coreUser.id != null) {
|
|
|
|
+
|
|
|
|
+ ddUserInfo.tmdId = coreUser.id;
|
|
|
|
+ ddUserInfo.tmdName = coreUser.name;
|
|
|
|
+ ddUserInfo.tmdMobile = coreUser.mobile;
|
|
|
|
+ ddUserInfo.picture = coreUser.mobile;
|
|
|
|
+ ddUserInfo.mail = coreUser.mail;
|
|
}
|
|
}
|
|
|
|
+ else return Ok(new { state = 404, msg = "依据钉钉手机号未找到醍摩豆账号!" });
|
|
|
|
+
|
|
|
|
+ //HttpClient httpClient = _http.CreateClient();
|
|
|
|
+ //string url = _configuration.GetValue<string>("HaBookAuth:CoreId:userinfo");
|
|
|
|
+
|
|
|
|
+ //List<string> mobiles = new() { $"{ ddUserInfo.mobile}" };
|
|
|
|
+ //HttpResponseMessage responseMessage = await httpClient.PostAsJsonAsync(url, mobiles);
|
|
|
|
+ //if (responseMessage.StatusCode == HttpStatusCode.OK)
|
|
|
|
+ //{
|
|
|
|
+ // string temp = responseMessage.Content.ReadAsStringAsync().Result;
|
|
|
|
+ // List<JsonElement> json_id = temp.ToObject<List<JsonElement>>();
|
|
|
|
+ // if (json_id.Count > 0)
|
|
|
|
+ // {
|
|
|
|
+ // foreach (var tmd in json_id)
|
|
|
|
+ // {
|
|
|
|
+ // ddUserInfo.tmdId = tmd.GetProperty("id").ToString();
|
|
|
|
+ // ddUserInfo.tmdName = tmd.GetProperty("name").ToString();
|
|
|
|
+ // ddUserInfo.tmdMobile = tmd.GetProperty("mobile").ToString();
|
|
|
|
+ // ddUserInfo.picture = tmd.GetProperty("picture").ToString();
|
|
|
|
+ // ddUserInfo.mail = tmd.GetProperty("mail").ToString();
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // else return Ok(new { state = 404, msg = "依据钉钉手机号未找到醍摩豆账号!" });
|
|
|
|
+ //}
|
|
}
|
|
}
|
|
else return Ok(new { state = 404, msg = "钉钉手机号为空" });
|
|
else return Ok(new { state = 404, msg = "钉钉手机号为空" });
|
|
|
|
|
|
@@ -352,7 +352,6 @@ namespace TEAMModelBI.Controllers
|
|
}
|
|
}
|
|
|
|
|
|
HttpClient httpClient = _http.CreateClient();
|
|
HttpClient httpClient = _http.CreateClient();
|
|
- string url = _configuration.GetValue<string>("HaBookAuth:CoreId:userinfo");
|
|
|
|
var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
|
|
var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
|
|
var tempUser = await table.FindListByDict<DingDingUserInfo>(new Dictionary<string, object> { { "PartitionKey", $"{partitionKey}" }, { "userId", $"{userId}" } });
|
|
var tempUser = await table.FindListByDict<DingDingUserInfo>(new Dictionary<string, object> { { "PartitionKey", $"{partitionKey}" }, { "userId", $"{userId}" } });
|
|
|
|
|
|
@@ -379,25 +378,38 @@ namespace TEAMModelBI.Controllers
|
|
|
|
|
|
if (!string.IsNullOrEmpty($"{mobile}"))
|
|
if (!string.IsNullOrEmpty($"{mobile}"))
|
|
{
|
|
{
|
|
- List<string> mobiles = new() { $"{mobile}" };
|
|
|
|
- HttpResponseMessage responseMessage = await httpClient.PostAsJsonAsync(url, mobiles);
|
|
|
|
- if (responseMessage.StatusCode == HttpStatusCode.OK)
|
|
|
|
|
|
+
|
|
|
|
+ var coreUser = await _coreAPIHttpService.GetUserInfo(new Dictionary<string, string> { { "key", $"{mobile}" } }, _option.Location, _configuration);
|
|
|
|
+ if (coreUser.id != null)
|
|
{
|
|
{
|
|
- var temp = await responseMessage.Content.ReadAsStringAsync();
|
|
|
|
- if (temp.Length > 0)
|
|
|
|
- {
|
|
|
|
- List<JsonElement> itemjson = temp.ToObject<List<JsonElement>>();
|
|
|
|
- foreach (var item in itemjson)
|
|
|
|
- {
|
|
|
|
- itemUser.tmdId = item.GetProperty("id").ToString();
|
|
|
|
- itemUser.tmdName = item.GetProperty("name").ToString();
|
|
|
|
- itemUser.tmdMobile = item.GetProperty("mobile").ToString();
|
|
|
|
- itemUser.picture = item.GetProperty("picture").ToString();
|
|
|
|
- itemUser.mail = item.GetProperty("mail").ToString();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ itemUser.tmdId = coreUser.id;
|
|
|
|
+ itemUser.tmdName = coreUser.name;
|
|
|
|
+ itemUser.tmdMobile = coreUser.mobile;
|
|
|
|
+ itemUser.picture = coreUser.mobile;
|
|
|
|
+ itemUser.mail = coreUser.mail;
|
|
}
|
|
}
|
|
else return Ok(new { state = 404, msg = "手机号未找到醍摩豆账户" });
|
|
else return Ok(new { state = 404, msg = "手机号未找到醍摩豆账户" });
|
|
|
|
+
|
|
|
|
+ //string url = _configuration.GetValue<string>("HaBookAuth:CoreId:userinfo");
|
|
|
|
+ //List<string> mobiles = new() { $"{mobile}" };
|
|
|
|
+ //HttpResponseMessage responseMessage = await httpClient.PostAsJsonAsync(url, mobiles);
|
|
|
|
+ //if (responseMessage.StatusCode == HttpStatusCode.OK)
|
|
|
|
+ //{
|
|
|
|
+ // var temp = await responseMessage.Content.ReadAsStringAsync();
|
|
|
|
+ // if (temp.Length > 0)
|
|
|
|
+ // {
|
|
|
|
+ // List<JsonElement> itemjson = temp.ToObject<List<JsonElement>>();
|
|
|
|
+ // foreach (var item in itemjson)
|
|
|
|
+ // {
|
|
|
|
+ // itemUser.tmdId = item.GetProperty("id").ToString();
|
|
|
|
+ // itemUser.tmdName = item.GetProperty("name").ToString();
|
|
|
|
+ // itemUser.tmdMobile = item.GetProperty("mobile").ToString();
|
|
|
|
+ // itemUser.picture = item.GetProperty("picture").ToString();
|
|
|
|
+ // itemUser.mail = item.GetProperty("mail").ToString();
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
|
|
+ //else return Ok(new { state = 404, msg = "手机号未找到醍摩豆账户" });
|
|
}
|
|
}
|
|
|
|
|
|
if (string.IsNullOrEmpty($"{mobile}") && string.IsNullOrEmpty($"{idtoken}"))
|
|
if (string.IsNullOrEmpty($"{mobile}") && string.IsNullOrEmpty($"{idtoken}"))
|
|
@@ -483,46 +495,66 @@ namespace TEAMModelBI.Controllers
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- HttpClient httpClient = _http.CreateClient();
|
|
|
|
- string url = _configuration.GetValue<string>("HaBookAuth:CoreId:userinfo");
|
|
|
|
- HttpResponseMessage responseMessage = await httpClient.PostAsJsonAsync(url, moile);
|
|
|
|
-
|
|
|
|
- if (responseMessage.StatusCode == HttpStatusCode.OK)
|
|
|
|
|
|
+ var coreUser = await _coreAPIHttpService.GetUserInfo(new Dictionary<string, string> { { "key", $"{moile}" } }, _option.Location, _configuration);
|
|
|
|
+ if (coreUser.id != null)
|
|
{
|
|
{
|
|
- var temp = await responseMessage.Content.ReadAsStringAsync();
|
|
|
|
- if (temp.Length > 0)
|
|
|
|
- {
|
|
|
|
- List<JsonElement> itemjson = temp.ToObject<List<JsonElement>>();
|
|
|
|
- string tmdId = null;
|
|
|
|
- string tmdName = null;
|
|
|
|
- foreach (var item in itemjson)
|
|
|
|
- {
|
|
|
|
- tmdId = item.GetProperty("id").ToString();
|
|
|
|
- tmdName = item.GetProperty("name").ToString();
|
|
|
|
- itemUser.tmdId = tmdId?.ToString();
|
|
|
|
- itemUser.tmdName = tmdName?.ToString();
|
|
|
|
- itemUser.tmdMobile = item.GetProperty("mobile").ToString();
|
|
|
|
- itemUser.picture = item.GetProperty("picture").ToString();
|
|
|
|
- itemUser.mail = item.GetProperty("mail").ToString();
|
|
|
|
- roles = !string.IsNullOrEmpty($"{itemUser.roles}") ? new List<string>(itemUser.roles.Split(",")) : new List<string>();
|
|
|
|
- permissions = !string.IsNullOrEmpty($"{itemUser.permissions}") ? new List<string>(itemUser.permissions.Split(",")) : new List<string>();
|
|
|
|
-
|
|
|
|
- ddUserInfos.Add(itemUser);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- ddUserInfos = await table.UpdateAll<DingDingUserInfo>(ddUserInfos);
|
|
|
|
-
|
|
|
|
- //保存操作记录
|
|
|
|
- //await _azureStorage.SaveBILog("tabledd-update", $"{tmdName}【{tmdId}】醍摩豆账号和{itemUser.name}【{itemUser.userId}】钉钉账户绑定成功", _dingDing, tid: itemUser.tmdId, tname: itemUser.name, twebsite: Website, httpContext: HttpContext);
|
|
|
|
- await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "tabledd-update", $"{tmdName}【{tmdId}】醍摩豆账号和{itemUser.name}【{itemUser.userId}】钉钉账户绑定成功", _dingDing, tid: itemUser.tmdId, tname: itemUser.name, twebsite: Website, httpContext: HttpContext);
|
|
|
|
- }
|
|
|
|
- else return Ok(new { state = 400, message = "该手机没有注册醍摩豆账号信息" });
|
|
|
|
|
|
+ itemUser.tmdId = coreUser.id;
|
|
|
|
+ itemUser.tmdName = coreUser.name;
|
|
|
|
+ itemUser.tmdMobile = coreUser.mobile;
|
|
|
|
+ itemUser.picture = coreUser.mobile;
|
|
|
|
+ itemUser.mail = coreUser.mail;
|
|
|
|
+
|
|
|
|
+ roles = !string.IsNullOrEmpty($"{itemUser.roles}") ? new List<string>(itemUser.roles.Split(",")) : new List<string>();
|
|
|
|
+ permissions = !string.IsNullOrEmpty($"{itemUser.permissions}") ? new List<string>(itemUser.permissions.Split(",")) : new List<string>();
|
|
|
|
+
|
|
|
|
+ ddUserInfos.Add(itemUser);
|
|
|
|
+
|
|
|
|
+ await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "tabledd-update", $"{coreUser.name}【{coreUser.id}】醍摩豆账号和{itemUser.name}【{itemUser.userId}】钉钉账户绑定成功", _dingDing, tid: itemUser.tmdId, tname: itemUser.name, twebsite: Website, httpContext: HttpContext);
|
|
}
|
|
}
|
|
- else return Ok(new { state = responseMessage.StatusCode });
|
|
|
|
|
|
+ else return Ok(new { state = 400, message = "该手机没有注册醍摩豆账号信息" });
|
|
|
|
+
|
|
|
|
+ //HttpClient httpClient = _http.CreateClient();
|
|
|
|
+ //string url = _configuration.GetValue<string>("HaBookAuth:CoreId:userinfo");
|
|
|
|
+ //HttpResponseMessage responseMessage = await httpClient.PostAsJsonAsync(url, moile);
|
|
|
|
+
|
|
|
|
+ //if (responseMessage.StatusCode == HttpStatusCode.OK)
|
|
|
|
+ //{
|
|
|
|
+ // var temp = await responseMessage.Content.ReadAsStringAsync();
|
|
|
|
+ // if (temp.Length > 0)
|
|
|
|
+ // {
|
|
|
|
+ // List<JsonElement> itemjson = temp.ToObject<List<JsonElement>>();
|
|
|
|
+ // string tmdId = null;
|
|
|
|
+ // string tmdName = null;
|
|
|
|
+ // foreach (var item in itemjson)
|
|
|
|
+ // {
|
|
|
|
+ // tmdId = item.GetProperty("id").ToString();
|
|
|
|
+ // tmdName = item.GetProperty("name").ToString();
|
|
|
|
+ // itemUser.tmdId = tmdId?.ToString();
|
|
|
|
+ // itemUser.tmdName = tmdName?.ToString();
|
|
|
|
+ // itemUser.tmdMobile = item.GetProperty("mobile").ToString();
|
|
|
|
+ // itemUser.picture = item.GetProperty("picture").ToString();
|
|
|
|
+ // itemUser.mail = item.GetProperty("mail").ToString();
|
|
|
|
+ // roles = !string.IsNullOrEmpty($"{itemUser.roles}") ? new List<string>(itemUser.roles.Split(",")) : new List<string>();
|
|
|
|
+ // permissions = !string.IsNullOrEmpty($"{itemUser.permissions}") ? new List<string>(itemUser.permissions.Split(",")) : new List<string>();
|
|
|
|
+
|
|
|
|
+ // ddUserInfos.Add(itemUser);
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ // ddUserInfos = await table.UpdateAll<DingDingUserInfo>(ddUserInfos);
|
|
|
|
+
|
|
|
|
+ // //保存操作记录
|
|
|
|
+ // //await _azureStorage.SaveBILog("tabledd-update", $"{tmdName}【{tmdId}】醍摩豆账号和{itemUser.name}【{itemUser.userId}】钉钉账户绑定成功", _dingDing, tid: itemUser.tmdId, tname: itemUser.name, twebsite: Website, httpContext: HttpContext);
|
|
|
|
+ // await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "tabledd-update", $"{tmdName}【{tmdId}】醍摩豆账号和{itemUser.name}【{itemUser.userId}】钉钉账户绑定成功", _dingDing, tid: itemUser.tmdId, tname: itemUser.name, twebsite: Website, httpContext: HttpContext);
|
|
|
|
+ // }
|
|
|
|
+ // else return Ok(new { state = 400, message = "该手机没有注册醍摩豆账号信息" });
|
|
|
|
+ //}
|
|
|
|
+ //else return Ok(new { state = responseMessage.StatusCode });
|
|
}
|
|
}
|
|
//自己写的
|
|
//自己写的
|
|
id_token = JwtAuth.CreateAuthTokenBI(_option.HostName, itemUser.tmdId?.ToString(), itemUser.tmdName?.ToString(), itemUser.picture?.ToString(), _option.JwtSecretKey, scope: "assist", webSite: Website, isex: false, itemUser.userId?.ToString(), itemUser.name?.ToString(), itemUser.avatar?.ToString(), roles: roles?.ToArray(), permissions: permissions?.ToArray(), expire: 3);
|
|
id_token = JwtAuth.CreateAuthTokenBI(_option.HostName, itemUser.tmdId?.ToString(), itemUser.tmdName?.ToString(), itemUser.picture?.ToString(), _option.JwtSecretKey, scope: "assist", webSite: Website, isex: false, itemUser.userId?.ToString(), itemUser.name?.ToString(), itemUser.avatar?.ToString(), roles: roles?.ToArray(), permissions: permissions?.ToArray(), expire: 3);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ await table.SaveOrUpdateAll<DingDingUserInfo>(ddUserInfos);
|
|
|
|
|
|
string osblob_uri = null, osblob_sas = null;
|
|
string osblob_uri = null, osblob_sas = null;
|
|
|
|
|