Browse Source

清理存储在table表的第三方接口

Li 2 years ago
parent
commit
e35839e597

+ 0 - 429
TEAMModelBI/Controllers/BITable/CompanyController.cs

@@ -1,429 +0,0 @@
-using Azure.Cosmos;
-using Microsoft.AspNetCore.Hosting;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Options;
-using System;
-using System.Collections.Generic;
-using System.Net.Http;
-using System.Text;
-using System.Text.Json;
-using System.Threading.Tasks;
-using TEAMModelBI.Filter;
-using TEAMModelBI.Models.Extension;
-using TEAMModelBI.Tool.Extension;
-using TEAMModelOS.Models;
-using TEAMModelOS.SDK.Context.BI;
-using TEAMModelOS.SDK.DI;
-using TEAMModelOS.SDK.Extension;
-using TEAMModelOS.SDK.Models.Cosmos.BI;
-using TEAMModelOS.SDK.Models.Service;
-using TEAMModelOS.SDK.Models.Table;
-
-namespace TEAMModelBI.Controllers.BITable
-{
-    [Route("business")]
-    [ApiController]
-    public class CompanyController : ControllerBase
-    {
-        public readonly AzureCosmosFactory _azureCosmos;
-        public readonly AzureStorageFactory _azureStorage;
-        public readonly DingDing _dingDing;
-        public readonly Option _option;
-        private readonly IWebHostEnvironment _environment; //读取文件
-
-        public CompanyController(AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, DingDing dingDing, IOptionsSnapshot<Option> option, IWebHostEnvironment environment)
-        {
-            _azureCosmos = azureCosmos;
-            _azureStorage = azureStorage;
-            _dingDing = dingDing;
-            _option = option?.Value;
-            _environment = environment;
-        }
-
-        /// <summary>
-        /// 查询企业信息结集合  若传ID查查询该账户的企业信息   //已对接
-        /// </summary>
-        /// <param name="jsonElenent"></param>
-        /// <returns></returns>
-        [ProducesDefaultResponseType]
-        //[AuthToken(Roles = "admin,rdc,assist,sales,company")]
-        [HttpPost("get-info")]
-        public async Task<IActionResult> GetInfo(JsonElement jsonElenent)
-        {
-            try
-            {
-                jsonElenent.TryGetProperty("id", out JsonElement id);
-                jsonElenent.TryGetProperty("site", out JsonElement site);
-                var cosmosClient = _azureCosmos.GetCosmosClient();
-                var tableClient = _azureStorage.GetCloudTableClient();
-                if ($"{site}".Equals(BIConst.Global))
-                {
-                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
-                    tableClient = _azureStorage.GetCloudTableClient(BIConst.Global);
-                }
-
-                var table = tableClient.GetTableReference("IESOpenApi");
-                Dictionary<string, object> keyValue = new Dictionary<string, object>() { { "PartitionKey", "BusinessConfig" } };
-                if (!string.IsNullOrEmpty($"{id}")) 
-                {
-                    keyValue.Add("RowKey", $"{id}");
-                }
-
-                List<BusinessConfig> companys = table.FindListByDictSync<BusinessConfig>(keyValue);
-
-                //cosmosDB数据库
-                //List<ReadCompany> companys = new();
-                //StringBuilder sqlTxt = new("select c.id,c.pk,c.code,c.name,c.credit,c.picture,c.jti,c.secretKey,c.emall,c.mobile,c.password,c.webhookDomain,c.salt,c.createTime from c");
-                //if (!string.IsNullOrEmpty($"{id}"))
-                //{
-                //    sqlTxt.Append($" where c.id='{id}'");
-                //}
-                //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<ReadCompany>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Company") }))
-                //{
-                //    companys.Add(item);
-                //}
-
-                return Ok(new { state = 200, companys });
-
-            }
-            catch (Exception e)
-            {
-                await _dingDing.SendBotMsg($"BI,{_option.Location} , /business/get-info   \n {e.Message}\n{e.StackTrace} \n ", GroupNames.成都开发測試群組);
-                return BadRequest();
-            }
-        }
-
-        /// <summary>
-        /// 新增企业信息和修改企业信息   //已对接
-        /// </summary>
-        /// <param name="appCompany"></param>
-        /// <returns></returns>
-        [ProducesDefaultResponseType]
-        [AuthToken(Roles = "admin,rdc,assist,sales,company")]
-        [HttpPost("set-info")]
-        public async Task<IActionResult> SetCompany([FromBody] BusinessConfig company, [FromHeader] string site)
-        {
-            try
-            {
-                //var (loginId, loginName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
-                var (tmdId, tmdName, pic, _, _, _) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
-                StringBuilder strMsg = new();
-                var cosmosClient = _azureCosmos.GetCosmosClient();
-                var tableClient = _azureStorage.GetCloudTableClient();
-                var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
-                if ($"{site}".Equals(BIConst.Global))
-                {
-                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
-                    tableClient = _azureStorage.GetCloudTableClient(BIConst.Global);
-                    blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public", BIConst.Global);
-                }
-                List<BusinessConfig> companys = new();
-                BusinessUser businessUser = new();
-                BizRelUser bizRelUser = new();
-
-                 var table = tableClient.GetTableReference("IESOpenApi");
-
-                string salt = Utils.CreatSaltString(8);
-                string type = "";
-
-                if (string.IsNullOrEmpty(company.RowKey))
-                {
-                    company.RowKey = Guid.NewGuid().ToString();
-                    company.PartitionKey = "BusinessConfig";
-                    company.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
-                    var auth_token = JwtAuthExtension.CreateBusinessApiToken(_option.Location, company.RowKey, _option.JwtSecretKey);
-                    company.jti = auth_token.jti;
-                    company.token = auth_token.jwt;
-                    company = await table.SaveOrUpdate<BusinessConfig>(company);
-                    
-                    businessUser = new() { RowKey = Guid.NewGuid().ToString(), name = $"{company.mobile}", mobile = company.mobile, salt = salt, pwd = Utils.HashedPassword($"{company.mobile}", salt) };
-                    businessUser = await table.SaveOrUpdate<BusinessUser>(businessUser);
-
-                    bizRelUser = new() { RowKey = $"{businessUser.RowKey}-{company.RowKey}",userId= $"{company.RowKey}", bizId = $"{company.RowKey}",bizName = company.name ,roles = "admin" };
-                    bizRelUser = await table.SaveOrUpdate<BizRelUser>(bizRelUser);
-
-                    companys.Add(company);
-                    strMsg.Append($"{company.name}【{company.RowKey}】新增企业基础信息。新增该企业管理员信息{businessUser.name}【{businessUser.RowKey}】。");
-                    type = "business-add";
-                }
-                else 
-                {
-                    //List<BusinessConfig> companyTables = table.FindListByDictSync<BusinessConfig>(new Dictionary<string, object> { { "PartitionKey", "BusinessConfig" }, { "RowKey", $"{company.RowKey}" } });
-                    BusinessConfig businessConfig = table.Get<BusinessConfig>("BusinessConfig", $"{company.RowKey}");
-
-                    if (businessConfig != null)
-                    {
-                        company.PartitionKey = businessConfig.PartitionKey;
-                        company.RowKey = businessConfig.RowKey;
-                        company.credit = businessConfig.credit;
-                        company.jti = businessConfig.jti;
-                        company.token = businessConfig.token;
-
-                        businessConfig = await table.SaveOrUpdate<BusinessConfig>(company);
-                        companys.Add(businessConfig);
-                        strMsg.Append($"{company.name}【{company.RowKey}】修改企业基础信息:{company}。");
-                        type = "business-add";
-                    }
-                    else
-                    {
-                        company.RowKey = Guid.NewGuid().ToString();
-                        company.PartitionKey = "BusinessConfig";
-                         company.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
-                        var auth_token = JwtAuthExtension.CreateBusinessApiToken(_option.Location, company.RowKey, _option.JwtSecretKey);
-                        company.jti = auth_token.jti;
-                        company.token = auth_token.jwt;
-                        company = await table.SaveOrUpdate<BusinessConfig>(company);
-
-                        businessUser = new() { RowKey = Guid.NewGuid().ToString(), name = $"{company.mobile}", mobile = company.mobile, salt = salt, pwd = Utils.HashedPassword($"{company.mobile}", salt) };
-                        businessUser = await table.SaveOrUpdate<BusinessUser>(businessUser);
-
-                        bizRelUser = new() { RowKey = $"{businessUser.RowKey}-{company.RowKey}", userId = $"{company.RowKey}", bizId = $"{company.RowKey}", bizName = company.name, roles = "admin" };
-                        bizRelUser = await table.SaveOrUpdate<BizRelUser>(bizRelUser);
-
-                        companys.Add(company);
-                        strMsg.Append($"{company.name}【{company.RowKey}】新增企业基础信息:{company}。新增该企业管理员信息{businessUser.name}【{businessUser.RowKey}】。");
-                        type = "business-add";
-                    }
-                }
-                
-                //保存操作记录
-                //await _azureStorage.SaveBILog(type, strMsg.ToString(), _dingDing, httpContext: HttpContext);
-                await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, type, strMsg.ToString(), _dingDing, httpContext: HttpContext);
-                return Ok(new { state = 200, companys, businessUser });
-            }
-            catch (Exception e)
-            {
-                await _dingDing.SendBotMsg($"BI,{_option.Location} , /business/set-info   \n {e.Message}\n{e.StackTrace} \n ", GroupNames.成都开发測試群組);
-                return BadRequest();
-            }
-        }
-
-        /// <summary>
-        /// 关联企业学校   //已对接
-        /// </summary>
-        /// <param name="jsonElement"></param>
-        /// <returns></returns>
-        [ProducesDefaultResponseType]
-        [AuthToken(Roles = "admin,rdc,assist,sales,company")]
-        [HttpPost("set-companyschool")]
-        public async Task<IActionResult> SetCompanySc(JsonElement jsonElement)
-        {
-            try
-            {
-                if (!jsonElement.TryGetProperty("schools", out JsonElement _schools)) return BadRequest();
-                if (!jsonElement.TryGetProperty("id", out JsonElement id)) return BadRequest();
-                var (tmdId, tmdName, pic, _, _, _) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
-                jsonElement.TryGetProperty("site", out JsonElement site);
-                List<RecSc> recScs = _schools.ToObject<List<RecSc>>();
-                var tableClient = _azureStorage.GetCloudTableClient();
-                var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
-                if ($"{site}".Equals(BIConst.Global))
-                {
-                    tableClient = _azureStorage.GetCloudTableClient(BIConst.Global);
-                    blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public", BIConst.Global);
-                }
-
-                var table = tableClient.GetTableReference("IESOpenApi");
-
-                StringBuilder strMsg = new($"{tmdName}[{tmdId}]关联企业ID:{id},学校列表:");
-                List<BusinessSchool> busSchools = new();
-                foreach (var item in recScs)
-                {
-                    BusinessSchool businessSchool = new() { PartitionKey = $"BusinessSchool", RowKey = Guid.NewGuid().ToString(), school = $"{item.id}", bizid = $"{id}", name = $"{item.name}", picture = $"{item.picture}" };
-                    busSchools.Add(businessSchool);
-                    strMsg.Append($"{item.name}[{item.id}]|");
-                }
-
-                busSchools = await table.SaveOrUpdateAll<BusinessSchool>(busSchools);
-
-                //保存操作记录
-                //await _azureStorage.SaveBILog(type, strMsg.ToString(), _dingDing, httpContext: HttpContext);
-                await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "BusinessSchool-add", strMsg.ToString(), _dingDing, httpContext: HttpContext);
-                return Ok(new { state = 200, busSchools });
-            }
-            catch (Exception e)
-            {
-                await _dingDing.SendBotMsg($"BI,{_option.Location} , /business/set-companyschool   \n {e.Message}\n{e.StackTrace} \n ", GroupNames.成都开发測試群組);
-                return BadRequest();
-            }
-        }
-
-        /// <summary>
-        /// 依据企业ID查询关联的学校   //已对接
-        /// </summary>
-        /// <param name="jsonElement"></param>
-        /// <returns></returns>
-        [ProducesDefaultResponseType]
-        [HttpPost("get-companyschool")]
-        public async Task<IActionResult> GetCompanySc(JsonElement jsonElement) 
-        {
-            try
-            {
-                jsonElement.TryGetProperty("id", out JsonElement id);
-                jsonElement.TryGetProperty("site", out JsonElement site);
-
-                var tableClient = _azureStorage.GetCloudTableClient();
-                var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
-                if ($"{site}".Equals(BIConst.Global))
-                {
-                    tableClient = _azureStorage.GetCloudTableClient(BIConst.Global);
-                    blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public", BIConst.Global);
-                }
-
-                var table = tableClient.GetTableReference("IESOpenApi");
-                Dictionary<string, object> keyValue = new() { { "PartitionKey", $"BusinessSchool" } };
-
-                if (!string.IsNullOrEmpty($"{id}")) 
-                {
-                    keyValue.Add("bizid", $"{id}");
-                }
-
-                List<BusinessSchool> busSchools = await table.FindListByDict<BusinessSchool>(keyValue);
-
-                return Ok(new { state = 200, busSchools });
-            }
-            catch (Exception e)
-            {
-                await _dingDing.SendBotMsg($"BI,{_option.Location} , /business/get-companyschool   \n {e.Message}\n{e.StackTrace} \n ", GroupNames.成都开发測試群組);
-                return BadRequest();
-            }
-        }
-
-        /// <summary>
-        /// 删除企业关联学校  //已对接
-        /// </summary>
-        /// <param name="jsonElement"></param>
-        /// <returns></returns>
-        [ProducesDefaultResponseType]
-        [AuthToken(Roles = "admin,rdc,assist,sales,company")]
-        [HttpPost("del-companysc")]
-        public async Task<IActionResult> DelCompanySc(JsonElement jsonElement) 
-        {
-            if(!jsonElement.TryGetProperty("id", out JsonElement id)) return  BadRequest();
-            if (!jsonElement.TryGetProperty("schools", out JsonElement _schools)) return BadRequest();
-            var (tmdId, tmdName, pic, _, _, _) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
-            jsonElement.TryGetProperty("site", out JsonElement site);
-
-            List<string> schools = _schools.ToObject<List<string>>();
-
-            var tableClient = _azureStorage.GetCloudTableClient();
-            var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
-            if ($"{site}".Equals(BIConst.Global))
-            {
-                tableClient = _azureStorage.GetCloudTableClient(BIConst.Global);
-                blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public", BIConst.Global);
-            }
-
-            var table = tableClient.GetTableReference("IESOpenApi");
-
-            StringBuilder strMsg = new($"{tmdName}[{tmdId}]删除企业关联学校,企业ID:{id},学校列表:");
-
-            List<string> noSc = new();
-
-            foreach (var school in schools)
-            {
-                string sqlTxt = $"PartitionKey eq 'BusinessSchool' and bizid eq '{id}' and school eq '{school}'";
-                List<BusinessSchool> busSc = await table.QueryWhereString<BusinessSchool>(sqlTxt);
-                if (busSc.Count > 0)
-                {
-                    strMsg.Append($"{school}|");
-                    await table.DeleteAll(busSc);
-                }
-                else
-                    noSc.Add(school);
-            }
-
-            //保存操作记录
-            await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "BusinessSchool-del", strMsg.ToString(), _dingDing, httpContext: HttpContext);
-
-            if (noSc.Count > 0)
-                return Ok(new { state = 201, noSc });
-            else
-                return Ok(new { state = 200 });
-        }
-
-
-        /// <summary>
-        /// 重置密码和token    //已对接
-        /// </summary>
-        /// <param name="jsonElement"></param>
-        /// <returns></returns>
-        [ProducesDefaultResponseType]
-        [AuthToken(Roles = "admin,rdc,assist,sales,company")]
-        [HttpPost("reset-bus")]
-        public async Task<IActionResult> ResetBus(JsonElement jsonElement) 
-        {
-            if (!jsonElement.TryGetProperty("id", out JsonElement id)) return BadRequest();
-            if (!jsonElement.TryGetProperty("resetType", out JsonElement resetType)) return BadRequest();
-            jsonElement.TryGetProperty("site", out JsonElement site);
-            var (tmdId, tmdName, pic, _, _, _) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
-
-            var tableClient = _azureStorage.GetCloudTableClient();
-            var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
-            if ($"{site}".Equals(BIConst.Global))
-            {
-                tableClient = _azureStorage.GetCloudTableClient(BIConst.Global);
-                blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public", BIConst.Global);
-            }                      
-
-            var table = tableClient.GetTableReference("IESOpenApi");
-
-            List<BusinessConfig> busConfigs = await table.FindListByDict<BusinessConfig>(new Dictionary<string, object>() { { "PartitionKey", "BusinessConfig" }, { "RowKey", $"{id}" } });
-            if (busConfigs.Count > 0)
-            {
-                foreach (var busConfig in busConfigs)
-                {
-                    if ($"{resetType}".Equals("token"))
-                    {
-                        var auth_token = JwtAuthExtension.CreateBusinessApiToken(_option.Location, busConfig.RowKey, _option.JwtSecretKey);
-                        busConfig.jti = auth_token.jti;
-                        busConfig.token = auth_token.jwt;
-                    }
-                }
-                if ($"{resetType}".Equals("token"))
-                {
-                    await table.SaveOrUpdateAll(busConfigs);
-                    return Ok(new { state = 200, busConfigs });
-                }
-                else
-                    return Ok(new { state = 400, msg = "重置类型错误!" });
-            }
-            else
-                return Ok(new { state = 404, msg = "未找到企业信息" });
-        }
-
-        /// <summary>
-        /// 关联时传入的学校信息
-        /// </summary>
-        public record RecSc 
-        {
-            public string id { get; set; }
-            public string name { get; set; }
-            public string picture { get; set; }
-        }
-
-
-        /// <summary>
-        /// 显示第三方信息
-        /// </summary>
-        public record ReadCompany
-        {
-            public string id { get; set; }
-            public string code { get; set; }
-            public string name { get; set; }
-            public string credit { get; set; }
-            public string picture { get; set; }
-            public string jti { get; set; }
-            public string secretKey { get; set; }
-            public string emall { get; set; }
-            public string mobile { get; set; }
-            public string salt { get; set; }
-            public string password { get; set; }
-            public string webhookDomain { get; set; }
-            public long createTime { get; set; }
-        }
-
-
-}
-}

+ 0 - 29
TEAMModelBI/Controllers/BITest/TestController.cs

@@ -1413,35 +1413,6 @@ namespace TEAMModelBI.Controllers.BITest
             return Ok(new { state = 200, linqTest,cosmosClient,site });
         }
 
-        /// <summary>
-        /// 查询一个实体信息
-        /// </summary>
-        /// <param name="jsonElement"></param>
-        /// <returns></returns>
-        [HttpPost("get-bizschool")]
-        public async Task<IActionResult> GetTable(JsonElement jsonElement) 
-        {            
-            jsonElement.TryGetProperty("partitionKey", out JsonElement partitionKey);
-            jsonElement.TryGetProperty("rowKey", out JsonElement rowKey);
-            var tableClient = _azureStorage.GetCloudTableClient();
-            var table = _azureStorage.GetCloudTableClient().GetTableReference("IESOpenApi");
-            BusinessSchool tempUser = table.Get<BusinessSchool>(partitionKey: $"{partitionKey}", rowKey: $"{rowKey}");
-            return Ok(new { state = 200, table = tempUser });
-        }
-
-        [HttpPost("get-testway")]
-        public async Task<IActionResult> TestWay (JsonElement jsonElement)
-        {
-            jsonElement.TryGetProperty("source", out JsonElement source);
-            jsonElement.TryGetProperty("splitChar", out JsonElement splitChar);
-            jsonElement.TryGetProperty("indexes", out JsonElement indexes);
-            jsonElement.TryGetProperty("num", out JsonElement num);
-
-            var upS= BICommonWay.SplitStr(source.GetString(), ',', indexes.GetInt32(), num.GetInt32());
-            return Ok(new { state = 200, source, upS });
-        }
-
-
         /// <summary>
         /// 
         /// </summary>

+ 3 - 0
TEAMModelOS.SDK/Models/Table/BusinessConfig.cs

@@ -9,6 +9,9 @@ using TEAMModelOS.SDK.Context.Attributes.Azure;
 
 namespace TEAMModelOS.SDK.Models.Table
 {
+    /// <summary>
+    /// BI这边已删除
+    /// </summary>
     [TableName(Name = "IESOpenApi")]
     public class BusinessSchool : TableEntity {
         // RowKey  雪花id  ,

+ 50 - 16
TEAMModelOS/Controllers/OpenApi/OpenApiService.cs

@@ -28,6 +28,7 @@ using Microsoft.Extensions.Configuration;
 using Azure.Messaging.ServiceBus;
 using TEAMModelOS.Models;
 using TEAMModelOS.SDK.Models.Service;
+using TEAMModelOS.SDK.Models.Cosmos.BI.BINormal;
 
 namespace TEAMModelOS.Controllers
 {
@@ -46,34 +47,67 @@ namespace TEAMModelOS.Controllers
         /// <param name="_dingDing"></param>
         /// <param name="bizId"></param>
         /// <returns></returns>
-        public static async Task<ResponseData<List<OSchool>>> GetSchools(AzureStorageFactory _azureStorage, DingDing _dingDing, string bizId)
+        //public static async Task<ResponseData<List<OSchool>>> GetSchools(AzureStorageFactory _azureStorage, DingDing _dingDing, string bizId)
+        //{
+        //    try
+        //    {
+        //        ResponseData<List<OSchool>> ResponseData = new();
+        //        List<OSchool> schools = new();
+        //        var table = _azureStorage.GetCloudTableClient().GetTableReference("IESOpenApi");
+        //        List<BusinessSchool> bizSchools = await table.FindListByDict<BusinessSchool>(new Dictionary<string, object> { { "PartitionKey", $"BusinessSchool" }, { "bizid", bizId } });
+        //        if (bizSchools != null && bizSchools.Count > 0)
+        //        {
+        //            ResponseData.code = RespondCode.Ok;
+        //            ResponseData.msg = "成功";
+        //            ResponseData.data = bizSchools.Select(x => new OSchool { id = x.school, name = x.name, picture = x.picture }).ToList();                   
+        //        }
+        //        else
+        //        {
+        //            ResponseData.code = RespondCode.NotFound;
+        //            ResponseData.msg = "未找到你关联的学校";
+        //        }
+        //        return ResponseData;
+
+        //    }
+        //    catch (Exception ex)
+        //    {
+        //        await _dingDing.SendBotMsg($"OpenApi,{Environment.GetEnvironmentVariable("Option:Location")} OpenApiService/GetSchools()   参数:bizId:{bizId} \n  {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
+        //        return new ResponseData<List<OSchool>>() { code = RespondCode.Error, msg = "服务器错误" };
+        //    }
+        //}
+
+        /// <summary>
+        /// 第三方获取学校列表
+        /// [ApiToken(Auth = "1000", Name = "合作商获取可访问的学校列表", RWN = "R", Limit = false)]
+        /// </summary>
+        /// <param name="_azureCosmos"></param>
+        /// <param name="_dingDing"></param>
+        /// <param name="json"></param>
+        /// <returns></returns>
+        public static async Task<ResponseData<List<BizSchool>>> GetSchools(AzureCosmosFactory _azureCosmos, DingDing _dingDing, string bizId)
         {
             try
             {
-                ResponseData<List<OSchool>> ResponseData = new();
-                List<OSchool> schools = new();
-                var table = _azureStorage.GetCloudTableClient().GetTableReference("IESOpenApi");
-                List<BusinessSchool> bizSchools = await table.FindListByDict<BusinessSchool>(new Dictionary<string, object> { { "PartitionKey", $"BusinessSchool" }, { "bizid", bizId } });
-                if (bizSchools != null && bizSchools.Count > 0)
-                {
-                    ResponseData.code = RespondCode.Ok;
-                    ResponseData.msg = "成功";
-                    ResponseData.data = bizSchools.Select(x => new OSchool { id = x.school, name = x.name, picture = x.picture }).ToList();                   
-                }
-                else
+                List<BizSchool> schools = new();
+
+                var response = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync(bizId, new PartitionKey("BizConfig"));
+                if (response.Status == 200)
                 {
-                    ResponseData.code = RespondCode.NotFound;
-                    ResponseData.msg = "未找到你关联的学校";
+                    using var resJson = await JsonDocument.ParseAsync(response.ContentStream);
+                    Business bizConfig = resJson.ToObject<Business>();
+                    schools = bizConfig.schools;
                 }
-                return ResponseData;
+                else return new ResponseData<List<BizSchool>>() { code = RespondCode.NotFound, msg = "未找到该企业" };
 
+                return new ResponseData<List<BizSchool>>() { code = RespondCode.Ok, msg = "成功", data = schools };
             }
             catch (Exception ex)
             {
                 await _dingDing.SendBotMsg($"OpenApi,{Environment.GetEnvironmentVariable("Option:Location")} OpenApiService/GetSchools()   参数:bizId:{bizId} \n  {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
-                return new ResponseData<List<OSchool>>() { code = RespondCode.Error, msg = "服务器错误" };
+                return new ResponseData<List<BizSchool>>() { code = RespondCode.Error, msg = "服务器错误" };
             }
         }
+
         /// <summary>
         /// josn:
         /// {