diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookNutritionTypeServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookNutritionTypeServiceImpl.java index e20f1bb..cef73b5 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookNutritionTypeServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookNutritionTypeServiceImpl.java @@ -60,7 +60,7 @@ public class CookNutritionTypeServiceImpl implements ICookNutritionTypeService { throw new ServiceException("营养类别名称不能为空"); } try { - if (cookNutritionType.getParentId() == null){ + if (cookNutritionType.getParentId() == null || cookNutritionType.getParentId() == 0L){ cookNutritionType.setParentId(0L); cookNutritionType.setLevel("0"); }else{ @@ -93,11 +93,11 @@ public class CookNutritionTypeServiceImpl implements ICookNutritionTypeService { if (StringUtils.isBlank(cookNutritionType.getNutritionTypeName())){ throw new ServiceException("营养类别名称不能为空"); } - if (cookNutritionType.getParentId() == null){ + if (cookNutritionType.getParentId() == null || cookNutritionType.getParentId() == 0L){ cookNutritionType.setParentId(0L); - cookNutritionType.setLevel("1"); + cookNutritionType.setLevel("0"); }else{ - cookNutritionType.setLevel("2"); + cookNutritionType.setLevel("1"); } //判断名称是否重复 CookNutritionType nutritionType = cookNutritionTypeMapper.selectCookNutritionTypeByNutritionTypeName(cookNutritionType.getNutritionTypeName(),cookNutritionType.getNutritionTypeId());