From af8cd7db30e347bf4a9d4753e352abe9106bdb09 Mon Sep 17 00:00:00 2001 From: puhanshu <a9236326> Date: 星期二, 11 一月 2022 18:06:54 +0800 Subject: [PATCH] 商业街1/11代码提交 --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsProductServiceImpl.java | 47 ++++++++++++++++++++++++++++++++++------------- 1 files changed, 34 insertions(+), 13 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsProductServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsProductServiceImpl.java index a7a8ef6..4dc4d5f 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsProductServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsProductServiceImpl.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import javax.annotation.Resource; @@ -15,6 +16,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.panzhihua.common.model.dtos.community.microCommercialStreet.DeleteProductDTO; import com.panzhihua.common.model.dtos.community.microCommercialStreet.McsProductDTO; import com.panzhihua.common.model.dtos.community.microCommercialStreet.PageMcsProductDTO; import com.panzhihua.common.model.dtos.community.microCommercialStreet.SetShelfForProductDTO; @@ -123,23 +125,20 @@ /** * 删除产品信息 - * @param productId - * @param userId + * @param deleteProductDTO * @return */ @Override - public R deleteMcsProduct(Long productId, Long userId) { - McsProduct mcsProduct = this.baseMapper.selectById(productId); - if (isNull(mcsProduct)) { - return R.fail("资源不存在"); + public R deleteMcsProduct(DeleteProductDTO deleteProductDTO) { + List<McsProduct> mcsProducts = this.baseMapper.selectBatchIds(deleteProductDTO.getProductIds()); + if (nonNull(mcsProducts) && !mcsProducts.isEmpty()) { + mcsProducts.forEach(e -> { + e.setIsDel(true); + e.setUpdatedBy(deleteProductDTO.getUpdatedBy()); + }); + this.updateBatchById(mcsProducts); } - mcsProduct.setIsDel(true); - mcsProduct.setUpdatedBy(userId); - int num = this.baseMapper.updateById(mcsProduct); - if (num > 0) { - return R.ok(); - } - return R.fail("删除失败,请重新尝试"); + return R.ok(); } /** @@ -185,4 +184,26 @@ IPage<McsProductVO> mcsProduct = this.baseMapper.pageMcsProduct(page, pageMcsProductDTO); return R.ok(mcsProduct); } + + /** + * 获取产品信息详情 + * @param productId + * @return + */ + @Override + public R getMcsProduct(Long productId) { + McsProduct mcsProduct = this.baseMapper.selectById(productId); + if (isNull(mcsProduct)) { + return R.fail("资源不存在"); + } + McsProductVO mcsProductVO = new McsProductVO(); + BeanUtils.copyProperties(mcsProduct, mcsProductVO); + List<McsProductLabel> mcsProductLabelList = mcsProductLabelDAO.selectList(new QueryWrapper<McsProductLabel>().lambda() + .eq(McsProductLabel::getProductId, productId)); + if (nonNull(mcsProductLabelList) && !mcsProductLabelList.isEmpty()) { + List<Long> labelIds = mcsProductLabelList.stream().map(McsProductLabel::getLabelId).collect(Collectors.toList()); + mcsProductVO.setLabelIds(labelIds); + } + return R.ok(mcsProductVO); + } } -- Gitblit v1.7.1