From fd242d02c08d7996834a9e6ab3deb84f7e90e2a1 Mon Sep 17 00:00:00 2001 From: MysticBoy Date: Mon, 13 Mar 2023 11:51:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=A7=9F=E6=88=B7ID=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IoTSharp.Data/Customer.cs | 1 - IoTSharp.sln | 4 ---- IoTSharp/Controllers/CustomersController.cs | 9 ++++----- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/IoTSharp.Data/Customer.cs b/IoTSharp.Data/Customer.cs index 8070db90..5d486001 100644 --- a/IoTSharp.Data/Customer.cs +++ b/IoTSharp.Data/Customer.cs @@ -20,7 +20,6 @@ namespace IoTSharp.Data public string Street { get; set; } public string Address { get; set; } public int ZipCode { get; set; } - public Guid? TenantId { get; set; } [System.Text.Json.Serialization.JsonIgnore] [Newtonsoft.Json.JsonIgnore] diff --git a/IoTSharp.sln b/IoTSharp.sln index 9ab00d94..c4d85059 100644 --- a/IoTSharp.sln +++ b/IoTSharp.sln @@ -59,8 +59,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTSharp.Interpreter", "IoT EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTSharp.Data.InMemory", "IoTSharp.Data.Storage\IoTSharp.Data.InMemory\IoTSharp.Data.InMemory.csproj", "{A57917E3-6F60-4D0E-8F13-36E5088DEFCE}" EndProject -Project("{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}") = "IoTSharp.Docs", "docs\IoTSharp.Docs.njsproj", "{F5644BA6-2A0C-49A5-9C9B-3CECD6DB2D1F}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTSharp.Data.Cassandra", "IoTSharp.Data.Storage\IoTSharp.Data.Cassandra\IoTSharp.Data.Cassandra.csproj", "{9C6FA709-3334-4C39-922D-6FF5ADB8C683}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "2.workflows", "2.workflows", "{59A51D63-F292-46F0-A4BF-975C98966DAA}" @@ -161,8 +159,6 @@ Global {A57917E3-6F60-4D0E-8F13-36E5088DEFCE}.Debug|Any CPU.Build.0 = Debug|Any CPU {A57917E3-6F60-4D0E-8F13-36E5088DEFCE}.Release|Any CPU.ActiveCfg = Release|Any CPU {A57917E3-6F60-4D0E-8F13-36E5088DEFCE}.Release|Any CPU.Build.0 = Release|Any CPU - {F5644BA6-2A0C-49A5-9C9B-3CECD6DB2D1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F5644BA6-2A0C-49A5-9C9B-3CECD6DB2D1F}.Release|Any CPU.ActiveCfg = Release|Any CPU {9C6FA709-3334-4C39-922D-6FF5ADB8C683}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9C6FA709-3334-4C39-922D-6FF5ADB8C683}.Debug|Any CPU.Build.0 = Debug|Any CPU {9C6FA709-3334-4C39-922D-6FF5ADB8C683}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/IoTSharp/Controllers/CustomersController.cs b/IoTSharp/Controllers/CustomersController.cs index 8c41ef68..1f42df08 100644 --- a/IoTSharp/Controllers/CustomersController.cs +++ b/IoTSharp/Controllers/CustomersController.cs @@ -52,7 +52,7 @@ namespace IoTSharp.Controllers /// /// [HttpPost("Tenant")] - [Authorize(Roles = nameof(UserRole.NormalUser))] + [Authorize(Roles = nameof(UserRole.TenantAdmin))] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(typeof(ApiResult), StatusCodes.Status404NotFound)] [ProducesDefaultResponseType] @@ -61,15 +61,14 @@ namespace IoTSharp.Controllers var profile = this.GetUserProfile(); if (m.tenantId != Guid.Empty) { - var querym = _context.Customer.Where(c => c.Deleted == false && c.TenantId == m.tenantId); + var querym = _context.Customer.Include(c=>c.Tenant).Where(c => !c.Deleted && c.Tenant.Id==m.tenantId); var data = await m.Query(querym, c => c.Name); return new ApiResult>(ApiCode.Success, "OK", data); } else { - var querym = _context.Customer.Where(c => c.Deleted == false); - var data = await m.Query(querym, c => c.Name); - return new ApiResult>(ApiCode.Success, "OK", data); + + return new ApiResult>(ApiCode.NotFoundCustomer, "没有指定客户ID",new PagedData ()); } } -- GitLab