菜品新增修改,重复菜品和编号判断优化

This commit is contained in:
jjLv 2025-05-14 15:41:09 +08:00
parent 41e65e2a01
commit 882dfd0933
2 changed files with 21 additions and 5 deletions

View File

@ -193,7 +193,10 @@ public class MenuRecipeController extends BaseController {
return ObjectUtil.isNull(excel) ? AjaxResult.error("请选择导入文件 ^_^") :
AjaxResult.success(this.menuRecipeService.recipeImportDishes(excel, recipeId));
}catch (Exception e){
throw new ServiceException(e.toString());
String message = e.toString();
//取倒数第二个之后的信息
String finalMessage = message.substring(message.lastIndexOf(":") - 7);
throw new ServiceException(finalMessage.replace("Error", ""));
}
}

View File

@ -401,15 +401,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getOneByName" parameterType="com.bonus.canteen.core.menu.dto.MenuDishesDTO" resultMap="MenuDishesResult">
select * from menu_dishes where area_id = #{areaId} and (
dishes_name = #{dishesName}
) limit 1
select * from menu_dishes
where 1 = 1
<if test="areaId != null and areaId != ''">
and area_id = #{areaId}
</if>
and (dishes_name = #{dishesName})
<if test="dishesId != null and dishesId != ''">
and dishes_id != #{dishesId}
</if>
limit 1
</select>
<select id="getOneByNum" parameterType="com.bonus.canteen.core.menu.dto.MenuDishesDTO" resultMap="MenuDishesResult">
select * from menu_dishes where area_id = #{areaId}
select * from menu_dishes where 1 = 1
<if test="areaId != null and areaId != ''">
and area_id = #{areaId}
</if>
<if test="dishesNum !=null and dishesNum !=''">
and dishes_num =#{dishesNum}
</if>
<if test="dishesId != null and dishesId != ''">
and dishes_id != #{dishesId}
</if>
limit 1
</select>