Ver a proveniência

[修改][卷列表][添加缓存]

release_toaliyun_real
luozukai há 6 anos
ascendente
cometimento
4150701677
3 ficheiros alterados com 40 adições e 5 eliminações
  1. +20
    -0
      mallinkAdmin/src/main/java/com/iformall/config/RedisConfig.java
  2. +2
    -1
      mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java
  3. +18
    -4
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java

+ 20
- 0
mallinkAdmin/src/main/java/com/iformall/config/RedisConfig.java Ver ficheiro

@@ -1,9 +1,11 @@
package com.iformall.config; package com.iformall.config;


import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.PushLimit; import com.iformall.domain.po.PushLimit;
import com.iformall.domain.po.WxCUser; import com.iformall.domain.po.WxCUser;
import com.iformall.domain.po.WxMall; import com.iformall.domain.po.WxMall;
import com.iformall.domain.po.WxScoreRules; import com.iformall.domain.po.WxScoreRules;
import com.iformall.domain.vo.WxCouponChannelVo;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.cache.CacheManager; import org.springframework.cache.CacheManager;
@@ -160,4 +162,22 @@ public class RedisConfig extends CachingConfigurerSupport {
return template; return template;
} }



@Bean("couponChannelRedisTemplate")
public RedisTemplate<String, PageInfo<WxCouponChannelVo>> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>();

Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);

// key的序列化
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());

template.setConnectionFactory(connectionFactory);
return template;
}

} }

+ 2
- 1
mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java Ver ficheiro

@@ -67,7 +67,6 @@ public class WxCouponChannelController extends BaseController {
return new ResultData(page); return new ResultData(page);
} }



@ApiOperation("根据id更新接口") @ApiOperation("根据id更新接口")
@PostMapping("update") @PostMapping("update")
@SystemControllerLog(description = "券投放-更新") @SystemControllerLog(description = "券投放-更新")
@@ -92,6 +91,8 @@ public class WxCouponChannelController extends BaseController {
return resultData; return resultData;
} }




@ApiOperation("根据id查询接口") @ApiOperation("根据id查询接口")
@GetMapping("/findById") @GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)


+ 18
- 4
mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java Ver ficheiro

@@ -118,9 +118,23 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
record.setUpdateDate(new Date()); record.setUpdateDate(new Date());
wxCouponChannelMapper.updateByPrimaryKeySelective(record); wxCouponChannelMapper.updateByPrimaryKeySelective(record);
} }

//清除缓存
clearCache(record.getTenantId());
return new ResultData(); return new ResultData();
} }


/**
* 清除c端首页卷列表缓存
* @param tenantId
*/
public void clearCache(String tenantId){
for (int i = 1; i <=20 ; i++) {
String key = "couponChannelList_"+tenantId+"_" + i + ":";
cdRedisTemplate.delete(key);
}
}

@Override @Override
public ResultData addBatch(String[] ids, String[] channelId, String tanantId, Date beginTime, Date endTime) { public ResultData addBatch(String[] ids, String[] channelId, String tanantId, Date beginTime, Date endTime) {
List<WxCouponChannelAddVo> errorList = new ArrayList<>(); List<WxCouponChannelAddVo> errorList = new ArrayList<>();
@@ -293,14 +307,14 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
public PageInfo<WxCouponChannelVo> listPageCVo(WxCouponChannel record, Integer pageIndex, Integer pageSize) { public PageInfo<WxCouponChannelVo> listPageCVo(WxCouponChannel record, Integer pageIndex, Integer pageSize) {
PageInfo<WxCouponChannelVo> pageInfo; PageInfo<WxCouponChannelVo> pageInfo;
//首页走缓存 //首页走缓存
if(EnumTargetAd.LIST.getCode().equals(record.getTargetAd()) && new Integer(6).equals(pageSize)) {
//logger.info("---------chache");
String key = "couponChannelList_" + pageIndex + ":";
if(EnumTargetAd.LIST.getCode().equals(record.getTargetAd()) && new Integer(6).equals(pageSize) && pageIndex.intValue() <=20 ) {
logger.info("---------chache");
String key = "couponChannelList_"+record.getTenantId()+"_" + pageIndex + ":";
ValueOperations<String, PageInfo<WxCouponChannelVo>> operations = cdRedisTemplate.opsForValue(); ValueOperations<String, PageInfo<WxCouponChannelVo>> operations = cdRedisTemplate.opsForValue();
boolean hasKey = cdRedisTemplate.hasKey(key); boolean hasKey = cdRedisTemplate.hasKey(key);
if (hasKey) { if (hasKey) {
pageInfo = operations.get(key); pageInfo = operations.get(key);
//logger.info("---------get:{}",pageInfo.getList().size());
logger.info("---------get:{}",pageInfo.getList().size());
}else{ }else{
pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.findVoList(record)); pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.findVoList(record));
} }


Carregando…
Cancelar
Guardar