From b4e66b2cdab28a0bbfc1524378d5b8fcf281e9e9 Mon Sep 17 00:00:00 2001 From: huangdeliang <huangdeliang@skieer.com> Date: Thu, 25 Mar 2021 16:42:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A3=9F=E6=9D=90=EF=BC=8C?= =?UTF-8?q?=E8=8F=9C=E5=93=81=E5=88=A0=E9=99=A4=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom/SysDishesController.java | 6 +- .../custom/SysIngredientController.java | 6 +- .../controller/custom/SysWapController.java | 12 ++- .../custom/mapper/SysIngredientMapper.java | 6 +- .../custom/service/ISysDishesService.java | 2 +- .../custom/service/ISysIngredientService.java | 2 +- .../service/impl/SysDishesServiceImpl.java | 12 +-- .../impl/SysIngredientServiceImpl.java | 28 +++--- .../mapper/custom/SysDishesMapper.xml | 88 ++++++++++--------- .../mapper/custom/SysIngredientMapper.xml | 38 ++++---- stdiet-ui/src/store/modules/recipes.js | 2 + stdiet-ui/src/views/custom/dishes/index.vue | 5 +- .../src/views/custom/ingredient/index.vue | 5 +- .../RecipesView/RecipesCom/index.vue | 10 +++ 14 files changed, 119 insertions(+), 103 deletions(-) diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysDishesController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysDishesController.java index cefa94b18..513f585d4 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysDishesController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysDishesController.java @@ -116,8 +116,8 @@ public class SysDishesController extends BaseController { */ @PreAuthorize("@ss.hasPermi('custom:dishes:remove')") @Log(title = "菜品", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable Long[] ids) { - return toAjax(sysDishesService.deleteSysDishesByIds(ids)); + @DeleteMapping("/{id}") + public AjaxResult remove(@PathVariable Long id) { + return toAjax(sysDishesService.deleteSysDishesById(id)); } } \ No newline at end of file diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysIngredientController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysIngredientController.java index e28d40ab7..c5483e276 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysIngredientController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysIngredientController.java @@ -98,9 +98,9 @@ public class SysIngredientController extends BaseController */ @PreAuthorize("@ss.hasPermi('custom:ingredient:remove')") @Log(title = "食材", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable Long[] ids) + @DeleteMapping("/{id}") + public AjaxResult remove(@PathVariable Long id) { - return toAjax(sysIngredientService.deleteSysIngredientByIds(ids)); + return toAjax(sysIngredientService.deleteSysIngredientById(id)); } } \ No newline at end of file diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysWapController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysWapController.java index 02f239ff9..4acf10865 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysWapController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysWapController.java @@ -11,6 +11,10 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + @RestController @RequestMapping("/wap") public class SysWapController extends BaseController { @@ -69,11 +73,17 @@ public class SysWapController extends BaseController { /** * 获取完整食谱 + * * @param id * @return */ - @GetMapping(value = "recipes/{id}") + @GetMapping(value = "/recipes/{id}") public AjaxResult recipesDetail(@PathVariable Long id) { return AjaxResult.success(iSysRecipesService.selectSysRecipesByRecipesId(id)); } + +// @GetMapping(value = "/qrcode") +// public void qrcodeRediredt(String group, HttpServletRequest request, HttpServletResponse response) throws IOException { +// response.sendRedirect("https://weibo.com/u/1913360251"); +// } } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysIngredientMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysIngredientMapper.java index e8f7a718e..063113307 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysIngredientMapper.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysIngredientMapper.java @@ -61,7 +61,7 @@ public interface SysIngredientMapper { * @param ids 需要删除的数据ID * @return 结果 */ - int deleteSysIngredientByIds(Long[] ids); +// int deleteSysIngredientByIds(Long[] ids); int batchIngredientRec(List<SysIngredientRec> ingredientRecList); @@ -71,9 +71,9 @@ public interface SysIngredientMapper { int deleteIngredientNotRecByIngredientId(Long notRecId); - int deleteIngredientRecByIngredientIds(Long[] id); +// int deleteIngredientRecByIngredientIds(Long[] id); - int deleteIngredientNotRecByIngredientIds(Long[] id); +// int deleteIngredientNotRecByIngredientIds(Long[] id); /** * 根据食材名称查询食材信息 diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysDishesService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysDishesService.java index baecbb30f..d10d38c01 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysDishesService.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysDishesService.java @@ -53,7 +53,7 @@ public interface ISysDishesService * @param ids 需要删除的菜品ID * @return 结果 */ - public int deleteSysDishesByIds(Long[] ids); +// public int deleteSysDishesByIds(Long[] ids); /** * 删除菜品信息 diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysIngredientService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysIngredientService.java index 0d8f10d61..026453ffa 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysIngredientService.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysIngredientService.java @@ -49,7 +49,7 @@ public interface ISysIngredientService * @param ids 需要删除的食材ID * @return 结果 */ - public int deleteSysIngredientByIds(Long[] ids); +// public int deleteSysIngredientByIds(Long[] ids); /** * 删除食材信息 diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysDishesServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysDishesServiceImpl.java index 39ada4428..322b978ba 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysDishesServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysDishesServiceImpl.java @@ -107,11 +107,11 @@ public class SysDishesServiceImpl implements ISysDishesService { * @param ids 需要删除的菜品ID * @return 结果 */ - @Override - public int deleteSysDishesByIds(Long[] ids) { - sysDishesMapper.deleteIngredientByIds(ids); - return sysDishesMapper.deleteSysDishesByIds(ids); - } +// @Override +// public int deleteSysDishesByIds(Long[] ids) { +// sysDishesMapper.deleteIngredientByIds(ids); +// return sysDishesMapper.deleteSysDishesByIds(ids); +// } /** * 删除菜品信息 @@ -121,7 +121,7 @@ public class SysDishesServiceImpl implements ISysDishesService { */ @Override public int deleteSysDishesById(Long id) { - sysDishesMapper.deleteIngredientById(id); +// sysDishesMapper.deleteIngredientById(id); return sysDishesMapper.deleteSysDishesById(id); } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysIngredientServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysIngredientServiceImpl.java index d12714b31..50cb3f521 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysIngredientServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysIngredientServiceImpl.java @@ -169,18 +169,18 @@ public class SysIngredientServiceImpl implements ISysIngredientService { return sysIngredientMapper.updateSysIngredient(sysIngredient); } - /** - * 批量删除食材 - * - * @param ids 需要删除的食材ID - * @return 结果 - */ - @Override - public int deleteSysIngredientByIds(Long[] ids) { - sysIngredientMapper.deleteIngredientRecByIngredientIds(ids); - sysIngredientMapper.deleteIngredientNotRecByIngredientIds(ids); - return sysIngredientMapper.deleteSysIngredientByIds(ids); - } +// /** +// * 批量删除食材 +// * +// * @param ids 需要删除的食材ID +// * @return 结果 +// */ +// @Override +// public int deleteSysIngredientByIds(Long[] ids) { +// sysIngredientMapper.deleteIngredientRecByIngredientIds(ids); +// sysIngredientMapper.deleteIngredientNotRecByIngredientIds(ids); +// return sysIngredientMapper.deleteSysIngredientByIds(ids); +// } /** * 删除食材信息 @@ -190,8 +190,8 @@ public class SysIngredientServiceImpl implements ISysIngredientService { */ @Override public int deleteSysIngredientById(Long id) { - sysIngredientMapper.deleteIngredientRecByIngredientId(id); - sysIngredientMapper.deleteIngredientNotRecByIngredientId(id); +// sysIngredientMapper.deleteIngredientRecByIngredientId(id); +// sysIngredientMapper.deleteIngredientNotRecByIngredientId(id); return sysIngredientMapper.deleteSysIngredientById(id); } diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysDishesMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysDishesMapper.xml index 3b13adebe..a9a167234 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysDishesMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysDishesMapper.xml @@ -5,37 +5,37 @@ <mapper namespace="com.stdiet.custom.mapper.SysDishesMapper"> <resultMap type="SysDishes" id="SysDishesResult"> - <result property="id" column="id" /> - <result property="name" column="name" /> - <result property="bigClass" column="big_class" /> - <result property="smallClass" column="small_class" /> - <result property="type" column="type" /> - <result property="isMain" column="is_main" /> - <result property="methods" column="methods" /> - <result property="reviewStatus" column="review_status" /> - <result property="createBy" column="create_by" /> - <result property="createTime" column="create_time" /> - <result property="updateBy" column="update_by" /> - <result property="updateTime" column="update_time" /> + <result property="id" column="id"/> + <result property="name" column="name"/> + <result property="bigClass" column="big_class"/> + <result property="smallClass" column="small_class"/> + <result property="type" column="type"/> + <result property="isMain" column="is_main"/> + <result property="methods" column="methods"/> + <result property="reviewStatus" column="review_status"/> + <result property="createBy" column="create_by"/> + <result property="createTime" column="create_time"/> + <result property="updateBy" column="update_by"/> + <result property="updateTime" column="update_time"/> <!-- 非持久化字段 --> - <result property="bigClassName" column="bigClassName" /> - <result property="smallClassName" column="smallClassName" /> + <result property="bigClassName" column="bigClassName"/> + <result property="smallClassName" column="smallClassName"/> </resultMap> <resultMap type="SysDishesIngredient" id="SysDishesIngredientResult"> - <result property="id" column="id" /> - <result property="name" column="name" /> - <result property="type" column="type" /> - <result property="proteinRatio" column="protein_ratio" /> - <result property="fatRatio" column="fat_ratio" /> - <result property="carbonRatio" column="carbon_ratio" /> - <result property="area" column="area" /> - <result property="rec" column="rec" /> - <result property="notRec" column="not_rec" /> - <result property="cusWeight" column="cus_weight" /> - <result property="cusUnit" column="cus_unit" /> - <result property="weight" column="weight" /> + <result property="id" column="id"/> + <result property="name" column="name"/> + <result property="type" column="type"/> + <result property="proteinRatio" column="protein_ratio"/> + <result property="fatRatio" column="fat_ratio"/> + <result property="carbonRatio" column="carbon_ratio"/> + <result property="area" column="area"/> + <result property="rec" column="rec"/> + <result property="notRec" column="not_rec"/> + <result property="cusWeight" column="cus_weight"/> + <result property="cusUnit" column="cus_unit"/> + <result property="weight" column="weight"/> </resultMap> <sql id="selectSysDishesVo"> @@ -45,12 +45,13 @@ <select id="selectSysDishesList" parameterType="SysDishes" resultMap="SysDishesResult"> <include refid="selectSysDishesVo"/> <where> - <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> - <if test="type != null and type != ''"> and FIND_IN_SET(#{type}, type)</if> - <if test="bigClass != null"> and big_class = #{bigClass}</if> - <if test="smallClass != null"> and small_class = #{smallClass}</if> - <if test="reviewStatus != null and type != ''"> and review_status = #{reviewStatus}</if> - <if test="isMain != null and type != ''"> and is_main = #{isMain}</if> + <if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if> + <if test="type != null and type != ''">and FIND_IN_SET(#{type}, type)</if> + <if test="bigClass != null">and big_class = #{bigClass}</if> + <if test="smallClass != null">and small_class = #{smallClass}</if> + <if test="reviewStatus != null and type != ''">and review_status = #{reviewStatus}</if> + <if test="isMain != null and type != ''">and is_main = #{isMain}</if> + <if test="true">and del_flag=0</if> </where> order by id desc </select> @@ -82,7 +83,7 @@ </sql> <select id="selectSysIngreditentsById" parameterType="Long" resultMap="SysDishesIngredientResult"> - <include refid="selectSysIngreditentsByIdVo" > + <include refid="selectSysIngreditentsByIdVo"> <property name="id" value="#{id}"/> </include> </select> @@ -140,16 +141,16 @@ where id = #{id} </update> - <delete id="deleteSysDishesById" parameterType="Long"> - delete from sys_dishes where id = #{id} - </delete> + <update id="deleteSysDishesById" parameterType="Long"> + update sys_dishes set del_flag=1 where id = #{id} + </update> - <delete id="deleteSysDishesByIds" parameterType="String"> - delete from sys_dishes where id in - <foreach item="id" collection="array" open="(" separator="," close=")"> - #{id} - </foreach> - </delete> + <!-- <delete id="deleteSysDishesByIds" parameterType="String">--> + <!-- delete from sys_dishes where id in--> + <!-- <foreach item="id" collection="array" open="(" separator="," close=")">--> + <!-- #{id}--> + <!-- </foreach>--> + <!-- </delete>--> <delete id="deleteIngredientById" parameterType="Long"> delete from sys_dishes_ingredient where dishes_id = #{id} @@ -163,7 +164,8 @@ </delete> <insert id="bashInsertDishesIngredent"> - insert into sys_dishes_ingredient(dishes_id, ingredient_id, ingredient_weight, cus_unit, cus_weight, remark) values + insert into sys_dishes_ingredient(dishes_id, ingredient_id, ingredient_weight, cus_unit, cus_weight, remark) + values <foreach collection="list" separator="," item="item" index="index"> (#{item.dishesId}, #{item.ingredientId}, #{item.weight}, #{item.cusUnit}, #{item.cusWeight}, #{item.remark}) </foreach> diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysIngredientMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysIngredientMapper.xml index e1b867059..c5d659d78 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysIngredientMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysIngredientMapper.xml @@ -103,6 +103,7 @@ <if test="type != null and type != ''">and type = #{type}</if> <if test="area != null and area != ''">and area = #{area}</if> <if test="reviewStatus != null and reviewStatus != ''">and review_status = #{reviewStatus}</if> + <if test="true">and del_flag=0</if> </where> </select> @@ -167,19 +168,19 @@ delete from sys_ingredient_not_rec where ingredient_id=#{ingredientId} </delete> - <delete id="deleteIngredientRecByIngredientIds" parameterType="Long"> - delete from sys_ingredient_rec where ingredient_id in - <foreach item="id" collection="array" open="(" separator="," close=")"> - #{id} - </foreach> - </delete> + <!-- <delete id="deleteIngredientRecByIngredientIds" parameterType="Long">--> + <!-- delete from sys_ingredient_rec where ingredient_id in--> + <!-- <foreach item="id" collection="array" open="(" separator="," close=")">--> + <!-- #{id}--> + <!-- </foreach>--> + <!-- </delete>--> - <delete id="deleteIngredientNotRecByIngredientIds" parameterType="String"> - delete from sys_ingredient_not_rec where ingredient_id in - <foreach item="id" collection="array" open="(" separator="," close=")"> - #{id} - </foreach> - </delete> + <!-- <delete id="deleteIngredientNotRecByIngredientIds" parameterType="String">--> + <!-- delete from sys_ingredient_not_rec where ingredient_id in--> + <!-- <foreach item="id" collection="array" open="(" separator="," close=")">--> + <!-- #{id}--> + <!-- </foreach>--> + <!-- </delete>--> <update id="updateSysIngredient" parameterType="SysIngredient"> update sys_ingredient @@ -201,16 +202,9 @@ where id = #{id} </update> - <delete id="deleteSysIngredientById" parameterType="Long"> - delete from sys_ingredient where id = #{id} - </delete> - - <delete id="deleteSysIngredientByIds" parameterType="String"> - delete from sys_ingredient where id in - <foreach item="id" collection="array" open="(" separator="," close=")"> - #{id} - </foreach> - </delete> + <update id="deleteSysIngredientById" parameterType="Long"> + update sys_ingredient set del_flag=1 where id = #{id} + </update> <!-- 根据食材名称查询食材 --> <select id="selectSysIngredientByName" parameterType="String" resultMap="SysIngredientResult"> diff --git a/stdiet-ui/src/store/modules/recipes.js b/stdiet-ui/src/store/modules/recipes.js index a4187059b..abf69b5c3 100644 --- a/stdiet-ui/src/store/modules/recipes.js +++ b/stdiet-ui/src/store/modules/recipes.js @@ -437,6 +437,8 @@ const actions = { const result = await updateDishesDetailApi(params); if (result.code === 200) { commit("updateRecipesDishesDetail", payload); + } else { + return new Promise((res, rej) => rej(result.msg)); } } } else { diff --git a/stdiet-ui/src/views/custom/dishes/index.vue b/stdiet-ui/src/views/custom/dishes/index.vue index 532a79f82..cd0424756 100644 --- a/stdiet-ui/src/views/custom/dishes/index.vue +++ b/stdiet-ui/src/views/custom/dishes/index.vue @@ -374,14 +374,13 @@ export default { }, /** 删除按钮操作 */ handleDelete(row) { - const ids = row.id || this.ids; - this.$confirm('是否确认删除菜品编号为"' + ids + '"的数据项?', "警告", { + this.$confirm('是否确认删除菜品「' + row.name + '」的数据项?', "警告", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning", }) .then(function () { - return delDishes(ids); + return delDishes(row.id); }) .then(() => { this.getList(); diff --git a/stdiet-ui/src/views/custom/ingredient/index.vue b/stdiet-ui/src/views/custom/ingredient/index.vue index 39448ba95..58a8962d3 100644 --- a/stdiet-ui/src/views/custom/ingredient/index.vue +++ b/stdiet-ui/src/views/custom/ingredient/index.vue @@ -664,14 +664,13 @@ export default { }, /** 删除按钮操作 */ handleDelete(row) { - const ids = row.id || this.ids; - this.$confirm('是否确认删除食材编号为"' + ids + '"的数据项?', "警告", { + this.$confirm("是否确认删除食材「" + row.name + "」的数据项?", "警告", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning", }) .then(function () { - return delIngredient(ids); + return delIngredient(row.id); }) .then(() => { this.getList(); diff --git a/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesCom/index.vue b/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesCom/index.vue index 09e4b4fd6..c32af5eb9 100644 --- a/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesCom/index.vue +++ b/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesCom/index.vue @@ -504,6 +504,8 @@ export default { igdId: data.igdId, weight, actionType: "weight", + }).catch((err) => { + this.$message.error(err); }); }, handleOnCustomUnitChange(data, { cusWeight, cusUnit }) { @@ -517,6 +519,8 @@ export default { cusWeight, cusUnit, actionType: "unit", + }).catch((err) => { + this.$message.error(err); }); }, handleOnDishesConfirm({ type, data }) { @@ -547,6 +551,8 @@ export default { id, type, actionType: "menuType", + }).catch((err) => { + this.$message.error(err); }); }, handleOnMenuTypeClick(data) { @@ -560,6 +566,8 @@ export default { id, igdId, actionType: "delIgd", + }).catch((err) => { + this.$message.error(err); }); }, handleOnEditRemark(data) { @@ -573,6 +581,8 @@ export default { id, remark, actionType: "remark", + }).catch((err) => { + this.$message.error(err); }); }, ...mapActions([