fix:修复规则主体重复校验逻辑错误
This commit is contained in:
parent
b4d98a5d89
commit
ef055943f6
@ -14,15 +14,17 @@ public sealed class WarningRuleRepository : BasicRepository<WarningRuleEntity>,
|
|||||||
|
|
||||||
public async Task<bool> CheckNameDuplicateAsync(int id, int subsystemId, int customId, string name)
|
public async Task<bool> CheckNameDuplicateAsync(int id, int subsystemId, int customId, string name)
|
||||||
{
|
{
|
||||||
var entity = await Context.Queryable<WarningRuleEntity>()
|
var list = await Context.Queryable<WarningRuleEntity>()
|
||||||
.Where(x => x.SubSystemId == subsystemId &&
|
.Where(x => x.SubSystemId == subsystemId &&
|
||||||
x.CustomId == customId
|
x.CustomId == customId
|
||||||
&& string.Equals(x.Name, name))
|
&& string.Equals(x.Name, name))
|
||||||
.FirstAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
// 如果是新增,则要求不能重复添加 subsystemId+customId+name三者都相同的
|
var entity = list.First();
|
||||||
if (id == 0)
|
|
||||||
return entity != null;
|
// 不重复
|
||||||
|
if (entity == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
// 如果是修改,则要求查出来的和要修改的是同一个,否则视为重复
|
// 如果是修改,则要求查出来的和要修改的是同一个,否则视为重复
|
||||||
return entity.Id != id;
|
return entity.Id != id;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user