清除分类商品缓存

This commit is contained in:
Tankaikai
2025-04-16 16:12:31 +08:00
parent 6d0cef6667
commit 1c5cc04769
5 changed files with 36 additions and 25 deletions

View File

@@ -12,6 +12,8 @@ import com.czg.product.enums.InOutTypeEnum;
import com.czg.product.service.ConsStockFlowService;
import com.czg.product.service.ProductRpcService;
import com.czg.product.service.ProductStockFlowService;
import com.czg.product.vo.ProductVO;
import com.czg.service.RedisService;
import com.czg.service.product.mapper.ConsInfoMapper;
import com.czg.service.product.mapper.ProdConsRelationMapper;
import com.czg.service.product.mapper.ProductMapper;
@@ -26,6 +28,8 @@ import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import static com.czg.constant.CacheConstant.ADMIN_CLIENT_PRODUCT_LIST;
/**
* 商品RPC远程调用服务接口实现
*
@@ -51,6 +55,8 @@ public class ProductRpcServiceImpl implements ProductRpcService {
private ProductStockFlowService productStockFlowService;
@Resource
private RabbitPublisher rabbitPublisher;
@Resource
private RedisService redisService;
@Override
@Transactional(rollbackFor = Exception.class)
@@ -275,4 +281,15 @@ public class ProductRpcServiceImpl implements ProductRpcService {
//ThreadUtil.execAsync(() -> rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId)));
log.info("ProductService.--------------------------------------------库存更新成功");
}
@Override
public List<ProductVO> listAndLowPrice(Long shopId, List<Long> productIds) {
return productMapper.productList(shopId, productIds);
}
@Override
public void cleanCategoryProduct(Long shopId, Long categoryId) {
String key = ADMIN_CLIENT_PRODUCT_LIST + "::" + shopId + "::" + categoryId;
redisService.del(key);
}
}

View File

@@ -20,7 +20,6 @@ import com.czg.product.enums.*;
import com.czg.product.param.*;
import com.czg.product.service.*;
import com.czg.product.vo.ProductStatisticsVo;
import com.czg.product.vo.ProductVO;
import com.czg.sa.StpKit;
import com.czg.service.RedisService;
import com.czg.service.product.mapper.*;
@@ -773,15 +772,4 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
record.setStockNumber(stock.getOrDefault(record.getId(), 0));
});
}
@Override
public List<ProductVO> listAndLowPrice(Long shopId, List<Long> productIds) {
return mapper.productList(shopId, productIds);
}
@Override
public void cleanCategoryProduct(Long shopId, Long categoryId) {
String key = ADMIN_CLIENT_PRODUCT_LIST + "::" + shopId + "::" + categoryId;
redisService.del(key);
}
}