018 发布商品

news2024/10/10 23:32:52

文章目录

    • 获取分类关联的品牌
      • CategoryBrandController.java
      • CategoryBrandServiceImpl.java
      • BrandVo.java
    • 获取分类下的所有分组&关联属性
      • AttrGroupController.java
      • AttrGroupServiceImpl.java
  • 保存七张表
    • sql
      • tb_spu_info.sql
      • tb_spu_info_desc.sql
      • tb_spu_images.sql
      • tb_product_attr_value.sql
      • tb_sku_info.sql
      • tb_sku_images.sql
      • tb_sku_sale_attr_value.sql
    • vo
      • Attr.java
      • BaseAttrs.java
      • Images.java
      • Skus.java
      • SpuSaveVo.java
    • controller
      • SpuInfoController.java
    • impl
      • SpuInfoServiceImpl.java
      • SpuInfoDescServiceImpl.java
      • SpuImagesServiceImpl.java
      • ProductAttrValueServiceImpl.java
      • SkuInfoServiceImpl.java

https://www.bejson.com/json2javapojo/new/#google_vignette
发布商品涉及七张表

获取分类关联的品牌

CategoryBrandController.java

    /**
     * 获取分类关联的品牌
     * @return
     */
    @GetMapping("/brands/list")
    public R relationBrandList(@RequestParam("categoryId") Integer categoryId){
        List<BrandEntity> brandEntities = categoryBrandService.getBrandByCategoryId(categoryId);

        List<BrandVo> collect = brandEntities.stream().map(brandEntity -> {
            BrandVo brandVo = new BrandVo();
            brandVo.setBrandId(brandEntity.getId());
            brandVo.setBrandName(brandEntity.getName());
            return brandVo;
        }).collect(Collectors.toList());

        return R.ok().put("data", collect);
    }

CategoryBrandServiceImpl.java

    /**
     * 获取分类关联的品牌
     * @param categoryId
     * @return
     */

    @Override
    public List<BrandEntity> getBrandByCategoryId(Integer categoryId) {

        List<CategoryBrandEntity> categoryBrandEntities = categoryBrandDao.selectList(
                new QueryWrapper<CategoryBrandEntity>().eq("category_id", categoryId)
        );


        List<BrandEntity> collect = categoryBrandEntities.stream().map(item->{
            Integer brandId = item.getBrandId();
            BrandEntity brandEntity = brandService.getById(brandId);
            return brandEntity;
        }).collect(Collectors.toList());

        return collect;
    }

BrandVo.java

package com.xd.cubemall.product.vo;

import lombok.Data;

@Data
public class BrandVo {

    /**
     * 品牌ID
     */
    private Integer brandId;

    /**
     * 品牌名称
     */
    private String brandName;
}

获取分类下的所有分组&关联属性

发布商品

AttrGroupController.java

    /**
     * 获取分类下所有分组&关联属性
     * @return
     */
    @GetMapping("/{categoryId}/withattr")
    public R getAttrGroupWithAttrs(@PathVariable("categoryId") Long categoryId){
        //1.查询当前分类下的所有属性分组

        //2.查询当前属性分组下所有的属性

        List<AttrGroupWithAttrsVo> vos = attrGroupService.getAttrGroupWithAttrsByCategoryId(categoryId);
        return R.ok().put("data", vos);

    }

AttrGroupServiceImpl.java

    /**
     * 获取分类下的所有分组&关联属性
     * @param categoryId
     * @return
     */
    @Override
    public List<AttrGroupWithAttrsVo> getAttrGroupWithAttrsByCategoryId(Long categoryId) {
        //1.查询该分类下所有的分组信息
        List<AttrGroupEntity> attrGroupEntities = this.list(new QueryWrapper<AttrGroupEntity>().eq("category_id",categoryId));

        //2.查询出所有属性
        List<AttrGroupWithAttrsVo> collect = attrGroupEntities.stream().map(attrGroupEntity -> {
            AttrGroupWithAttrsVo attrsVo = new AttrGroupWithAttrsVo();
            //属性对拷
            BeanUtils.copyProperties(attrGroupEntity, attrsVo);

            //设置关联的属性
            List<AttrEntity> relationAttr = attrService.getRelationAttr(attrsVo.getId());
            attrsVo.setAttrs(relationAttr);

            return attrsVo;
        }).collect(Collectors.toList());

        return collect;
    }

保存七张表

sql

tb_spu_info.sql

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for tb_spu_info
-- ----------------------------
DROP TABLE IF EXISTS `tb_spu_info`;
CREATE TABLE `tb_spu_info`  (
  `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `spu_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT 'spu名称',
  `spu_description` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT 'spu描述',
  `category_id` bigint(0) NULL DEFAULT NULL COMMENT '分类ID',
  `brand_id` bigint(0) NULL DEFAULT NULL COMMENT '品牌ID',
  `weight` decimal(18, 4) NULL DEFAULT NULL COMMENT '权重',
  `publish_status` tinyint(0) NULL DEFAULT NULL COMMENT '发布状态',
  `create_time` datetime(0) NULL DEFAULT NULL,
  `update_time` datetime(0) NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = 'spu信息' ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;

tb_spu_info_desc.sql

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for tb_spu_info_desc
-- ----------------------------
DROP TABLE IF EXISTS `tb_spu_info_desc`;
CREATE TABLE `tb_spu_info_desc`  (
  `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `spu_id` bigint(0) NOT NULL COMMENT 'spu_id',
  `decript` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL COMMENT '描述',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = 'spu描述' ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;

tb_spu_images.sql

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for tb_spu_images
-- ----------------------------
DROP TABLE IF EXISTS `tb_spu_images`;
CREATE TABLE `tb_spu_images`  (
  `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `spu_id` bigint(0) NULL DEFAULT NULL COMMENT 'spu_id',
  `img_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '图片名称',
  `img_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '图片url',
  `img_sort` int(0) NULL DEFAULT NULL COMMENT '图片顺序',
  `default_img` tinyint(0) NULL DEFAULT NULL COMMENT '默认图片',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = 'spu图片' ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;

tb_product_attr_value.sql

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for tb_product_attr_value
-- ----------------------------
DROP TABLE IF EXISTS `tb_product_attr_value`;
CREATE TABLE `tb_product_attr_value`  (
  `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `spu_id` bigint(0) NULL DEFAULT NULL COMMENT 'spuid',
  `attr_id` bigint(0) NULL DEFAULT NULL COMMENT '属性id',
  `attr_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '属性名称',
  `attr_value` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '属性值',
  `attr_sort` int(0) NULL DEFAULT NULL COMMENT '属性排序',
  `quick_show` tinyint(0) NULL DEFAULT NULL COMMENT '显示',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 20 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = 'spu' ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;

tb_sku_info.sql

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for tb_sku_info
-- ----------------------------
DROP TABLE IF EXISTS `tb_sku_info`;
CREATE TABLE `tb_sku_info`  (
  `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `spu_id` bigint(0) NULL DEFAULT NULL COMMENT 'spuId',
  `sku_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT 'sku名称',
  `sku_desc` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT 'sku描述',
  `category_id` bigint(0) NULL DEFAULT NULL COMMENT '分类id',
  `brand_id` bigint(0) NULL DEFAULT NULL COMMENT '品牌id',
  `sku_default_img` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '默认sku图片',
  `sku_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT 'sku名称',
  `sku_subtitle` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT 'sku子名称',
  `price` decimal(18, 4) NULL DEFAULT NULL COMMENT '价格',
  `sale_count` bigint(0) NULL DEFAULT NULL COMMENT '销售数量',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 18 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = 'sku??Ϣ' ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;

tb_sku_images.sql

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for tb_sku_images
-- ----------------------------
DROP TABLE IF EXISTS `tb_sku_images`;
CREATE TABLE `tb_sku_images`  (
  `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `sku_id` bigint(0) NULL DEFAULT NULL COMMENT 'sku_id',
  `img_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '图片地址',
  `img_sort` int(0) NULL DEFAULT NULL COMMENT '图片排序',
  `default_img` int(0) NULL DEFAULT NULL COMMENT '默认图片',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 15 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = 'sku图片表' ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;

tb_sku_sale_attr_value.sql

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for tb_sku_sale_attr_value
-- ----------------------------
DROP TABLE IF EXISTS `tb_sku_sale_attr_value`;
CREATE TABLE `tb_sku_sale_attr_value`  (
  `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `sku_id` bigint(0) NULL DEFAULT NULL COMMENT 'sku_id',
  `attr_id` bigint(0) NULL DEFAULT NULL COMMENT 'attr_id',
  `attr_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '属性名称',
  `attr_value` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '属性值',
  `attr_sort` int(0) NULL DEFAULT NULL COMMENT '属性排序',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 36 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = 'sku销售属性值' ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;

vo

Attr.java

/**
  * Copyright 2021 json.cn 
  */
package com.xd.cubemall.product.vo;

import lombok.Data;

@Data
public class Attr {

    private int attrId;
    private String attrName;
    private String attrValue;

}

BaseAttrs.java

/**
  * Copyright 2021 json.cn 
  */
package com.xd.cubemall.product.vo;

import lombok.Data;

@Data
public class BaseAttrs {

    private int attrId;
    private String attrValues;
    private int showDesc;

}

Images.java

/**
  * Copyright 2021 json.cn 
  */
package com.xd.cubemall.product.vo;

import lombok.Data;

@Data
public class Images {

    private String imgUrl;
    private int defaultImg;

}

Skus.java

/**
  * Copyright 2021 json.cn 
  */
package com.xd.cubemall.product.vo;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

@Data
public class Skus {

    private List<Attr> attr;
    private String skuName;
    private BigDecimal price;
    private String skuTitle;
    private String skuSubtitle;
    private List<Images> images;
    private List<String> descar;
    private int fullCount;
    private int countStatus;
    private BigDecimal fullPrice;
    private int priceStatus;

}

SpuSaveVo.java

/**
  * Copyright 2021 json.cn 
  */
package com.xd.cubemall.product.vo;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Data
public class SpuSaveVo {

    private String spuName;
    private String spuDescription;
    private Long categoryId;
    private Long brandId;
    private BigDecimal weight;
    private int publishStatus;
    private String decript;
    private List<String> images;
    private List<BaseAttrs> baseAttrs;
    private List<Skus> skus;

}
SELECT * FROM tb_spu_info;
SELECT * FROM tb_spu_info_desc;
SELECT * FROM tb_spu_images;
SELECT * FROM tb_product_attr_value;
SELECT * FROM tb_sku_info;
SELECT * FROM tb_sku_images;
SELECT * FROM tb_sku_sale_attr_value;

controller

SpuInfoController.java

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("product:spuinfo:save")
    public R save(@RequestBody SpuSaveVo spuSaveVo){
		spuInfoService.saveSpuInfo(spuSaveVo);

        return R.ok();
    }

impl

SpuInfoServiceImpl.java

import com.xd.cubemall.common.utils.PageUtils;
import com.xd.cubemall.common.utils.Query;
import com.xd.cubemall.product.entity.*;
import com.xd.cubemall.product.service.*;
import com.xd.cubemall.product.vo.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


import com.xd.cubemall.product.dao.SpuInfoDao;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.MethodArgumentNotValidException;


@Service("spuInfoService")
public class SpuInfoServiceImpl extends ServiceImpl<SpuInfoDao, SpuInfoEntity> implements SpuInfoService {

    @Autowired
    private SpuInfoDescService spuInfoDescService;

    @Autowired
    private SpuImagesService spuImagesService;

    @Autowired
    private AttrService attrService;

    @Autowired
    private ProductAttrValueService productAttrValueService;

    @Autowired
    private SkuInfoService skuInfoService;

    @Autowired
    private SkuImagesService skuImagesService;

    @Autowired
    private SkuSaleAttrValueService skuSaleAttrValueService;

    /**
     * 对7张数据库表进行保存操作
     * @param spuSaveVo
     */

    @Transactional(rollbackFor = MethodArgumentNotValidException.class)//不设置,在springboot低版本不会进行事务的回滚
    @Override
    public void saveSpuInfo(SpuSaveVo spuSaveVo) {
        //1.保存spu基本信息: tb_spu_info
        SpuInfoEntity spuInfoEntity = new SpuInfoEntity();
        BeanUtils.copyProperties(spuSaveVo, spuInfoEntity);
        spuInfoEntity.setCreateTime(new Date());
        spuInfoEntity.setUpdateTime(new Date());

        this.saveBaseSpuInfo(spuInfoEntity);

        //2.保存spu的描述信息: tb_spu_info_desc
        SpuInfoDescEntity spuInfoDescEntity = new SpuInfoDescEntity();
        spuInfoDescEntity.setSpuId(spuInfoEntity.getId());
        spuInfoDescEntity.setDecript(spuSaveVo.getDecript());

        spuInfoDescService.saveSpuInfoDesc(spuInfoDescEntity);

        //3.保存spu图片集: tb_spu_images
        List<String> images = spuSaveVo.getImages();
        spuImagesService.saveImage(spuInfoEntity.getId(), images);


        //4.保存spu的规格参数: tb_product_attr_value
        List<BaseAttrs> baseAttrs = spuSaveVo.getBaseAttrs();
        List<ProductAttrValueEntity> collect = baseAttrs.stream().map(attr->{
            ProductAttrValueEntity productAttrValueEntity = new ProductAttrValueEntity();
            productAttrValueEntity.setSpuId(spuInfoEntity.getId());
            productAttrValueEntity.setAttrId((long) attr.getAttrId());
            AttrEntity attrEntity = attrService.getById(attr.getAttrId());
            productAttrValueEntity.setAttrName(attrEntity.getName());
            productAttrValueEntity.setAttrValue(attr.getAttrValues());
            productAttrValueEntity.setQuickShow(attr.getShowDesc());
            return productAttrValueEntity;
        }).collect(Collectors.toList());

        productAttrValueService.saveProductAttr(collect);




        //5.保存当前spu对应的所有的sku信息
        List<Skus> skus = spuSaveVo.getSkus();
        if (skus != null && skus.size()>0) {

            skus.forEach(item->{
                //获取默认图片
                String defaultImg = "";
                for (Images image : item.getImages()) {
                    if (image.getDefaultImg() == 1){
                        defaultImg = image.getImgUrl();
                    }
                }
                //5.1 保存sku的基本信息:tb_sku_info
                SkuInfoEntity skuInfoEntity = new SkuInfoEntity();
                BeanUtils.copyProperties(item, skuInfoEntity);
                skuInfoEntity.setBrandId(spuInfoEntity.getBrandId());
                skuInfoEntity.setCategoryId(spuInfoEntity.getCategoryId());
                skuInfoEntity.setSaleCount(0L);
                skuInfoEntity.setSpuId(spuInfoEntity.getId());
                skuInfoEntity.setSkuDefaultImg(defaultImg);


                skuInfoService.saveSkuInfo(skuInfoEntity);
                //5.2 保存sku的图片信息:tb_sku_images
                Long skuId = skuInfoEntity.getId();
                List<SkuImagesEntity> imagesEntities = item.getImages().stream().map(img->{
                    SkuImagesEntity skuImagesEntity = new SkuImagesEntity();
                    skuImagesEntity.setSkuId(skuId);
                    skuImagesEntity.setImgUrl(img.getImgUrl());
                    skuImagesEntity.setDefaultImg(img.getDefaultImg());
                    return skuImagesEntity;
                }).filter(entity->{
                    return StringUtils.isEmpty(entity.getImgUrl());
                }).collect(Collectors.toList());

                skuImagesService.saveBatch(imagesEntities);


                //5.3 保存sku的销售属性: tb_sku_sale_attr_value
                List<Attr> attrs = item.getAttr();
                if (attrs != null && attrs.size() > 0) {
                    List<SkuSaleAttrValueEntity> skuSaleAttrValueEntities = attrs.stream().map(attr -> {
                        SkuSaleAttrValueEntity skuSaleAttrValueEntity = new SkuSaleAttrValueEntity();
                        BeanUtils.copyProperties(attr, skuSaleAttrValueEntity);
                        skuSaleAttrValueEntity.setSkuId(skuId);
                        return skuSaleAttrValueEntity;
                    }).collect(Collectors.toList());
                    skuSaleAttrValueService.saveBatch(skuSaleAttrValueEntities);

                }

            });

        }





    }

    /**
     * 1.保存spu基本信息: tb_spu_info
     * @param spuInfoEntity
     */

    public void saveBaseSpuInfo(SpuInfoEntity spuInfoEntity) {
        this.baseMapper.insert(spuInfoEntity);
    }

}

SpuInfoDescServiceImpl.java

import com.xd.cubemall.common.utils.PageUtils;
import com.xd.cubemall.common.utils.Query;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


import com.xd.cubemall.product.dao.SpuInfoDescDao;
import com.xd.cubemall.product.entity.SpuInfoDescEntity;
import com.xd.cubemall.product.service.SpuInfoDescService;


@Service("spuInfoDescService")
public class SpuInfoDescServiceImpl extends ServiceImpl<SpuInfoDescDao, SpuInfoDescEntity> implements SpuInfoDescService {

    /**
     * 2.保存spu的描述信息: tb_spu_info_desc
     * @param spuInfoDescEntity
     */

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

}

SpuImagesServiceImpl.java

import com.xd.cubemall.common.utils.PageUtils;
import com.xd.cubemall.common.utils.Query;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


import com.xd.cubemall.product.dao.SpuImagesDao;
import com.xd.cubemall.product.entity.SpuImagesEntity;
import com.xd.cubemall.product.service.SpuImagesService;


@Service("spuImagesService")
public class SpuImagesServiceImpl extends ServiceImpl<SpuImagesDao, SpuImagesEntity> implements SpuImagesService {

    /**
     * 3.保存spu图片集: tb_spu_images
     * @param id
     * @param images
     */

    @Override
    public void saveImage(Long id, List<String> images) {
        if (images == null || images.size()<=0) {
            return;
        }
        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);

    }

}

ProductAttrValueServiceImpl.java

import com.xd.cubemall.common.utils.PageUtils;
import com.xd.cubemall.common.utils.Query;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


import com.xd.cubemall.product.dao.ProductAttrValueDao;
import com.xd.cubemall.product.entity.ProductAttrValueEntity;
import com.xd.cubemall.product.service.ProductAttrValueService;


@Service("productAttrValueService")
public class ProductAttrValueServiceImpl extends ServiceImpl<ProductAttrValueDao, ProductAttrValueEntity> implements ProductAttrValueService {

    /**
     * 4.保存spu的规格参数: tb_product_attr_value
     * @param collect
     */

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

}

SkuInfoServiceImpl.java

import com.xd.cubemall.common.utils.PageUtils;
import com.xd.cubemall.common.utils.Query;
import com.xd.cubemall.product.entity.SpuInfoEntity;
import com.xd.cubemall.product.vo.SpuSaveVo;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


import com.xd.cubemall.product.dao.SkuInfoDao;
import com.xd.cubemall.product.entity.SkuInfoEntity;
import com.xd.cubemall.product.service.SkuInfoService;


@Service("skuInfoService")
public class SkuInfoServiceImpl extends ServiceImpl<SkuInfoDao, SkuInfoEntity> implements SkuInfoService {

    /**
     * 5.1 保存sku的基本信息:tb_sku_info
     * @param skuInfoEntity
     */
    @Override
    public void saveSkuInfo(SkuInfoEntity skuInfoEntity) {
        this.baseMapper.insert(skuInfoEntity);
    }


}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2203500.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

UE4 材质学习笔记06(布料着色器/体积冰着色器)

一.布料着色器 要编写一个着色器首先是看一些参考图片&#xff0c;我们需要找出一些布料特有的特征&#xff0c;下面是一个棉织物&#xff0c;可以看到布料边缘的纤维可以捕捉光线使得边缘看起来更亮 下面是缎子和丝绸的图片&#xff0c;与棉织物有几乎相反的效果&#xff0c;…

基于SPI的flash读写操作

1、实验目标 使用页写或连续写操作向Flash芯片写入数据&#xff0c;再使用数据读操作读取之前写入数据&#xff0c;将读取的数据使用串口传回PC机&#xff0c;使用串口助手传回数据并与之前写入数据比较&#xff0c;判断正误。 注意&#xff1a;在向Flash芯片写入数据之前&…

【Redis原理】数据结构(上)

文章目录 动态字符串(SDS)概念SDS特点SDS的优势 IntSet概念IntSet的特点升序统一的编码格式IntSet自动升级 Dict概念Dict特点Dict的伸缩Dict的扩容Dict收缩 Dict的rehash渐进式哈希 总结Dict的结构Dict的伸缩 动态字符串(SDS) 概念 Redis是使用C语言实现的,C语言字符串底层是…

【后端开发】自动化部署、服务管理、问题排查工具(cicd流水线,k8s集群,ELK日志)

【后端开发】自动化部署、服务管理、问题排查工具&#xff08;cicd流水线&#xff0c;k8s集群&#xff0c;ELK日志&#xff09; 文章目录 1、Devops与CICD流水线(TeamCity, Jenkins&#xff0c;GitHub Actions)2、Kubernetes 集群的管理和操作&#xff08;对比Portainer&#x…

【解决】Set-ExecutionPolicy不是内部或外部命令

简介 当使用 VsCode 配置Django项目时&#xff0c;需要配置环境&#xff0c;但是当切换至虚拟环境时&#xff0c;出现了下面的情况。 无法加载文件&#xff1a;D:\django\Scripts\Activate.ps1&#xff0c; 上述问题可通过下面的命令进行解决 解决方法 1 命令行(最好是管理员…

JVM进阶调优系列(1)类加载器原理一文讲透

今天开始写JVM调优系列&#xff0c;并发编程系列也会继续穿插连载&#xff0c;让各位同学闲暇之余有更多阅读选择。 起笔写第一篇&#xff0c;并不好写。首先要构思整个系列的大概框架&#xff0c;一个好的框架一定是深度上由浅入深、逻辑上有严格顺序&#xff0c;读者订阅跟踪…

免费获取的8个SVG图标库,轻松下载与复制!

SVG图标相比传统的JPG、PNG图标具有诸多优势&#xff0c;适用于各种类型的图像&#xff0c;不仅能在不同尺寸下保持清晰度&#xff0c;还具备高度压缩性和轻量特性&#xff0c;支持静态和动态效果。因此&#xff0c;SVG格式在网页设计中往往是优选。尽管如今有很多免费的图标库…

风扇PD协议取电协议芯片-ECP 5702

随着USB-C的普及&#xff0c;市面上消费者PD充电器越来越多&#xff0c;如何让小家电产品也能够支持PD协议快充呢&#xff1f;加入一颗能芯科技PD协议取电协议芯片ECP5702试试看 USB PD协议受电端诱骗协议芯片 1、概述 ECP5702是能芯科技开发的一款专门PD协议的Sink控制器。 …

【论文速看】DL最新进展20241010-扩散模型、目标检测、行人检测

目录 【扩散模型】【目标检测】【行人检测】 【扩散模型】 []Faster Diffusion: Rethinking the Role of UNet Encoder in Diffusion Models 论文链接&#xff1a;https://arxiv.org/pdf/2312.09608 代码链接&#xff1a;https://github.com/hutaiHang/Faster-Diffusion 扩散…

No.10 笔记 | PHP学习指南:PHP数组掌握

本指南为PHP开发者提供了一个全面而简洁的数组学习路径。从数组的基本概念到高级操作技巧&#xff0c;我们深入浅出地解析了PHP数组的方方面面。无论您是初学者还是寻求提升的中级开发者&#xff0c;这份指南都能帮助您更好地理解和运用PHP数组&#xff0c;提高编码效率和代码质…

java批量发送邮件:如何实现高效邮件群发?

java批量发送邮件的教程指南&#xff1f;利用Java实现邮件批发&#xff1f; 随着技术的进步&#xff0c;java批量发送邮件已经成为企业实现高效邮件群发的关键工具。AokSend将探讨如何利用java批量发送邮件技术&#xff0c;实现高效的邮件群发&#xff0c;提升营销效果。 jav…

相当炸裂!495页看漫画学Python(全彩版)通俗易懂!Git首发破万Star

今天给大家分享一份由清华大学出品的《看漫画学Python》&#xff0c;本书作者对每一幅漫画表达的准确性也进行了N遍的推敲和打磨&#xff0c;向广大读者奉献一本精品漫画Python技术书。 总共495页&#xff0c;书中结合了幽默的故事情节和实用的编程知识&#xff0c;使得学习过…

【LeetCode】动态规划—673. 最长递增子序列的个数(附完整Python/C++代码)

动态规划—673. 最长递增子序列的个数 前言题目描述基本思路1. 问题定义2. 理解问题和递推关系3. 解决方法3.1 动态规划方法3.2 优化方法 4. 进一步优化5. 小总结 代码实现PythonPython3代码实现Python 代码解释 CC代码实现C 代码解释1. 初始化&#xff1a;2. 动态规划过程&…

Basic Pentesting靶机打靶记录

一、靶机介绍 下载链接&#xff1a;https://download.vulnhub.com/basicpentesting/basic_pentesting_1.ova 二、信息收集 确认靶机ip&#xff1a;192.168.242.136 arp-scan -l 扫描端口 nmap -p- -A -sS 192.168.242.136 这里开放了21&#xff0c;22&#xff0c;80端口 扫…

美发店数字化转型:SpringBoot管理系统

2相关技术 2.1 MYSQL数据库 MySQL是一个真正的多用户、多线程SQL数据库服务器。 是基于SQL的客户/服务器模式的关系数据库管理系统&#xff0c;它的有点有有功能强大、使用简单、管理方便、安全可靠性高、运行速度快、多线程、跨平台性、完全网络化、稳定性等&#xff0c;非常…

鸿蒙开发:文件推送到沙箱路径

最近一个项目需要基于沙箱路径下的文件进行操作&#xff0c;奈何应用沙箱路径下没有。找来找去方法都是要把文件推送进去。以下是我的一些拙见&#xff0c;请各位看官老爷指点一二。 沙箱路径 沙箱路径&#xff08;Sandbox Path&#xff09;通常是指在计算机安全和软件开发中…

【大学学习-大学之路-回顾-电子计算机相关专业-学习方案-自我学习-大二学生(2)】

【大学学习-大学之路-回顾-电子&计算机相关专业-学习方案-自我学习-大二学生&#xff08;2&#xff09;】 1、前言2、总体说明1-保证课程原因1&#xff1a;原因2&#xff1a; 2-打比赛3-自我适应 - 享受大学生活 3、 保证课程1、英语课程2、专业课程3、其他课程 4、 打比赛…

数据质量指标:如何衡量数据的准确性

数据质量是任何数据驱动运营的重要组成部分。即使对于不打算将数据集出售给其他公司的企业&#xff0c;数据的质量和准确性也会极大地影响决策效率。 不幸的是&#xff0c;没有单一指标可以确保数据质量达到标准。您必须跟踪多个指标并不断关注它们。因此&#xff0c;维护数据…

高通QCS6490开发(十):合并显示多路安防摄像头

视频分析时边缘侧AI应用的一个常见场景&#xff0c;边缘侧的单个节点能够同时视频流越多&#xff0c;这不仅提高了处理效率&#xff0c;还具有显著的经济性。本文将介绍如何使用QCS6490的VPU&#xff08;视频处理单元&#xff09;来支持H264/H265的视频硬件编解码&#xff0c;并…

C语言计算GPS卫星位置

1 概述 在用GPS信号进行导航定位以与制订观测计划时&#xff0c;都必须已知GPS卫星在空间的瞬间位置。卫星位置的计算是根据卫星电文所提供的轨道参数按一定的公式计算的。本节专门讲解观测瞬间GPS卫星在地固坐标系中坐标的计算方法。 2 卫星位置的计算 1. 计算卫星运行的平…