|
@@ -11,16 +11,14 @@
|
|
|
package com.yami.shop.admin.controller;
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.yami.shop.bean.model.ProdTagReference;
|
|
|
import com.yami.shop.common.util.PageParam;
|
|
|
import com.yami.shop.bean.model.ProdTag;
|
|
|
import com.yami.shop.common.annotation.SysLog;
|
|
|
import com.yami.shop.common.exception.YamiShopBindException;
|
|
|
import com.yami.shop.security.util.SecurityUtils;
|
|
|
-import com.yami.shop.service.ProdTagReferenceService;
|
|
|
import com.yami.shop.service.ProdTagService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
@@ -44,9 +42,6 @@ public class ProdTagController {
|
|
|
@Autowired
|
|
|
private ProdTagService prodTagService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private ProdTagReferenceService prodTagReferenceService;
|
|
|
-
|
|
|
/**
|
|
|
* 分页查询
|
|
|
*
|
|
@@ -87,12 +82,16 @@ public class ProdTagController {
|
|
|
@PostMapping
|
|
|
@PreAuthorize("@pms.hasPermission('prod:prodTag:save')")
|
|
|
public ResponseEntity<Boolean> save(@RequestBody @Valid ProdTag prodTag) {
|
|
|
+ // 查看是否相同的标签
|
|
|
+ List<ProdTag> list = prodTagService.list(new LambdaQueryWrapper<ProdTag>().like(ProdTag::getTitle, prodTag.getTitle()));
|
|
|
+ if (CollectionUtil.isNotEmpty(list)) {
|
|
|
+ throw new YamiShopBindException("标签名称已存在,不能添加相同的标签");
|
|
|
+ }
|
|
|
+ prodTag.setIsDefault(0);
|
|
|
+ prodTag.setProdCount(0L);
|
|
|
prodTag.setCreateTime(new Date());
|
|
|
prodTag.setUpdateTime(new Date());
|
|
|
- prodTag.setIsDefault(0);
|
|
|
prodTag.setShopId(SecurityUtils.getSysUser().getShopId());
|
|
|
- prodTag.setStatus(1);
|
|
|
- prodTag.setProdCount(0L);
|
|
|
prodTagService.removeProdTag();
|
|
|
return ResponseEntity.ok(prodTagService.save(prodTag));
|
|
|
}
|
|
@@ -126,13 +125,6 @@ public class ProdTagController {
|
|
|
if (prodTag.getIsDefault() != 0) {
|
|
|
throw new YamiShopBindException("默认标签不能删除");
|
|
|
}
|
|
|
- // 校验分组是否已经使用过
|
|
|
- int count = prodTagReferenceService.count(new LambdaUpdateWrapper<ProdTagReference>()
|
|
|
- .eq(ProdTagReference::getStatus, 1)
|
|
|
- .eq(ProdTagReference::getTagId, id));
|
|
|
- if (count > 0) {
|
|
|
- throw new YamiShopBindException("该分组已被商品使用,无法进行删除操作");
|
|
|
- }
|
|
|
prodTagService.removeProdTag();
|
|
|
return ResponseEntity.ok(prodTagService.removeById(id));
|
|
|
}
|
|
@@ -144,4 +136,4 @@ public class ProdTagController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-}
|
|
|
+}
|