From e786f8d53a358ed6e840156faa8c179b70e05ae4 Mon Sep 17 00:00:00 2001
From: sxu <602087911@qq.com>
Date: Wed, 28 May 2025 10:20:08 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=8F=9C=E8=B0=B1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../bonus/canteen/core/cook/mapper/CookRecipeMapper.java | 2 ++
.../core/cook/service/impl/CookRecipeServiceImpl.java | 5 ++++-
.../src/main/resources/mapper/cook/CookRecipeMapper.xml | 9 ++++++++-
3 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookRecipeMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookRecipeMapper.java
index 6d8c4c5..a172929 100644
--- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookRecipeMapper.java
+++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookRecipeMapper.java
@@ -19,6 +19,8 @@ public interface CookRecipeMapper {
*/
public CookRecipe selectCookRecipeByRecipeId(Long recipeId);
+ public CookRecipe selectCookRecipeByRecipeName(String recipeName);
+
/**
* 查询菜品计划信息列表
*
diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceImpl.java
index 20e5fc6..f8289e9 100644
--- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceImpl.java
+++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceImpl.java
@@ -78,7 +78,10 @@ public class CookRecipeServiceImpl implements ICookRecipeService {
cookRecipeDTO.setCreateTime(DateUtils.getNowDate());
cookRecipeDTO.setCreateBy(SecurityUtils.getUsername());
try {
- //TODO 判断名字是否重复
+ CookRecipe cookRecipe = cookRecipeMapper.selectCookRecipeByRecipeName(cookRecipeDTO.getRecipeName());
+ if (Objects.nonNull(cookRecipe)) {
+ throw new ServiceException("该菜谱名称已存在,请重新输入");
+ }
int count = cookRecipeMapper.insertCookRecipe(cookRecipeDTO); //插入菜谱
createRecipeDetails(cookRecipeDTO, true);
return count;
diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeMapper.xml
index b218dcd..15192d2 100644
--- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeMapper.xml
+++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeMapper.xml
@@ -19,7 +19,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- select recipe_id, recipe_name, recipe_type, stall_id, canteen_id, plan_id, effect_date, expire_date, create_by, create_time, update_by, update_time from cook_recipe
+ select recipe_id, recipe_name, recipe_type, stall_id, canteen_id, plan_id, effect_date,
+ expire_date, create_by, create_time, update_by, update_time
+ from cook_recipe
+
+
insert into cook_recipe