From 14c63ead736861b2e5df16ece47b4f510280b9e4 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Wed, 6 Mar 2024 21:40:34 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BC=98=E5=8C=96=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Device/Controllers/DeviceGroupsController.cs | 1 + .../Services/Implements/DeviceGroupService.cs | 4 ++-- .../Controllers/GainfoGroupsController.cs | 2 ++ .../Services/Implements/GainfoGroupService.cs | 14 +++++++------- .../Entities/DeviceGroupRelationshipEntity.cs | 5 +---- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Src/Dlhis.Basic/Device/Controllers/DeviceGroupsController.cs b/Src/Dlhis.Basic/Device/Controllers/DeviceGroupsController.cs index 723635c4..b3b849cd 100644 --- a/Src/Dlhis.Basic/Device/Controllers/DeviceGroupsController.cs +++ b/Src/Dlhis.Basic/Device/Controllers/DeviceGroupsController.cs @@ -66,6 +66,7 @@ public class DeviceGroupsController : ControllerBase /// /// [HttpPost("assign")] + [IgnoreTenant] [Transactional] public async Task AssignDevicesAsync(DeviceAssignRequest request) { diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceGroupService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceGroupService.cs index dfd02f8a..a6ed9c39 100644 --- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceGroupService.cs +++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceGroupService.cs @@ -90,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); @@ -99,7 +99,7 @@ public class DeviceGroupService : IDeviceGroupService await _devicePermissionService.GenerateDeviceTasksAsync(async () => { var relationships = await _dbContext.Queryable().Where(x => x.GroupCode == request.GroupCode).ToListAsync(); - await _dbContext.DeleteAsync(relationships); + await _dbContext.DeleteReallyAsync(relationships); var entities = request.DeviceCodes.Select(x => new DeviceGroupRelationshipEntity { diff --git a/Src/Dlhis.Basic/Organization/Controllers/GainfoGroupsController.cs b/Src/Dlhis.Basic/Organization/Controllers/GainfoGroupsController.cs index ca2225a9..8fc33da5 100644 --- a/Src/Dlhis.Basic/Organization/Controllers/GainfoGroupsController.cs +++ b/Src/Dlhis.Basic/Organization/Controllers/GainfoGroupsController.cs @@ -63,6 +63,8 @@ public class GainfoGroupsController : ControllerBase /// /// [HttpPost("assign")] + [IgnoreTenant] + [Transactional] public async Task AssignGainfosAsync(GainfoAssignRequest request) { await _gainfoGroupService.AssignGainfosAsync(request); diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoGroupService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoGroupService.cs index 4bf17d67..5f0c3267 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoGroupService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoGroupService.cs @@ -89,14 +89,14 @@ public class GainfoGroupService : IGainfoGroupService public async Task AssignGainfosAsync(GainfoAssignRequest request) { + var pGrp = await _dbContext.Queryable().Where(x => x.Code == request.GroupCode).FirstAsync(); + pGrp?.Editable.ThrowIfFalse("不可分配人员到当前分组"); + + var existsNextGroup = await _dbContext.Queryable().Where(x => x.PCode == request.GroupCode).AnyAsync(); + existsNextGroup.ThrowIfTrue("存在下级分组,无法分配人员"); + await _devicePermissionService.GenerateDeviceTasksAsync(async () => - { - var pGrp = await _dbContext.Queryable().Where(x => x.Code == request.GroupCode).FirstAsync(); - pGrp?.Editable.ThrowIfFalse("不可分配人员到当前分组"); - - var existsNextGroup = await _dbContext.Queryable().Where(x => x.PCode == request.GroupCode).AnyAsync(); - existsNextGroup.ThrowIfTrue("存在下级分组,无法分配人员"); - + { var relations = await _dbContext.Queryable().Where(x => x.GroupCode == request.GroupCode).ToListAsync(); await _dbContext.DeleteReallyAsync(relations); diff --git a/Src/Dlhis.Entity/Device/Entities/DeviceGroupRelationshipEntity.cs b/Src/Dlhis.Entity/Device/Entities/DeviceGroupRelationshipEntity.cs index 352c55c4..d3d79fe0 100644 --- a/Src/Dlhis.Entity/Device/Entities/DeviceGroupRelationshipEntity.cs +++ b/Src/Dlhis.Entity/Device/Entities/DeviceGroupRelationshipEntity.cs @@ -8,7 +8,7 @@ namespace Dlhis.Entity.Device.Entities; /// 设备组/设备关系 /// [SugarTable(TableName = "DeviceGroupRelationship", TableDescription = "设备组/设备关系")] -public class DeviceGroupRelationshipEntity : SugarBaseEntity, ITenantId, ISoftDeleted +public class DeviceGroupRelationshipEntity : SugarBaseEntity, ITenantId { /// /// 设备组code @@ -22,8 +22,5 @@ public class DeviceGroupRelationshipEntity : SugarBaseEntity, ITenantId, ISoftDe [SugarColumn(ColumnDescription = "设备code")] public Guid DeviceCode { get; set; } - public string TenantId { get; set; } - - public bool IsDeleted { get; set; } } \ No newline at end of file