Search in sources :

Example 1 with PmsProductSaleAttr

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

the class SpuServiceImpl method spuSaleAttrList.

public List<PmsProductSaleAttr> spuSaleAttrList(String spuId) {
    List<PmsProductSaleAttr> pmsProductSaleAttrList = saleAttrMapper.selectList(new QueryWrapper<PmsProductSaleAttr>().eq("product_id", spuId));
    for (PmsProductSaleAttr pmsProductSaleAttr : pmsProductSaleAttrList) {
        List<PmsProductSaleAttrValue> pmsProductSaleAttrValueList = saleAttrValueMapper.selectList(new QueryWrapper<PmsProductSaleAttrValue>().eq("product_id", spuId).eq("sale_attr_id", pmsProductSaleAttr.getSaleAttrId()));
        pmsProductSaleAttr.setSpuSaleAttrValueList(pmsProductSaleAttrValueList);
    }
    return pmsProductSaleAttrList;
}
Also used : PmsProductSaleAttr(com.xatu.gmall.entity.PmsProductSaleAttr) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) PmsProductSaleAttrValue(com.xatu.gmall.entity.PmsProductSaleAttrValue)

Example 2 with PmsProductSaleAttr

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

the class ItemController method item.

@RequestMapping("{skuId}.html")
public String item(@PathVariable String skuId, ModelMap map) {
    // sku对象
    PmsSkuInfo pmsSkuInfo = skuService.getSkuById(skuId);
    map.put("skuInfo", pmsSkuInfo);
    // 销售属性列表
    List<PmsProductSaleAttr> pmsProductSaleAttrs = spuService.spuSaleAttrListCheckBySku(pmsSkuInfo.getSpuId(), pmsSkuInfo.getId());
    map.put("spuSaleAttrListCheckBySku", pmsProductSaleAttrs);
    // 查询当前sku的spu的其他sku的集合的hash表
    List<PmsSkuInfo> pmsSkuInfos = skuService.getSkuSaleAttrValueListBySpu(pmsSkuInfo.getSpuId());
    HashMap<String, Long> skuSaleAttrHash = new HashMap<>();
    for (PmsSkuInfo skuInfo : pmsSkuInfos) {
        String k = "";
        Long v = skuInfo.getId();
        List<PmsSkuSaleAttrValue> skuSaleAttrValueList = skuInfo.getSkuSaleAttrValueList();
        for (PmsSkuSaleAttrValue skuSaleAttrValue : skuSaleAttrValueList) {
            k += skuSaleAttrValue.getSaleAttrValueId() + "|";
        }
        skuSaleAttrHash.put(k, v);
    }
    // 将sku的销售属性hash表放到页面
    String skuSaleAttrHashJsonStr = JSON.toJSONString(skuSaleAttrHash);
    map.put("skuSaleAttrHashJsonStr", skuSaleAttrHashJsonStr);
    return "item";
}
Also used : PmsProductSaleAttr(com.xatu.gmall.entity.PmsProductSaleAttr) HashMap(java.util.HashMap) PmsSkuSaleAttrValue(com.xatu.gmall.entity.PmsSkuSaleAttrValue) PmsSkuInfo(com.xatu.gmall.entity.PmsSkuInfo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with PmsProductSaleAttr

use of com.xatu.gmall.entity.PmsProductSaleAttr 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

PmsProductSaleAttr (com.xatu.gmall.entity.PmsProductSaleAttr)3 PmsProductSaleAttrValue (com.xatu.gmall.entity.PmsProductSaleAttrValue)2 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)1 PmsProductImage (com.xatu.gmall.entity.PmsProductImage)1 PmsSkuInfo (com.xatu.gmall.entity.PmsSkuInfo)1 PmsSkuSaleAttrValue (com.xatu.gmall.entity.PmsSkuSaleAttrValue)1 HashMap (java.util.HashMap)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1