From 2e6602737a246a4eba3eb443041499ef91f83d79 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Wed, 6 Mar 2024 19:42:35 +0800 Subject: [PATCH] fix tenantId --- .../Device/Services/Implements/DeviceGroupService.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceGroupService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceGroupService.cs index 3bef9e57..dfd02f8a 100644 --- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceGroupService.cs +++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceGroupService.cs @@ -49,6 +49,7 @@ public class DeviceGroupService : IDeviceGroupService { var entity = request.Adapt(); entity.Code = Guid.NewGuid(); + entity.TenantId = _currentUser.GetStringTenantId(); await _dbContext.InsertAsync(entity); } @@ -89,7 +90,7 @@ public class DeviceGroupService : IDeviceGroupService public async Task AssignDevicesAsync(DeviceAssignRequest request) { var group = await _dbContext.Queryable().Where(x => x.Code == request.GroupCode).FirstAsync(); - group.ThrowIfNull("设备组不存在"); + group.ThrowIfNull("设备组不存在,无法进行分配"); await CheckNoNextGroupAsync(group.Code); await CheckGroupTypeMatchAsync(request, group); @@ -133,17 +134,15 @@ public class DeviceGroupService : IDeviceGroupService /// private async Task CheckPCodeAsync(DeviceGroupSaveRequest request) { - var pGrp = await _dbContext.Queryable().Where(x => x.Code == request.PCode).FirstAsync(); if (pGrp != null) { (!pGrp.AbleSetNext && !request.Id.HasValue).ThrowIfTrue($"{pGrp.Name}不可添加下级"); var exists = await _dbContext.Queryable().Where(x => x.GroupCode == request.PCode).AnyAsync(); - exists.ThrowIfTrue("父级分组存在设备"); + exists.ThrowIfTrue("上级分组存在设备"); } - (pGrp != null && pGrp.Type != request.Type).ThrowIfTrue("分组类型必须与上级类型保持一致"); - + (pGrp != null && pGrp.Type != request.Type).ThrowIfTrue("分组类型必须与上级类型保持一致"); return pGrp; }