fix 唯一号处理

This commit is contained in:
2024-03-06 22:36:02 +08:00
parent 28390abaa5
commit 04f20e7cf2
3 changed files with 5 additions and 2 deletions

View File

@@ -78,6 +78,11 @@ public class DeviceSaveRequest : IValidatableObject
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (Id.HasValue)
{
UniqueNo = null;
}
if (Type != DeviceTypeEnumType.Door && AsAttendance)
{
yield return new ValidationResult($"{DeviceTypeEnumType.Door.GetDescription()}才可设置作为考勤设备", new[] { nameof(AsAttendance) });

View File

@@ -111,7 +111,6 @@ public class DeviceService : IDeviceService
var existsG = await _dbContext.Queryable<DeviceGroupRelationshipEntity>()
.LeftJoin<DeviceGroupEntity>((dgr, dg) => dgr.GroupCode == dg.Code)
.Where((dgr, dg) => dgr.DeviceCode == entity.Code)
.Where((dgr, dg) => dg.Type != null)
.AnyAsync();
existsG.ThrowIfTrue("存在设备分组,不可修改设备分类");

View File

@@ -22,7 +22,6 @@ public class DeviceEntity : SugarBaseEntity, ITenantId
/// <summary>
/// 设备唯一码,IP/MAC/SNO
/// </summary>
[AdaptIgnore(MemberSide.Destination)]
[SugarColumn(ColumnDescription = "设备唯一码", UniqueGroupNameList = new[] { "Idx_Device_UniqueNo" })]
public string UniqueNo { get; set; }