1.接口文档
2.SpuInfoController中添加spuUp方法
/**
* 商品上架
* @param spuId
* @return
*/
@PostMapping("/{spuId}/up")
public R spuUp(@PathVariable("spuId") Long spuId) {
spuInfoService.up(spuId);
return R.ok();
}
3.SpuInfoService中添加up方法
void up(Long spuId);
4.sku在ES中模型
在gulimall-common项目中新建es包
package com.atguigu.common.to.es;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* spu在es中模型
* @author zfh
* @email hst1406959716@163.com
* @date 2021-12-14 09:40:46
*/
@Data
public class SkuEsModel {
private Long skuId;
private Long spuId;
private String skuTitle;
private BigDecimal skuPrice;
private String skuImg;
private Long saleCount;
private Boolean hasStock;
private Long hotScore;
private Long brandId;
private Long catalogId;
private String brandName;
private String brandImg;
private String catalogName;
private List<Attrs> attrs;
@Data
public static class Attrs {
private Long attrId;
private String attrName;
private String attrValue;
}
}
5.查询当前spuId对应的sku
5.1.SkuInfoService添加getSkusBySpuId方法
List<SkuInfoEntity> getSkusBySpuId(Long spuId);
5.2.SkuInfoServiceImpl中添加getSkusBySpuId方法实现
/**
* 根据spuId查询对应的sku
* @param spuId
* @return
*/
@Override
public List<SkuInfoEntity> getSkusBySpuId(Long spuId) {
List<SkuInfoEntity> skuInfoEntities = this.list(
new QueryWrapper<SkuInfoEntity>().eq("spu_id", spuId));
return skuInfoEntities;
}
6.查询当前sku所有可被检索的规格属性
6.1.AttrService中添加selectSearchAttrIds
List<Long> selectSearchAttrIds(List<Long> attrIds);
6.2.AttrServiceImpl添加selectSearchAttrIds方法实现
/**
* 在指定的所有属性中挑出可被检索的属性
* @param attrIds
* @return
*/
@Override
public List<Long> selectSearchAttrIds(List<Long> attrIds) {
return baseMapper.selectSearchAttrIds(attrIds);
}
6.3.AttrDao中添加selectSearchAttrIds
List<Long> selectSearchAttrIds(@Param("attrIds") List<Long> attrIds);
6.4.AttrDao.xml
<select id="selectSearchAttrIds" resultType="java.lang.Long">
SELECT attr_id FROM pms_attr WHERE attr_id IN
<foreach collection="attrIds" item="attrId" separator="," open="(" close=")">
#{attrId}
</foreach>
AND search_type = 1
</select>