Li 2 年之前
父節點
當前提交
8ce29a1711

+ 37 - 2
TEAMModelBI/Controllers/BINormal/BusinessUsersController.cs

@@ -1,6 +1,7 @@
 using Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.Options;
 using System;
 using System.Collections.Generic;
@@ -11,6 +12,7 @@ using System.Threading.Tasks;
 using TEAMModelBI.Filter;
 using TEAMModelBI.Tool.Extension;
 using TEAMModelOS.Models;
+using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.Context.BI;
 using TEAMModelOS.SDK.Context.Constant;
 using TEAMModelOS.SDK.DI;
@@ -27,12 +29,17 @@ namespace TEAMModelBI.Controllers.BINormal
         public readonly AzureStorageFactory _azureStorage;
         public readonly DingDing _dingDing;
         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;
             _azureStorage = azureStorage;
             _dingDing = dingDing;
             _option = option?.Value;
+            _configuration = configuration;
+            _coreAPIHttpService = coreAPIHttpService;
         }
 
         /// <summary>
@@ -90,7 +97,6 @@ namespace TEAMModelBI.Controllers.BINormal
             string type = "";
             if (string.IsNullOrEmpty(bizUsers.id))
             {
-
                 bizUsers.id = Guid.NewGuid().ToString();
                 bizUsers.code = "BizUsers";
                 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 });
         }
 
+        /// <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>

+ 7 - 4
TEAMModelOS.SDK/Models/Cosmos/BI/BINormal/BizConfig.cs

@@ -110,10 +110,10 @@ namespace TEAMModelOS.SDK.Models.Cosmos.BI.BINormal
         /// </summary>
         public string picture { get; set; }
 
-        ///// <summary>
-        ///// 醍摩豆账户
-        ///// </summary>
-        //public string tmdId { get; set; }
+        /// <summary>
+        /// 醍摩豆账户
+        /// </summary>
+        public string tmdId { get; set; }
 
         /// <summary>
         /// 手机号
@@ -151,6 +151,9 @@ namespace TEAMModelOS.SDK.Models.Cosmos.BI.BINormal
         public string bizId { get; set; }
         public string name { get; set; }
         public string picture { get; set; }
+        /// <summary>
+        /// admin  role
+        /// </summary>
         public List<string> role { get; set; }
     }