初始化索引,按照规格去生成索引

This commit is contained in:
lifenlong
2021-08-03 23:28:16 +08:00
parent 99f93b516a
commit ce22c9b7ff
3 changed files with 10 additions and 10 deletions

View File

@@ -2,8 +2,8 @@ package cn.lili.controller.other;
import cn.hutool.json.JSONUtil;
import cn.lili.modules.goods.entity.dos.Goods;
import cn.lili.modules.goods.entity.dto.GoodsParamsDTO;
import cn.lili.modules.goods.entity.dos.GoodsSku;
import cn.lili.modules.goods.entity.dto.GoodsParamsDTO;
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
import cn.lili.modules.goods.service.GoodsService;
@@ -66,7 +66,6 @@ public class ElasticsearchController {
String goodsId = null;
//库存锁是在redis做的所以生成索引同时更新一下redis中的库存数量
for (GoodsSku goodsSku : list) {
if (goodsId == null || !goodsId.equals(goodsSku.getGoodsId())) {
goodsId = goodsSku.getGoodsId();
Goods goods = goodsService.getById(goodsId);
EsGoodsIndex index = new EsGoodsIndex(goodsSku);
@@ -78,7 +77,7 @@ public class ElasticsearchController {
index.setPromotionMap(goodsCurrentPromotionMap);
esGoodsIndices.add(index);
stringRedisTemplate.opsForValue().set(GoodsSkuService.getStockCacheKey(goodsSku.getId()), goodsSku.getQuantity().toString());
}
}
//初始化商品索引
esGoodsIndexService.initIndex(esGoodsIndices);