From 2bfc0f79193dfbfc52ccf87a841ff02521d83a40 Mon Sep 17 00:00:00 2001 From: wangjinlei <751475802@qq.com> Date: Wed, 20 Sep 2023 15:43:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ShopProductLabelController.java | 15 +++++++++++++++ .../book/entity/ShopProductLabelEntity.java | 1 + 2 files changed, 16 insertions(+) diff --git a/src/main/java/com/peanut/modules/book/controller/ShopProductLabelController.java b/src/main/java/com/peanut/modules/book/controller/ShopProductLabelController.java index 4faf5224..896b06e5 100644 --- a/src/main/java/com/peanut/modules/book/controller/ShopProductLabelController.java +++ b/src/main/java/com/peanut/modules/book/controller/ShopProductLabelController.java @@ -1,5 +1,6 @@ package com.peanut.modules.book.controller; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.peanut.common.utils.R; import com.peanut.modules.book.entity.ShopProductLabelEntity; import com.peanut.modules.book.service.ShopProductLabelService; @@ -19,10 +20,24 @@ public class ShopProductLabelController { @RequestMapping("/addLabel") public R addLabel(@RequestParam String labelName){ + + //同名不能添加 + QueryWrapper shopProductLabelEntityQueryWrapper = new QueryWrapper(); + shopProductLabelEntityQueryWrapper.eq("label_name",labelName); + ShopProductLabelEntity shopProductLabelEntity_check = shopProductLabelService.getBaseMapper().selectOne(shopProductLabelEntityQueryWrapper); + if(shopProductLabelEntity_check!=null){ + return R.error("不可添加已存在的项目"); + } + ShopProductLabelEntity shopProductLabelEntity = new ShopProductLabelEntity(); shopProductLabelEntity.setLabelName(labelName); shopProductLabelService.save(shopProductLabelEntity); return R.ok(); } + @RequestMapping("/delLabel") + public R delLabel(@RequestParam Integer splId){ + return R.ok(); + } + } diff --git a/src/main/java/com/peanut/modules/book/entity/ShopProductLabelEntity.java b/src/main/java/com/peanut/modules/book/entity/ShopProductLabelEntity.java index eaa17018..dcb169e8 100644 --- a/src/main/java/com/peanut/modules/book/entity/ShopProductLabelEntity.java +++ b/src/main/java/com/peanut/modules/book/entity/ShopProductLabelEntity.java @@ -20,6 +20,7 @@ public class ShopProductLabelEntity { @TableId private Integer splId; + @TableField("label_name") private String labelName; private Date ctime;