puhanshu
2021-09-26 8853646a805c64f96c23d6b2fcfea981f034d44a
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);