Ver código fonte

BUGFix:2424 价目表(0115):菜品新建页面,预约规则未设置为必填项

panzhilin 3 meses atrás
pai
commit
7af619b350

+ 15 - 1
alien-store/src/main/java/shop/alien/store/service/impl/StoreCuisineServiceImpl.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import lombok.RequiredArgsConstructor;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -22,7 +23,6 @@ import shop.alien.store.service.StoreCuisineService;
 
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -49,6 +49,13 @@ public class StoreCuisineServiceImpl extends ServiceImpl<StoreCuisineMapper, Sto
      */
     @Override
     public boolean addCuisineCombo(CuisineComboDto cuisineComboDto) {
+        // 验证:如果需要预约,预约规则必填
+        if (cuisineComboDto.getNeedReserve() != null && cuisineComboDto.getNeedReserve() == 1) {
+            if (StringUtils.isBlank(cuisineComboDto.getReserveRule())) {
+                throw new IllegalArgumentException("需要预约时,预约规则不能为空");
+            }
+        }
+        
         // 1. 保存主表信息到 store_cuisine
         StoreCuisine cuisine = new StoreCuisine();
         BeanUtils.copyProperties(cuisineComboDto, cuisine);
@@ -70,6 +77,13 @@ public class StoreCuisineServiceImpl extends ServiceImpl<StoreCuisineMapper, Sto
      */
     @Override
     public boolean updateCuisineCombo(CuisineComboDto cuisineComboDto) {
+        // 验证:如果需要预约,预约规则必填
+        if (cuisineComboDto.getNeedReserve() != null && cuisineComboDto.getNeedReserve() == 1) {
+            if (StringUtils.isBlank(cuisineComboDto.getReserveRule())) {
+                throw new IllegalArgumentException("需要预约时,预约规则不能为空");
+            }
+        }
+        
         Integer comboId = cuisineComboDto.getId();
 
         // 1. 更新主表信息