四十七.完善新增商品接口所需的本地方法

需要保存spu基本信息

SpuInfoServiceImpl接口新增如下方法:

 /**
     * 保存基础的商品信息
     *
     * @param infoEntity
     */
    private void saveBaseSpuInfo(SpuInfoEntity infoEntity) {
        this.baseMapper.insert(infoEntity);
    }  

需要保存Spu的描述图片

SpuInfoDescService接口新增如下方法:

    /**
     * 保存spu信息描述
     *
     * @param descEntity
     */
    void saveSpuInfoDesc(SpuInfoDescEntity descEntity);

SpuInfoDescServiceImpl类新增该方法的实现,如下:

@Override
    public void saveSpuInfoDesc(SpuInfoDescEntity descEntity) {
        this.baseMapper.insert(descEntity);
    }

需要保存spu的图片集

SpuImagesService接口新增如下方法:

    /**
     * 保存spu图片
     *
     * @param id
     * @param images
     */
    void saveImages(Long id, List<String> images);

SpuImagesServiceImpl类新增方法的实现,如下:

 @Override
    public void saveImages(Long id, List<String> images) {
        if (CollectionUtils.isEmpty(images)) {
            List<SpuImagesEntity> collect = images.stream().map(img -> {
                SpuImagesEntity spuImagesEntity = new SpuImagesEntity();
                spuImagesEntity.setSpuId(id);
                spuImagesEntity.setImgUrl(img);
                return spuImagesEntity;
            }).collect(Collectors.toList());
            this.saveBatch(collect);
        }

需要保存spu的规格参数

ProductAttrValueService接口新增如下方法:

    /**
     * 保存商品属性值
     *
     * @param productAttrValueEntities
     */
    void saveProductAttr(List<ProductAttrValueEntity> productAttrValueEntities);

ProductAttrValueServiceImpl类新增方法的实现,如下:

 @Override
    public void saveProductAttr(List<ProductAttrValueEntity> productAttrValueEntities) {
        this.saveBatch(productAttrValueEntities);
    }

需要保存当前spu对应的sku基本信息

SkuInfoService接口新增如下方法:

    /**
     * 保存sku的基本信息
     *
     * @param skuInfoEntity
     */
    void saveSkuInfo(SkuInfoEntity skuInfoEntity);

SkuInfoServiceImpl类增加方法的实现,如下:

    @Override
    public void saveSkuInfo(SkuInfoEntity skuInfoEntity) {
        this.baseMapper.insert(skuInfoEntity);
    }

猜你喜欢

转载自blog.csdn.net/weixin_38106322/article/details/107524906
今日推荐