Search in sources :

Example 1 with PmsProductImage

use of com.xatu.gmall.entity.PmsProductImage in project GMall by 18391713434.

the class SpuServiceImpl method saveSpuInfo.

public void saveSpuInfo(PmsProductInfo pmsProductInfo) {
    spuMapper.insert(pmsProductInfo);
    Long id = pmsProductInfo.getId();
    List<PmsProductSaleAttr> spuSaleAttrList = pmsProductInfo.getSpuSaleAttrList();
    for (PmsProductSaleAttr pmsProductSaleAttr : spuSaleAttrList) {
        // 添加SPU单元的销售属性
        pmsProductSaleAttr.setProductId(id);
        saleAttrMapper.insert(pmsProductSaleAttr);
        // 添加SPU单元的销售属性值
        List<PmsProductSaleAttrValue> spuSaleAttrValueList = pmsProductSaleAttr.getSpuSaleAttrValueList();
        for (PmsProductSaleAttrValue pmsProductSaleAttrValue : spuSaleAttrValueList) {
            pmsProductSaleAttrValue.setProductId(id);
            saleAttrValueMapper.insert(pmsProductSaleAttrValue);
        }
    }
    // 添加SPU单元的图片集合
    List<PmsProductImage> spuImageList = pmsProductInfo.getSpuImageList();
    for (PmsProductImage pmsProductImage : spuImageList) {
        pmsProductImage.setProductId(pmsProductInfo.getId());
        imageMapper.insert(pmsProductImage);
    }
}
Also used : PmsProductSaleAttr(com.xatu.gmall.entity.PmsProductSaleAttr) PmsProductImage(com.xatu.gmall.entity.PmsProductImage) PmsProductSaleAttrValue(com.xatu.gmall.entity.PmsProductSaleAttrValue)

Aggregations

PmsProductImage (com.xatu.gmall.entity.PmsProductImage)1 PmsProductSaleAttr (com.xatu.gmall.entity.PmsProductSaleAttr)1 PmsProductSaleAttrValue (com.xatu.gmall.entity.PmsProductSaleAttrValue)1