| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | |
| | | 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; |
| | |
| | | |
| | | /** |
| | | * 删除产品信息 |
| | | * @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(); |
| | | } |
| | | |
| | | /** |
| | |
| | | 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); |
| | | } |
| | | } |