change-params:预警规则主体查询增加客户id参数

This commit is contained in:
hardstylewyl 2025-03-25 14:57:01 +08:00
parent 261aa5110e
commit 84edc5644e
4 changed files with 12 additions and 7 deletions

View File

@ -11,10 +11,15 @@ public class GetWarningRuleInput
public int? SubSystemId { get; set; }
/// <summary>
/// 关键字(kpi/客户名称 模糊)
/// 关键字(kpi名称 模糊查询)
/// </summary>
public string? Keywords { get; set; }
/// <summary>
/// 客户id
/// </summary>
public int? CustomId { get; set; }
/// <summary>
/// 是否启用(留null查全部)
/// </summary>

View File

@ -38,7 +38,7 @@ public class WarningService : ApplicationService
[HttpPost("GetWarningRule")]
public async Task<UnifyResultDto<List<WarningRuleDto>>> GetWarningRule(GetWarningRuleInput input)
{
var result = await _warningRuleRepository.GetWarningRuleListAsync(input.SubSystemId, input.Keywords, input.IsEnabled, input.WarningType);
var result = await _warningRuleRepository.GetWarningRuleListAsync(input.SubSystemId, input.CustomId, input.Keywords, input.IsEnabled, input.WarningType);
if (result.Count == 0)
return new UnifyResultDto<List<WarningRuleDto>>(true, new List<WarningRuleDto>());

View File

@ -25,7 +25,7 @@ public interface IWarningRuleRepository : IBasicRepository<WarningRuleEntity>
Task<string> UpdateVersionAsync(WarningRuleEntity entity);
// 模糊查询预警规则主体
Task<List<WarningRuleEntity>> GetWarningRuleListAsync(int? subsystemId, string? keyword, bool? isEnabled, int? warningType);
Task<List<WarningRuleEntity>> GetWarningRuleListAsync(int? subsystemId, int? customId, string? keyword, bool? isEnabled, int? warningType);
// 获取启用的预警规则主体
Task<WarningRuleEntity?> GetWarningRuleForEnabledAsync(int subSystemId, int customId, WarningRuleType warningType);

View File

@ -76,14 +76,14 @@ public class WarningRuleRepository : BasicRepository<WarningRuleEntity>, IWarnin
return version;
}
public Task<List<WarningRuleEntity>> GetWarningRuleListAsync(int? subsystemId, string? keywords, bool? isEnabled, int? warningType)
public Task<List<WarningRuleEntity>> GetWarningRuleListAsync(int? subsystemId, int? customId, string? keywords, bool? isEnabled, int? warningType)
{
return Context.Queryable<WarningRuleEntity>()
.WhereIF(customId.HasValue, x => x.CustomId == customId!.Value)
.WhereIF(subsystemId.HasValue, x => x.SubSystemId == subsystemId!.Value)
// todo: 客户/kpi名称 改成客户下拉
.WhereIF(!string.IsNullOrWhiteSpace(keywords), x => x.Name.Contains(keywords!))
.WhereIF(isEnabled.HasValue, x => x.IsEnabled == isEnabled!.Value)
.WhereIF(warningType.HasValue, x => x.WarningType == warningType!.Value)
.WhereIF(isEnabled.HasValue, x => x.IsEnabled == isEnabled!.Value)
.WhereIF(!string.IsNullOrWhiteSpace(keywords), x => x.Name.Contains(keywords!))
.ToListAsync();
}