From d61236480ac041147a67a0e5697588d2bb05e94c Mon Sep 17 00:00:00 2001 From: lihongjie0209 Date: Thu, 2 May 2024 09:28:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CoalWashingDailyAnalysisService.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/service/CoalWashingDailyAnalysisService.java b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/service/CoalWashingDailyAnalysisService.java index b8cead4e..02f677f6 100644 --- a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/service/CoalWashingDailyAnalysisService.java +++ b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/service/CoalWashingDailyAnalysisService.java @@ -17,6 +17,7 @@ import jakarta.annotation.PostConstruct; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.convert.ConversionService; import org.springframework.data.domain.Page; @@ -45,10 +46,25 @@ public class CoalWashingDailyAnalysisService CoalWashingDailyAnalysisEntity entity = mapper.toEntity(request); entity.setOrganizationId(Ctx.currentUser().getOrganizationId()); + validate(entity); this.repository.save(entity); return getById(entity.getId()); } + private void validate(CoalWashingDailyAnalysisEntity entity) { + + + if (CollectionUtils.isNotEmpty(entity.getInputItems())){ + entity.getInputItems().forEach(item -> { + if (item.getTime() == null){ + throw new BizException("时间不能为空"); + } + + }); + } + + } + public CoalWashingDailyAnalysisDto calculate(CreateCoalWashingDailyAnalysisDto request) { CoalWashingDailyAnalysisEntity entity = mapper.toEntity(request); @@ -69,6 +85,10 @@ public class CoalWashingDailyAnalysisService this.mapper.updateEntity(entity, request); entity.setOrganizationId(Ctx.currentUser().getOrganizationId()); + + + validate(entity); + this.repository.save(entity); return getById(entity.getId());