DESKTOP-71BH0QO\L、ming
2021-04-16 52026839eb1503895f325f8d0c9f38b6940fe1f4
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopGoodsServiceImpl.java
@@ -1,10 +1,19 @@
package com.panzhihua.service_community.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.shop.PageComShopGoodsDTO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.shop.ComShopStoreVO;
import com.panzhihua.common.model.vos.shop.ShopGoodsVO;
import com.panzhihua.service_community.dao.ComShopGoodsDAO;
import com.panzhihua.service_community.model.dos.ComShopGoodsDO;
import com.panzhihua.service_community.model.dos.ComShopStoreDO;
import com.panzhihua.service_community.service.ComShopGoodsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
/**
@@ -15,5 +24,43 @@
@Slf4j
@Service
public class ComShopGoodsServiceImpl extends ServiceImpl<ComShopGoodsDAO, ComShopGoodsDO> implements ComShopGoodsService {
    @Override
    public R saveShopGoods(ShopGoodsVO shopGoodsVO) {
        if (shopGoodsVO == null) {
            return R.ok("500", "数据为空!");
        }
        ComShopGoodsDO shopGoodsDO = new ComShopGoodsDO();
        BeanUtils.copyProperties(shopGoodsVO, shopGoodsDO);
        shopGoodsDO.setSale(0);
        this.baseMapper.insert(shopGoodsDO);
        return R.ok();
    }
    @Override
    public R pageStoreList(PageComShopGoodsDTO pageComShopGoodsDTO) {
        Page page = new Page<>(pageComShopGoodsDTO.getPageNum(), pageComShopGoodsDTO.getPageSize());
        IPage<ComShopStoreVO> comShopStoreVOIPage = this.baseMapper.pageShopGoods(page, pageComShopGoodsDTO);
        return R.ok(comShopStoreVOIPage);
    }
    @Override
    public R editShopGoods(Long id, ShopGoodsVO shopGoodsVO) {
        if (shopGoodsVO == null) {
            return R.ok("500", "数据为空!");
        }
        LambdaQueryWrapper<ComShopGoodsDO> query = new LambdaQueryWrapper<ComShopGoodsDO>().eq(ComShopGoodsDO::getId, id);
        ComShopGoodsDO shopGoodsDO = new ComShopGoodsDO();
        BeanUtils.copyProperties(shopGoodsVO,shopGoodsDO);
        int update = this.baseMapper.update(shopGoodsDO, query);
        return update > 0 ? R.ok() : R.fail();
    }
    @Override
    public R deleteShopGoods(Long[] id) {
        ComShopGoodsDO storeDO = new ComShopGoodsDO();
        storeDO.setDeleteStatus(2);
        LambdaQueryWrapper<ComShopGoodsDO> query = new LambdaQueryWrapper<ComShopGoodsDO>().eq(ComShopGoodsDO::getId, id);
        int update = this.baseMapper.update(storeDO, query);
        return update > 0 ? R.ok() : R.fail();
    }
}