| @@ -94,6 +94,7 @@ public class WxCouponChannelController extends BaseController { | |||||
| wxCouponChannelService.updateQrCode(couponChannel,couponChannel.getId(),couponChannel.getType()); | wxCouponChannelService.updateQrCode(couponChannel,couponChannel.getId(),couponChannel.getType()); | ||||
| } | } | ||||
| CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId()); | CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId()); | ||||
| CouponCacheUtils.removeDouyinLivePageCache(redisTemplate, wxCouponChannel.getTenantId(), null, null); | |||||
| return resultData; | return resultData; | ||||
| } | } | ||||
| @@ -30,6 +30,7 @@ import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.vo.WxCouponChannelVo; | import com.iformall.domain.vo.WxCouponChannelVo; | ||||
| import com.iformall.service.WxCouponChannelService; | import com.iformall.service.WxCouponChannelService; | ||||
| import com.iformall.service.WxMerchantService; | import com.iformall.service.WxMerchantService; | ||||
| import com.iformall.service.util.CouponCacheUtils; | |||||
| import com.iformall.utils.RedisCacheUtils; | import com.iformall.utils.RedisCacheUtils; | ||||
| import io.swagger.annotations.Api; | 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.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC, BaseEntity.SortField.CCId_DESC); | ||||
| wxCouponChannel.setShowBeginTime(new Date()); | 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 ) { | if (null == page ) { | ||||
| page = wxCouponChannelService.liveHomePage(wxCouponChannel, pageNum, pageSize); | page = wxCouponChannelService.liveHomePage(wxCouponChannel, pageNum, pageSize); | ||||
| if(page.getList() != null && page.getList().size() > 0){ | 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); | return new ResultData(page); | ||||
| @@ -2,11 +2,14 @@ package com.iformall.service.util; | |||||
| import java.util.List; | import java.util.List; | ||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | import org.springframework.data.redis.core.RedisTemplate; | ||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.WxCoupon; | import com.iformall.domain.po.WxCoupon; | ||||
| import com.iformall.domain.po.WxCouponChannel; | import com.iformall.domain.po.WxCouponChannel; | ||||
| import com.iformall.domain.vo.WxMerchantVo; | import com.iformall.domain.vo.WxMerchantVo; | ||||
| import com.iformall.enums.EnumCacheKey; | |||||
| import com.iformall.utils.RedisCacheUtils; | import com.iformall.utils.RedisCacheUtils; | ||||
| public class CouponCacheUtils { | public class CouponCacheUtils { | ||||
| @@ -57,19 +60,25 @@ public class CouponCacheUtils { | |||||
| return RedisCacheUtils.getCacheListObject(template, key,WxMerchantVo.class); | 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); | |||||
| } | |||||
| } | } | ||||
| @@ -164,4 +164,9 @@ public class RedisCacheUtils { | |||||
| template.delete(key); | template.delete(key); | ||||
| } | } | ||||
| } | } | ||||
| public static void removeCachePrefix(RedisTemplate<String, Object> template,String prefix) { | |||||
| Set keys = template.keys(prefix+"*"); | |||||
| template.delete(keys); | |||||
| } | |||||
| } | } | ||||