From 84edc5644e2cf964822555d56fd809d57080afcc Mon Sep 17 00:00:00 2001 From: hardstylewyl <827778732@qq.com> Date: Tue, 25 Mar 2025 14:57:01 +0800 Subject: [PATCH] =?UTF-8?q?change-params:=E9=A2=84=E8=AD=A6=E8=A7=84?= =?UTF-8?q?=E5=88=99=E4=B8=BB=E4=BD=93=E6=9F=A5=E8=AF=A2=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=AE=A2=E6=88=B7id=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/Warning/GetWarningRuleInput.cs | 7 ++++++- .../Services/Warning/WarningService.cs | 2 +- .../Aggregates/WarningAggregate/IWarningRuleRepository.cs | 2 +- .../Repositories/WarningRuleRepository.cs | 8 ++++---- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/SJZY.Track.Application.Contract/Dtos/Warning/GetWarningRuleInput.cs b/src/SJZY.Track.Application.Contract/Dtos/Warning/GetWarningRuleInput.cs index 8fe2a151..8ec6831e 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/Warning/GetWarningRuleInput.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/Warning/GetWarningRuleInput.cs @@ -11,10 +11,15 @@ public class GetWarningRuleInput public int? SubSystemId { get; set; } /// - /// 关键字(kpi/客户名称 模糊) + /// 关键字(kpi名称 模糊查询) /// public string? Keywords { get; set; } + /// + /// 客户id + /// + public int? CustomId { get; set; } + /// /// 是否启用(留null查全部) /// diff --git a/src/SJZY.Track.Application/Services/Warning/WarningService.cs b/src/SJZY.Track.Application/Services/Warning/WarningService.cs index 478883b6..ced9e491 100644 --- a/src/SJZY.Track.Application/Services/Warning/WarningService.cs +++ b/src/SJZY.Track.Application/Services/Warning/WarningService.cs @@ -38,7 +38,7 @@ public class WarningService : ApplicationService [HttpPost("GetWarningRule")] public async Task>> 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>(true, new List()); diff --git a/src/SJZY.Track.Domain/Aggregates/WarningAggregate/IWarningRuleRepository.cs b/src/SJZY.Track.Domain/Aggregates/WarningAggregate/IWarningRuleRepository.cs index 13df653f..b137a06c 100644 --- a/src/SJZY.Track.Domain/Aggregates/WarningAggregate/IWarningRuleRepository.cs +++ b/src/SJZY.Track.Domain/Aggregates/WarningAggregate/IWarningRuleRepository.cs @@ -25,7 +25,7 @@ public interface IWarningRuleRepository : IBasicRepository Task UpdateVersionAsync(WarningRuleEntity entity); // 模糊查询预警规则主体 - Task> GetWarningRuleListAsync(int? subsystemId, string? keyword, bool? isEnabled, int? warningType); + Task> GetWarningRuleListAsync(int? subsystemId, int? customId, string? keyword, bool? isEnabled, int? warningType); // 获取启用的预警规则主体 Task GetWarningRuleForEnabledAsync(int subSystemId, int customId, WarningRuleType warningType); diff --git a/src/SJZY.Track.Repository/Repositories/WarningRuleRepository.cs b/src/SJZY.Track.Repository/Repositories/WarningRuleRepository.cs index 13d7c255..811dbe8e 100644 --- a/src/SJZY.Track.Repository/Repositories/WarningRuleRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/WarningRuleRepository.cs @@ -76,14 +76,14 @@ public class WarningRuleRepository : BasicRepository, IWarnin return version; } - public Task> GetWarningRuleListAsync(int? subsystemId, string? keywords, bool? isEnabled, int? warningType) + public Task> GetWarningRuleListAsync(int? subsystemId, int? customId, string? keywords, bool? isEnabled, int? warningType) { return Context.Queryable() + .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(); }