From bfc6e3a58a707abbb1aa2d8bd495f5d9698bd442 Mon Sep 17 00:00:00 2001 From: huanghongfa <huanghongfa123456> Date: 星期日, 26 九月 2021 16:09:49 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/test' into test --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientProductCategoryServiceImpl.java | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientProductCategoryServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientProductCategoryServiceImpl.java index 4bc22d8..bb3a61f 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientProductCategoryServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientProductCategoryServiceImpl.java @@ -4,9 +4,12 @@ import java.util.Date; +import javax.annotation.Resource; + import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -15,7 +18,9 @@ import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.convenient.ConvenientProductCategoryVO; import com.panzhihua.service_community.dao.ConvenientProductCategoryDAO; +import com.panzhihua.service_community.dao.ConvenientProductDAO; import com.panzhihua.service_community.model.dos.ConvenientProductCategoryDO; +import com.panzhihua.service_community.model.dos.ConvenientProductDO; import com.panzhihua.service_community.service.ConvenientProductCategoryService; /** @@ -27,6 +32,9 @@ */ @Service public class ConvenientProductCategoryServiceImpl extends ServiceImpl<ConvenientProductCategoryDAO, ConvenientProductCategoryDO> implements ConvenientProductCategoryService { + + @Resource + private ConvenientProductDAO convenientProductDAO; @Override public R addProductCategory(ConvenientProductCategoryDTO convenientProductCategoryDTO) { @@ -63,6 +71,11 @@ if (isNull(convenientProductCategoryDO)) { return R.fail("分类id不存在"); } + int quotedCount = convenientProductDAO.selectCount(new QueryWrapper<ConvenientProductDO>() + .lambda().eq(ConvenientProductDO::getCategoryId, categoryId).eq(ConvenientProductDO::getIsDel, false)); + if (quotedCount > 0) { + return R.fail("该分类名称已被引用,无法删除!"); + } convenientProductCategoryDO.setIsDel(true); convenientProductCategoryDO.setUpdatedBy(operator); int result = this.baseMapper.updateById(convenientProductCategoryDO); -- Gitblit v1.7.1