change:修改预警规则时效添加参数校验

This commit is contained in:
xiaolipro 2024-09-30 10:54:49 +08:00
parent bf5f9662a9
commit 39e2dab9cc

View File

@ -184,6 +184,15 @@ public class ForewarningService : ApplicationService
public async Task<bool> ModifyTimeSpans(ModifyTimeSpanInput input) public async Task<bool> ModifyTimeSpans(ModifyTimeSpanInput input)
{ {
if (input.Items.IsNullOrEmpty()) return false; if (input.Items.IsNullOrEmpty()) return false;
if (input.Items.Any(x => x.TotalTimeSpan < x.WarnTimeSpan))
{
throw new BusinessException(message: "预警时效不能小于预警提醒时效");
}
if (input.Items.Any(x => x.WarnCount is < 1 or > 10))
{
throw new BusinessException(message: "预警次数范围为1-10");
}
var warning = await _warningRepository.GetFirstAsync(x => x.Id == input.WarningId); var warning = await _warningRepository.GetFirstAsync(x => x.Id == input.WarningId);
if (warning == null) if (warning == null)