mirror of
https://gitee.com/gz-yami/mall4j.git
synced 2025-12-26 07:56:43 +08:00
更新分组标签被使用后不能进行删除
This commit is contained in:
parent
a0d58cad8a
commit
1d258a2455
@ -12,12 +12,15 @@ package com.yami.shop.admin.controller;
|
||||
|
||||
|
||||
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;
|
||||
@ -41,6 +44,9 @@ public class ProdTagController {
|
||||
@Autowired
|
||||
private ProdTagService prodTagService;
|
||||
|
||||
@Autowired
|
||||
private ProdTagReferenceService prodTagReferenceService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
@ -120,6 +126,13 @@ 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));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user