mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
增加校验
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user