From a823f933ae40ad5b1509729d9b2652fa18bcfbf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=AD=A3=E6=98=93?= Date: Tue, 11 Jun 2024 13:35:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=8A=B6=E6=80=81=E7=9C=8B?= =?UTF-8?q?=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ZR.Admin.WebApi/appsettings.Development.json | 2 +- ZR.Service/MES/dev/DeviceAccountService.cs | 23 +++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ZR.Admin.WebApi/appsettings.Development.json b/ZR.Admin.WebApi/appsettings.Development.json index 1ed9bb6..c2fc5c6 100644 --- a/ZR.Admin.WebApi/appsettings.Development.json +++ b/ZR.Admin.WebApi/appsettings.Development.json @@ -24,7 +24,7 @@ "DbName": "GXAssembly" //代码生成默认连接数据库,Oracle库是实例的名称 }, "urls": "http://*.*.*.*:7000", //项目启动url,如果改动端口前端对应devServer也需要进行修改 - "corsUrls": [ "http://localhost:7001", "http://localhost:7001", "http://*.*.*.*:7001", "http://0.0.0.0:7001", "http://127.0.0.1:7001" ], //跨域地址(前端启动项目,前后端分离单独部署需要设置),多个用","隔开 + "corsUrls": [ "http://localhost:7001", "http://localhost:7002", "http://*.*.*.*:7001", "http://0.0.0.0:7001", "http://127.0.0.1:7001" ], //跨域地址(前端启动项目,前后端分离单独部署需要设置),多个用","隔开 "JwtSettings": { "Issuer": "DOAN.NET", //即token的签发者。 "Audience": "DOAN.NET", //指该token是服务于哪个群体的(群体范围) diff --git a/ZR.Service/MES/dev/DeviceAccountService.cs b/ZR.Service/MES/dev/DeviceAccountService.cs index bd448a6..c40c2a6 100644 --- a/ZR.Service/MES/dev/DeviceAccountService.cs +++ b/ZR.Service/MES/dev/DeviceAccountService.cs @@ -26,11 +26,32 @@ namespace ZR.Service.MES.dev /// public PagedInfo GetList(DeviceAccountQueryDto parm) { + // 全部设备parm.FkDeviceType == 1 + // 提取parentId + DeviceType typeItem = Context.Queryable() + .Where(it=>it.Id == parm.FkDeviceType) + .Where(it=>it.Status==1) + .First(); + int[] typeIds = []; + // 二级菜单 + if (typeItem != null && typeItem.ParentId == 1) + { + typeIds = Context.Queryable() + .Where(it => it.ParentId == parm.FkDeviceType) + .Where(it => it.Status == 1) + .Select(it => it.Id) + .ToArray(); + } + + // 非全部设备 + + var predicate = Expressionable.Create() .AndIF(!string.IsNullOrEmpty(parm.DeviceName), it => it.DeviceName.Contains(parm.DeviceName)) .AndIF(!string.IsNullOrEmpty(parm.DeviceSpecification), it => it.DeviceSpecification.Contains(parm.DeviceSpecification)) .AndIF(parm.Status > -1, it => it.Status == parm.Status) - .AndIF(parm.FkDeviceType > 0, it => it.FkDeviceType == parm.FkDeviceType) + .AndIF(typeItem != null && typeItem.ParentId > 1, it => it.FkDeviceType == parm.FkDeviceType) + .AndIF(typeItem != null && typeItem.ParentId == 1, it => typeIds.Contains(it.FkDeviceType)) ; var response = Queryable()