fix 中文工号禁止导入,过滤已导入人员

This commit is contained in:
2024-10-21 15:28:10 +08:00
parent b0c97fb9bb
commit d400b33ea9
2 changed files with 30 additions and 16 deletions

View File

@@ -1,6 +1,8 @@
using System.ComponentModel.DataAnnotations;
using System.Text.RegularExpressions;
using Dlhis.Basic.Organization.Dto;
using Dlhis.Entity.Basic.Enums;
using Kurisu.AspNetCore.Utils.Extensions;
namespace Dlhis.Basic.Organization.Request;
@@ -76,5 +78,14 @@ public class GainfoOutsourceRequest : IValidatableObject
{
yield return new ValidationResult("工号和对接人工号不可相同", new[] { nameof(Code) });
}
const string containChineseRule = "[\u4e00-\u9fa5]";
if (Code.IsPresent())
{
if (Regex.IsMatch(Code, containChineseRule))
{
yield return new ValidationResult($"工号[{Code}]不能包含中文", new[] { nameof(Code) });
}
}
}
}

View File

@@ -34,6 +34,8 @@ public class GainfoOutsourceService : IGainfoOutsourceService
isOutsource.ThrowIfTrue("对接人不可为外包人员");
if (!request.Id.HasValue)
{
if (!await _dbContext.Queryable<GainfoEntity>().Where(x => x.IdNo == request.IdNo).AnyAsync())
{
var entity = request.Adapt<GainfoEntity>();
entity.No = Guid.NewGuid().ToString();
@@ -55,6 +57,7 @@ public class GainfoOutsourceService : IGainfoOutsourceService
});
}
}
}
else
{
var entity = await _dbContext.Queryable<GainfoEntity>().FirstAsync(x => x.Id == request.Id);