fix 设备分组保存逻辑控制
This commit is contained in:
@@ -3,9 +3,9 @@ using Dlhis.Basic.Device.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Device.Entities;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Kurisu.AspNetCore.UnifyResultAndValidation;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Kurisu.SqlSugar.Attributes;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Mapster;
|
||||
@@ -55,6 +55,15 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
|
||||
if (!request.Id.HasValue)
|
||||
{
|
||||
if (request.PCode.HasValue)
|
||||
{
|
||||
var pGrp = await _dbContext.Queryable<DeviceGroupEntity>().Where(x => x.Code == request.PCode).FirstAsync();
|
||||
if (pGrp != null && pGrp.Type != request.Type)
|
||||
{
|
||||
throw new UserFriendlyException("分组类型必须与上级类型保持一致");
|
||||
}
|
||||
}
|
||||
|
||||
var entity = request.Adapt<DeviceGroupEntity>();
|
||||
entity.Editable = true;
|
||||
entity.Code = Guid.NewGuid();
|
||||
@@ -67,6 +76,23 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
entity.ThrowIfNull("设备组不存在,无法更新");
|
||||
entity.Editable.ThrowIfFalse("不可编辑当前组");
|
||||
|
||||
if (entity.PCode.HasValue)
|
||||
{
|
||||
var pGrp = await _dbContext.Queryable<DeviceGroupEntity>().Where(x => x.Code == request.PCode).FirstAsync();
|
||||
if (pGrp != null && pGrp.Type != request.Type)
|
||||
{
|
||||
throw new UserFriendlyException("分组类型必须与上级类型保持一致");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var nGrp = await _dbContext.Queryable<DeviceGroupEntity>().Where(x => x.PCode == entity.Code).FirstAsync();
|
||||
if (nGrp != null && nGrp.Type != request.Type)
|
||||
{
|
||||
throw new UserFriendlyException("存在下级分组类型不一致,无法修改");
|
||||
}
|
||||
}
|
||||
|
||||
var nextDevices = await GetDevicesAsync(entity.Code);
|
||||
if (!entity.Type.HasValue)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user