|
@@ -8,6 +8,7 @@ using StackExchange.Redis;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
+using System.Net.Http;
|
|
|
using System.Text;
|
|
|
using System.Text.Json;
|
|
|
using System.Threading.Tasks;
|
|
@@ -16,6 +17,7 @@ using TEAMModelBI.Tool;
|
|
|
using TEAMModelBI.Tool.CosmosBank;
|
|
|
using TEAMModelBI.Tool.Extension;
|
|
|
using TEAMModelOS.Models;
|
|
|
+using TEAMModelOS.SDK;
|
|
|
using TEAMModelOS.SDK.DI;
|
|
|
using TEAMModelOS.SDK.Extension;
|
|
|
using TEAMModelOS.SDK.Models;
|
|
@@ -35,8 +37,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
private readonly AzureRedisFactory _azureRedis;
|
|
|
private readonly IConfiguration _configuration;
|
|
|
private readonly NotificationService _notificationService;
|
|
|
+ private readonly CoreAPIHttpService _coreAPIHttpService;
|
|
|
|
|
|
- public SchoolController(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, IOptionsSnapshot<Option> option, AzureRedisFactory azureRedis, IConfiguration configuration, NotificationService notificationService)
|
|
|
+ public SchoolController(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, IOptionsSnapshot<Option> option, AzureRedisFactory azureRedis, IConfiguration configuration, NotificationService notificationService, CoreAPIHttpService coreAPIHttpService)
|
|
|
{
|
|
|
_azureCosmos = azureCosmos;
|
|
|
_dingDing = dingDing;
|
|
@@ -45,6 +48,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
_azureRedis = azureRedis;
|
|
|
_configuration = configuration;
|
|
|
_notificationService = notificationService;
|
|
|
+ _coreAPIHttpService = coreAPIHttpService;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -499,15 +503,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
{
|
|
|
dic.Add("userId", $"{userId}");
|
|
|
}
|
|
|
- if (!string.IsNullOrEmpty($"{tmdId}"))
|
|
|
- {
|
|
|
- dic.Add("tmdId", $"{tmdId}");
|
|
|
- }
|
|
|
|
|
|
- if (string.IsNullOrEmpty($"{userId}") && string.IsNullOrEmpty($"{tmdId}"))
|
|
|
- {
|
|
|
- return BadRequest();
|
|
|
- }
|
|
|
Dictionary<string, List<string>> noSchools = new();
|
|
|
List<DingDingUserInfo> ddUserInfoList = await table.FindListByDict<DingDingUserInfo>(dic);
|
|
|
List<DingDingUserInfo> updUsers = new();
|
|
@@ -518,6 +514,26 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
{
|
|
|
if (schoolIds.Count > 0)
|
|
|
{
|
|
|
+ if (string.IsNullOrEmpty(ddInfo.tmdId))
|
|
|
+ {
|
|
|
+ List<string> moblie = new() { $"{ddInfo.mobile}" };
|
|
|
+
|
|
|
+ var content = new StringContent(moblie.ToJsonString(), Encoding.UTF8, "application/json");
|
|
|
+ string json = await _coreAPIHttpService.GetUserInfos(content);
|
|
|
+ if (!string.IsNullOrEmpty(json))
|
|
|
+ {
|
|
|
+ List<JsonElement> json_id = json.ToObject<List<JsonElement>>();
|
|
|
+ foreach (var tmd in json_id)
|
|
|
+ {
|
|
|
+ ddInfo.tmdId = tmd.GetProperty("id").ToString();
|
|
|
+ ddInfo.tmdName = tmd.GetProperty("name").ToString();
|
|
|
+ ddInfo.tmdMobile = tmd.GetProperty("mobile").ToString();
|
|
|
+ ddInfo.picture = tmd.GetProperty("picture").ToString();
|
|
|
+ ddInfo.mail = tmd.GetProperty("mail").ToString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else return Ok(new { state = 404, msg = "依据钉钉手机号未找到醍摩豆账号!" });
|
|
|
+ }
|
|
|
List<string> noSchool = await SchoolWay.SchoolAdviser(cosmosClient, ddInfo, schoolIds, $"{busy}");
|
|
|
if (noSchool.Count > 0)
|
|
|
{
|