From 558664b2df897013f1334f4a32d2b886e4092c9a Mon Sep 17 00:00:00 2001 From: lch <1627445470@qq.com> Date: Fri, 31 May 2024 15:50:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=B5=E4=BB=B7=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BasicConfig/BaseConfigController.cs | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/WebStarter/Controllers/BasicConfig/BaseConfigController.cs b/WebStarter/Controllers/BasicConfig/BaseConfigController.cs index 17f2805..263e4b7 100644 --- a/WebStarter/Controllers/BasicConfig/BaseConfigController.cs +++ b/WebStarter/Controllers/BasicConfig/BaseConfigController.cs @@ -191,10 +191,9 @@ namespace WebStarter.Controllers.BasicConfig StartTime = new TimeSpan(item.StartHour, item.StartMinute, item.StartSecond), EndTime = new TimeSpan(item.EndHour, item.EndMinute, item.EndSecond), Price = item.Price, - Type = item.Price + Type = item.Type }); } - return Result>.Success(elecPriceModelVersionDetailResps); } @@ -257,14 +256,6 @@ namespace WebStarter.Controllers.BasicConfig { Result.Fail("参数不能为空"); } - - List modelFromDbs = - await _elecPriceModelVersionDetailServices.QueryListByClauseAsync(u => u.Version == model[0].Version); - if (modelFromDbs != null) - { - await _elecPriceModelVersionDetailServices.DeleteAsync(i => i.Version == model[0].Version); - } - List elecPriceModelVersionDetails = new List(); foreach (var item in model) { @@ -281,14 +272,19 @@ namespace WebStarter.Controllers.BasicConfig Type = item.Type }); } + if (!TimeListIfContains(elecPriceModelVersionDetails)) + { + return Result.Fail("时间区间重复请检查"); + } - if (TimeListIfContains(elecPriceModelVersionDetails)) + List modelFromDbs = await _elecPriceModelVersionDetailServices.QueryListByClauseAsync(u => u.Version == model[0].Version); + if (modelFromDbs != null) { - await _elecPriceModelVersionDetailServices.InsertAsync(elecPriceModelVersionDetails); - return Result.Success(true); + await _elecPriceModelVersionDetailServices.DeleteAsync(i => i.Version == model[0].Version); } + await _elecPriceModelVersionDetailServices.InsertAsync(elecPriceModelVersionDetails); + return Result.Success(true); - return Result.Fail("时间区间重复请检查"); } @@ -300,7 +296,7 @@ namespace WebStarter.Controllers.BasicConfig [ApiExplorerSettings(IgnoreApi = true)] public bool TimeListIfContains(List timePeriods) { - bool hasOverlap = true; + bool notHasOverlap = true; for (int i = 0; i < timePeriods.Count; i++) { @@ -308,13 +304,13 @@ namespace WebStarter.Controllers.BasicConfig { if (timePeriods[i].Contains(timePeriods[j]) || timePeriods[j].Contains(timePeriods[i])) { - hasOverlap = false; - return hasOverlap; + notHasOverlap = false; + return notHasOverlap; } } } - return hasOverlap; + return notHasOverlap; } ///