winter 4 лет назад
Родитель
Сommit
7e18df25f6
4 измененных файлов: 32 добавлений и 22 удалений
  1. +1
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java
  2. +3
    -8
      mallinkCApi/src/main/java/com/iformall/controller/WxCouponChannelController.java
  3. +23
    -14
      mallinkService/src/main/java/com/iformall/service/util/CouponCacheUtils.java
  4. +5
    -0
      mallinkService/src/main/java/com/iformall/utils/RedisCacheUtils.java

+ 1
- 0
mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java Просмотреть файл

@@ -94,6 +94,7 @@ public class WxCouponChannelController extends BaseController {
wxCouponChannelService.updateQrCode(couponChannel,couponChannel.getId(),couponChannel.getType());
}
CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId());
CouponCacheUtils.removeDouyinLivePageCache(redisTemplate, wxCouponChannel.getTenantId(), null, null);
return resultData;
}



+ 3
- 8
mallinkCApi/src/main/java/com/iformall/controller/WxCouponChannelController.java Просмотреть файл

@@ -30,6 +30,7 @@ import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.vo.WxCouponChannelVo;
import com.iformall.service.WxCouponChannelService;
import com.iformall.service.WxMerchantService;
import com.iformall.service.util.CouponCacheUtils;
import com.iformall.utils.RedisCacheUtils;

import io.swagger.annotations.Api;
@@ -113,17 +114,11 @@ public class WxCouponChannelController extends BaseController {
wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC, BaseEntity.SortField.CCId_DESC);
wxCouponChannel.setShowBeginTime(new Date());

String key = EnumCacheKey.DOUYIN_LIVE_PAGE_LIST.getMessage()
+ wxCouponChannel.getTenantId() + "_"
+ wxCouponChannel.getTargetAd() + "_"
+ wxCouponChannel.getBusiness() + "_"
+ pageNum + ":"+ pageNum + ":";
PageInfo<WxCoupon> page = RedisCacheUtils.getCacheObject(redisTemplate, key, PageInfo.class);
logger.info("WxCouponChannelController.chache.get:{} page:{}",key,page);
PageInfo<WxCoupon> page = CouponCacheUtils.getDouyinLivePageCache(redisTemplate, wxCouponChannel.getTenantId(), wxCouponChannel.getTargetAd(), wxCouponChannel.getBusiness(), pageNum);
if (null == page ) {
page = wxCouponChannelService.liveHomePage(wxCouponChannel, pageNum, pageSize);
if(page.getList() != null && page.getList().size() > 0){
RedisCacheUtils.cache(redisTemplate, key, page, 60*60);
CouponCacheUtils.setDouyinLivePageCache(redisTemplate, page, wxCouponChannel.getTenantId(), wxCouponChannel.getTargetAd(), wxCouponChannel.getBusiness(), pageNum);
}
}
return new ResultData(page);


+ 23
- 14
mallinkService/src/main/java/com/iformall/service/util/CouponCacheUtils.java Просмотреть файл

@@ -2,11 +2,14 @@ package com.iformall.service.util;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.data.redis.core.RedisTemplate;

import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.WxCouponChannel;
import com.iformall.domain.vo.WxMerchantVo;
import com.iformall.enums.EnumCacheKey;
import com.iformall.utils.RedisCacheUtils;

public class CouponCacheUtils {
@@ -57,19 +60,25 @@ public class CouponCacheUtils {
return RedisCacheUtils.getCacheListObject(template, key,WxMerchantVo.class);
}
// public static void removeDouyinLivePageCache(RedisTemplate<String, Object> template,String tenantId,Integer targetAd,Integer bussiness) {
// String key = "couponMerchant:"+couponId;
// RedisCacheUtils.removeCache(template, key);
// }
//
// public static void setDouyinLivePageCache(RedisTemplate<String, Object> template,Long couponId,List<WxMerchantVo> merchantList) {
// String key = "couponMerchant:"+couponId;
// RedisCacheUtils.cache(template, key, merchantList, 24*3600);
// }
//
// public static List<WxMerchantVo> getDouyinLivePageCache(RedisTemplate<String, Object> template,Long couponId) {
// String key = "couponMerchant:"+couponId;
// return RedisCacheUtils.getCacheListObject(template, key,WxMerchantVo.class);
// }
public static void removeDouyinLivePageCache(RedisTemplate<String, Object> template,String tenantId,Integer targetAd,Integer bussiness) {
String key = EnumCacheKey.DOUYIN_LIVE_PAGE_LIST.getMessage()+ tenantId+"_";
if (null != targetAd) {
key = key + targetAd;
if ( null != bussiness) {
key = key + "_"+ bussiness;
}
}
RedisCacheUtils.removeCachePrefix(template, key);
}
public static void setDouyinLivePageCache(RedisTemplate<String, Object> template,PageInfo<WxCoupon> pageList,String tenantId,Integer targetAd,Integer bussiness,Integer pageNum) {
String key = EnumCacheKey.DOUYIN_LIVE_PAGE_LIST.getMessage()+ tenantId + "_"+ targetAd + "_"+ bussiness+"_"+pageNum;
RedisCacheUtils.cache(template, key, pageList, 3*3600);
}
public static PageInfo getDouyinLivePageCache(RedisTemplate<String, Object> template,String tenantId,Integer targetAd,Integer bussiness,Integer pageNum) {
String key = EnumCacheKey.DOUYIN_LIVE_PAGE_LIST.getMessage()+ tenantId + "_"+ targetAd + "_"+ bussiness+"_"+pageNum;
return RedisCacheUtils.getCacheObject(template, key,PageInfo.class);
}
}

+ 5
- 0
mallinkService/src/main/java/com/iformall/utils/RedisCacheUtils.java Просмотреть файл

@@ -164,4 +164,9 @@ public class RedisCacheUtils {
template.delete(key);
}
}
public static void removeCachePrefix(RedisTemplate<String, Object> template,String prefix) {
Set keys = template.keys(prefix+"*");
template.delete(keys);
}
}

Загрузка…
Отмена
Сохранить