fix 中文工号禁止导入,过滤已导入人员
This commit is contained in:
@@ -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) });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,24 +35,27 @@ public class GainfoOutsourceService : IGainfoOutsourceService
|
||||
|
||||
if (!request.Id.HasValue)
|
||||
{
|
||||
var entity = request.Adapt<GainfoEntity>();
|
||||
entity.No = Guid.NewGuid().ToString();
|
||||
entity.Type = GainfoUserTypeEnumType.Outsource;
|
||||
entity.Code = request.Code.IsPresent()
|
||||
? request.Code
|
||||
: await GetOutSourceCodeAsync();
|
||||
|
||||
await _dbContext.InsertAsync(entity);
|
||||
|
||||
if (!await _dbContext.Queryable<OutsourceEntity>().Where(x => x.Code == entity.Code).AnyAsync())
|
||||
if (!await _dbContext.Queryable<GainfoEntity>().Where(x => x.IdNo == request.IdNo).AnyAsync())
|
||||
{
|
||||
await _dbContext.InsertAsync(new OutsourceEntity
|
||||
var entity = request.Adapt<GainfoEntity>();
|
||||
entity.No = Guid.NewGuid().ToString();
|
||||
entity.Type = GainfoUserTypeEnumType.Outsource;
|
||||
entity.Code = request.Code.IsPresent()
|
||||
? request.Code
|
||||
: await GetOutSourceCodeAsync();
|
||||
|
||||
await _dbContext.InsertAsync(entity);
|
||||
|
||||
if (!await _dbContext.Queryable<OutsourceEntity>().Where(x => x.Code == entity.Code).AnyAsync())
|
||||
{
|
||||
Code = entity.Code,
|
||||
Supplier = request.ExternalInfo.Supplier,
|
||||
SapCode = request.ExternalInfo.SapCode,
|
||||
SapPhone = request.ExternalInfo.SapPhone
|
||||
});
|
||||
await _dbContext.InsertAsync(new OutsourceEntity
|
||||
{
|
||||
Code = entity.Code,
|
||||
Supplier = request.ExternalInfo.Supplier,
|
||||
SapCode = request.ExternalInfo.SapCode,
|
||||
SapPhone = request.ExternalInfo.SapPhone
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user