|
@@ -8,39 +8,71 @@ import org.dromara.bulk.domain.bo.GoodsBo;
|
|
|
import org.dromara.bulk.domain.vo.GoodsVo;
|
|
|
import org.dromara.bulk.mapper.GoodsMapper;
|
|
|
import org.dromara.bulk.service.GoodsService;
|
|
|
+import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
|
|
|
+/**
|
|
|
+ * 商品管理服务层实现
|
|
|
+ */
|
|
|
@Service
|
|
|
@RequiredArgsConstructor
|
|
|
public class GoodsServiceImpl implements GoodsService {
|
|
|
|
|
|
private final GoodsMapper goodsMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询商品列表
|
|
|
+ * @param goodsBo 商品BO对象
|
|
|
+ * @param pageQuery 分页查询条件
|
|
|
+ * @return 分页信息
|
|
|
+ */
|
|
|
@Override
|
|
|
public TableDataInfo<GoodsVo> selectPageGoodsList(GoodsBo goodsBo, PageQuery pageQuery) {
|
|
|
QueryWrapper<Goods> qw = new QueryWrapper<>();
|
|
|
+ qw.like(null != goodsBo.getId(), "id", goodsBo.getId());
|
|
|
Page<GoodsVo> page = goodsMapper.selectVoPage(pageQuery.build(), qw);
|
|
|
return TableDataInfo.build(page);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 新增商品
|
|
|
+ * @param goodsBo 商品BO对象
|
|
|
+ * @return 新增行数
|
|
|
+ */
|
|
|
@Override
|
|
|
public int insertGoods(GoodsBo goodsBo) {
|
|
|
- return 0;
|
|
|
+ return goodsMapper.insert(MapstructUtils.convert(goodsBo, Goods.class));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 修改商品
|
|
|
+ * @param goodsBo 商品BO对象
|
|
|
+ * @return 更新行数
|
|
|
+ */
|
|
|
@Override
|
|
|
public int updateGoods(GoodsBo goodsBo) {
|
|
|
- return 0;
|
|
|
+ return goodsMapper.updateById(MapstructUtils.convert(goodsBo, Goods.class));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 删除商品
|
|
|
+ * @param goodsIds 商品ID数组
|
|
|
+ * @return 删除行数
|
|
|
+ */
|
|
|
@Override
|
|
|
public int deleteGoodsById(Long[] goodsIds) {
|
|
|
- return 0;
|
|
|
+ return goodsMapper.deleteByIds(Arrays.asList(goodsIds));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询商品列表
|
|
|
+ * @return 商品VO列表
|
|
|
+ */
|
|
|
@Override
|
|
|
public List<GoodsVo> selectGoodsList() {
|
|
|
return goodsMapper.selectVoList();
|