You've already forked FrameTour-BE
Merge branch 'rem_old_price_config'
This commit is contained in:
@@ -3,23 +3,17 @@ package com.ycwl.basic.repository;
|
||||
import com.ycwl.basic.pricing.entity.PriceOnePriceConfig;
|
||||
import com.ycwl.basic.pricing.service.IOnePricePurchaseService;
|
||||
import com.ycwl.basic.utils.JacksonUtil;
|
||||
import com.ycwl.basic.mapper.PriceConfigMapper;
|
||||
import com.ycwl.basic.model.pc.price.entity.PriceConfigEntity;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Component
|
||||
public class PriceRepository {
|
||||
@Autowired
|
||||
private PriceConfigMapper mapper;
|
||||
@Autowired
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
public static final String PRICE_SCENIC_TYPE_GOODS_CACHE = "price:s%s:t%s:g%s";
|
||||
public static final String PRICE_ID_CACHE = "price:%s";
|
||||
@Autowired
|
||||
private IOnePricePurchaseService onePricePurchaseService;
|
||||
@@ -39,19 +33,7 @@ public class PriceRepository {
|
||||
entity.setGoodsIds(goodsId);
|
||||
return entity;
|
||||
}
|
||||
String cacheKey = String.format(PRICE_SCENIC_TYPE_GOODS_CACHE, scenicId, type, goodsId);
|
||||
PriceConfigEntity priceConfigEntity = null;
|
||||
if (redisTemplate.hasKey(cacheKey)) {
|
||||
priceConfigEntity = JacksonUtil.parseObject(redisTemplate.opsForValue().get(cacheKey), PriceConfigEntity.class);
|
||||
}
|
||||
if (priceConfigEntity == null) {
|
||||
priceConfigEntity = mapper.getPriceByScenicTypeGoods(scenicId, type, goodsId);
|
||||
if (priceConfigEntity != null) {
|
||||
redisTemplate.opsForValue().set(cacheKey, JacksonUtil.toJSONString(priceConfigEntity), 12, TimeUnit.HOURS);
|
||||
redisTemplate.opsForValue().set(String.format(PRICE_ID_CACHE, priceConfigEntity.getId()), JacksonUtil.toJSONString(priceConfigEntity), 12, TimeUnit.HOURS);
|
||||
}
|
||||
}
|
||||
return priceConfigEntity;
|
||||
return null;
|
||||
}
|
||||
|
||||
public PriceConfigEntity getPriceConfig(Integer id) {
|
||||
|
Reference in New Issue
Block a user