diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/MenuNutritionMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/MenuNutritionMapper.java index 7ec2767..8327255 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/MenuNutritionMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/MenuNutritionMapper.java @@ -68,4 +68,7 @@ public interface MenuNutritionMapper { * @return 食材营养基础信息 */ MenuNutrition queryIfExistMenuNutrition(MenuNutrition menuNutrition); + + MenuNutrition getOneByCode(MenuNutrition menuNutrition); + MenuNutrition getOneByName(MenuNutrition menuNutrition); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuDishesServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuDishesServiceImpl.java index ece807d..0cf131b 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuDishesServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuDishesServiceImpl.java @@ -177,6 +177,15 @@ public class MenuDishesServiceImpl extends ServiceImpl materialList= menuDishesDTO.getMaterialList(); List nutritionEntityList = new ArrayList<>(); @@ -430,7 +439,15 @@ public class MenuDishesServiceImpl extends ServiceImpl 0L) { - throw new ServiceException(I18n.getMessage("添加物品已存在", new Object[0])); + throw new ServiceException("添加物品已存在"); } else { Long parentId = content.getParentId(); if (ObjectUtil.isNotNull(parentId) && parentId != -1L) { Long countParent = this.baseMapper.selectCount(Wrappers.lambdaQuery(MenuMaterialCategory.class) .eq(MenuMaterialCategory::getCategoryId, parentId)); if (ObjectUtil.isNull(countParent) || countParent <= 0L) { - throw new ServiceException(I18n.getMessage("菜单无父级节点", new Object[0])); + throw new ServiceException("菜单无父级节点"); } } @@ -237,7 +237,7 @@ public class MenuMaterialCategoryServiceImpl extends ServiceImpl0){ diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuNutritionServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuNutritionServiceImpl.java index c6091a3..a1c3d17 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuNutritionServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuNutritionServiceImpl.java @@ -91,10 +91,18 @@ public class MenuNutritionServiceImpl implements IMenuNutritionService { try { menuNutrition.setUpdateBy(SecurityUtils.getUsername()); menuNutrition.setUpdateTime(DateUtils.getNowDate()); + MenuNutrition getOneByCode =menuNutritionMapper.getOneByCode(menuNutrition); + if(getOneByCode != null){ + throw new ServiceException("营养编码重复"); + } + MenuNutrition getOneByName =menuNutritionMapper.getOneByName(menuNutrition); + if(getOneByName != null){ + throw new ServiceException("营养名称重复"); + } return menuNutritionMapper.updateMenuNutrition(menuNutrition); } catch (Exception e) { log.error("更新营养数据出错, ", e.getMessage()); - throw new ServiceException("更新营养数据出错"); + throw new ServiceException(e.getMessage()); } } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuRecipeServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuRecipeServiceImpl.java index cfc2d5c..9cbd234 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuRecipeServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuRecipeServiceImpl.java @@ -152,7 +152,7 @@ public class MenuRecipeServiceImpl extends ServiceImpl records = new ArrayList<>(); if (ObjectUtil.isEmpty(sortEnum)) { - throw new ServiceException(I18n.getMessage("参数错误", new Object[0])); + throw new ServiceException("参数错误"); }else{ content.setDeviceTypeList(sortEnum.getDeviceType()); content.setBindType(sortEnum.getBindType()); @@ -213,7 +213,7 @@ public class MenuRecipeServiceImpl extends ServiceImpl deviceSnList = this.menuRecipeMapper.getDeviceSnByIds(deviceInfoList); @@ -224,7 +224,7 @@ public class MenuRecipeServiceImpl extends ServiceImpl deviceTypeList = menuRecipeMapper.getDeviceIdByDevivce(null, String.valueOf(menuRecipe.getStallId())); if (ObjectUtil.isEmpty(sortEnum)) { - throw new ServiceException(I18n.getMessage("bingType值异常", new Object[0])); + throw new ServiceException("bingType值异常"); } else { List deviceTypes = sortEnum.getDeviceType(); if (content.getHandleType().equals(1)) { @@ -232,12 +232,12 @@ public class MenuRecipeServiceImpl extends ServiceImpl sourceRecipeList = this.menuRecipeMapper.selectRecipeInSameShop(menuRecipe.getStallId(), null, content.getBindType(), content.getMealLineId()); if (ObjectUtil.isNotEmpty(sourceRecipeList)) { @@ -439,7 +439,7 @@ public class MenuRecipeServiceImpl extends ServiceImpl 0L) { - throw new ServiceException(I18n.getMessage("菜单菜谱名称重复", new Object[0])); + throw new ServiceException("菜单菜谱名称重复"); } recipeId = Id.next(); recipe = new MenuRecipe(); @@ -513,9 +513,9 @@ public class MenuRecipeServiceImpl extends ServiceImpl 0) { - throw new ServiceException(I18n.getMessage("设备已被绑定", new Object[0])); + throw new ServiceException("菜谱已绑定设备"); } else if (appCount > 0) { - throw new ServiceException(I18n.getMessage("菜谱已绑定设备", new Object[0])); + throw new ServiceException("菜谱已绑定设备"); } else { // this.baseMapper.delete( Wrappers.lambdaUpdate(MenuRecipe.class) // .in(MenuRecipe::getRecipeId, recipeId)); @@ -1048,7 +1048,7 @@ private IMenuRecipeDetailService menuRecipeDetailService; .map(MenuRecipeDateAddDTO::getDetailList) .map(list -> list.get(0)) .map(MenuRecipeDetailAddDTO::getMealtimeType) - .orElseThrow(() -> new ServiceException(I18n.getMessage("详情id为空"))); + .orElseThrow(() -> new ServiceException("详情id为空")); } return menuRecipeMapper.selectDetailIds(getRecipeDto, mealType); } @@ -1064,7 +1064,7 @@ private IMenuRecipeDetailService menuRecipeDetailService; .map(MenuRecipeDateAddDTO::getDetailList) .map(list -> list.get(0)) .map(MenuRecipeDetailAddDTO::getMealtimeType) - .orElseThrow(() -> new ServiceException(I18n.getMessage("详情id为空"))); + .orElseThrow(() -> new ServiceException("详情id为空")); } return this.menuRecipeMapper.selectDetailsList(getRecipeDto, LocalDate.now(), mealType); } @@ -1266,7 +1266,7 @@ private IMenuRecipeDetailService menuRecipeDetailService; return x.getSizeType() != 3L; }).count(); if (count > 99L) { - throw new ServiceException(I18n.getMessage("菜谱信息达到上限", new Object[0])); + throw new ServiceException("菜谱信息达到上限"); } else { dishesList.stream().filter((x) -> { return x.getSizeType() == 3L; @@ -1277,7 +1277,7 @@ private IMenuRecipeDetailService menuRecipeDetailService; return Integer.valueOf(1).equals(d.getRecommendFlag()); }).count(); if (dishesCount > 3L) { - throw new ServiceException(I18n.getMessage("无推荐菜谱", new Object[0])); + throw new ServiceException("无推荐菜谱"); } } } diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuNutritionMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuNutritionMapper.xml index 7d836ed..2c2996b 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuNutritionMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuNutritionMapper.xml @@ -472,4 +472,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where nutrition_code = #{nutritionCode} or nutrition_name = #{nutritionName} limit 1 + + + +