This commit is contained in:
wangjinlei
2023-09-20 15:43:43 +08:00
parent e0a103358c
commit 2bfc0f7919
2 changed files with 16 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
package com.peanut.modules.book.controller; package com.peanut.modules.book.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.peanut.common.utils.R; import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.ShopProductLabelEntity; import com.peanut.modules.book.entity.ShopProductLabelEntity;
import com.peanut.modules.book.service.ShopProductLabelService; import com.peanut.modules.book.service.ShopProductLabelService;
@@ -19,10 +20,24 @@ public class ShopProductLabelController {
@RequestMapping("/addLabel") @RequestMapping("/addLabel")
public R addLabel(@RequestParam String labelName){ public R addLabel(@RequestParam String labelName){
//同名不能添加
QueryWrapper<ShopProductLabelEntity> shopProductLabelEntityQueryWrapper = new QueryWrapper<ShopProductLabelEntity>();
shopProductLabelEntityQueryWrapper.eq("label_name",labelName);
ShopProductLabelEntity shopProductLabelEntity_check = shopProductLabelService.getBaseMapper().selectOne(shopProductLabelEntityQueryWrapper);
if(shopProductLabelEntity_check!=null){
return R.error("不可添加已存在的项目");
}
ShopProductLabelEntity shopProductLabelEntity = new ShopProductLabelEntity(); ShopProductLabelEntity shopProductLabelEntity = new ShopProductLabelEntity();
shopProductLabelEntity.setLabelName(labelName); shopProductLabelEntity.setLabelName(labelName);
shopProductLabelService.save(shopProductLabelEntity); shopProductLabelService.save(shopProductLabelEntity);
return R.ok(); return R.ok();
} }
@RequestMapping("/delLabel")
public R delLabel(@RequestParam Integer splId){
return R.ok();
}
} }

View File

@@ -20,6 +20,7 @@ public class ShopProductLabelEntity {
@TableId @TableId
private Integer splId; private Integer splId;
@TableField("label_name")
private String labelName; private String labelName;
private Date ctime; private Date ctime;