|
@@ -1,6 +1,7 @@
|
|
using Azure.Cosmos;
|
|
using Azure.Cosmos;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
+using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Options;
|
|
using Microsoft.Extensions.Options;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
@@ -11,6 +12,7 @@ using System.Threading.Tasks;
|
|
using TEAMModelBI.Filter;
|
|
using TEAMModelBI.Filter;
|
|
using TEAMModelBI.Tool.Extension;
|
|
using TEAMModelBI.Tool.Extension;
|
|
using TEAMModelOS.Models;
|
|
using TEAMModelOS.Models;
|
|
|
|
+using TEAMModelOS.SDK;
|
|
using TEAMModelOS.SDK.Context.BI;
|
|
using TEAMModelOS.SDK.Context.BI;
|
|
using TEAMModelOS.SDK.Context.Constant;
|
|
using TEAMModelOS.SDK.Context.Constant;
|
|
using TEAMModelOS.SDK.DI;
|
|
using TEAMModelOS.SDK.DI;
|
|
@@ -27,12 +29,17 @@ namespace TEAMModelBI.Controllers.BINormal
|
|
public readonly AzureStorageFactory _azureStorage;
|
|
public readonly AzureStorageFactory _azureStorage;
|
|
public readonly DingDing _dingDing;
|
|
public readonly DingDing _dingDing;
|
|
public readonly Option _option;
|
|
public readonly Option _option;
|
|
- public BusinessUsersController(AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, DingDing dingDing, IOptionsSnapshot<Option> option)
|
|
|
|
|
|
+ //读取配置信息
|
|
|
|
+ private readonly IConfiguration _configuration;
|
|
|
|
+ private readonly CoreAPIHttpService _coreAPIHttpService;
|
|
|
|
+ public BusinessUsersController(AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, DingDing dingDing, IOptionsSnapshot<Option> option, IConfiguration configuration, CoreAPIHttpService coreAPIHttpService)
|
|
{
|
|
{
|
|
_azureCosmos = azureCosmos;
|
|
_azureCosmos = azureCosmos;
|
|
_azureStorage = azureStorage;
|
|
_azureStorage = azureStorage;
|
|
_dingDing = dingDing;
|
|
_dingDing = dingDing;
|
|
_option = option?.Value;
|
|
_option = option?.Value;
|
|
|
|
+ _configuration = configuration;
|
|
|
|
+ _coreAPIHttpService = coreAPIHttpService;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -90,7 +97,6 @@ namespace TEAMModelBI.Controllers.BINormal
|
|
string type = "";
|
|
string type = "";
|
|
if (string.IsNullOrEmpty(bizUsers.id))
|
|
if (string.IsNullOrEmpty(bizUsers.id))
|
|
{
|
|
{
|
|
-
|
|
|
|
bizUsers.id = Guid.NewGuid().ToString();
|
|
bizUsers.id = Guid.NewGuid().ToString();
|
|
bizUsers.code = "BizUsers";
|
|
bizUsers.code = "BizUsers";
|
|
bizUsers.name = string.IsNullOrEmpty(bizUsers.name)? bizUsers.mobile.ToString(): bizUsers.name;
|
|
bizUsers.name = string.IsNullOrEmpty(bizUsers.name)? bizUsers.mobile.ToString(): bizUsers.name;
|
|
@@ -129,6 +135,35 @@ namespace TEAMModelBI.Controllers.BINormal
|
|
return Ok(new { state = RespondCode.Ok, bizUsers });
|
|
return Ok(new { state = RespondCode.Ok, bizUsers });
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 通过手机号查询信息
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="jsonElement"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
|
+ [AuthToken(Roles = "admin,rdc,assist")]
|
|
|
|
+ [HttpPost("get-mobileuser")]
|
|
|
|
+ public async Task<IActionResult> GetMobileUser(JsonElement jsonElement)
|
|
|
|
+ {
|
|
|
|
+ var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
|
+ if (!jsonElement.TryGetProperty("mobile", out JsonElement mobile)) return BadRequest();
|
|
|
|
+
|
|
|
|
+ string sql = $"select value(c) from c where c.mobile ={mobile}";
|
|
|
|
+
|
|
|
|
+ List<BizUsers> bizUsers = new();
|
|
|
|
+ await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS,"Normal").GetItemQueryIterator<BizUsers>(queryText:sql,requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
|
|
|
|
+ {
|
|
|
|
+ bizUsers.Add(item);
|
|
|
|
+ }
|
|
|
|
+ CoreUser coreUser = null;
|
|
|
|
+ if (bizUsers.Count <= 0)
|
|
|
|
+ {
|
|
|
|
+ coreUser = await _coreAPIHttpService.GetUserInfo(new Dictionary<string, string> { { "key", $"{mobile}" } }, _option.Location, _configuration);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return Ok(new { state = RespondCode.Ok, bizUsers, coreUser });
|
|
|
|
+ }
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 重置密码
|
|
/// 重置密码
|
|
/// </summary>
|
|
/// </summary>
|