| @@ -3,16 +3,14 @@ package com.iformall.service.impl; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.WxProjectConfig; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.WxMall; | |||
| import com.iformall.domain.po.WxMallBuilding; | |||
| import com.iformall.domain.po.WxMallFloor; | |||
| import com.iformall.mapper.WxMallBuildingMapper; | |||
| import com.iformall.mapper.WxMallFloorMapper; | |||
| import com.iformall.mapper.WxMallMapper; | |||
| import com.iformall.service.WxMallService; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.RedisCacheUtils; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -44,8 +42,10 @@ public class WxMallServiceImpl implements WxMallService { | |||
| RedisTemplate<String, WxMall> mallRedisTemplate; | |||
| @Autowired | |||
| @Qualifier("subMallListRedisTemplate") | |||
| RedisTemplate<String, List<WxMall>> subMallListRedisTemplate; | |||
| @Qualifier("objectCommonRedisTemplate") | |||
| RedisTemplate<String, Object> subMallListRedisTemplate; | |||
| @Override | |||
| public String wxMallInit(WxProjectConfig wxProjectConfig) { | |||
| @@ -211,16 +211,13 @@ public class WxMallServiceImpl implements WxMallService { | |||
| @Override | |||
| public List<WxMall> getSubByParentTenantId(String parentTenantId) { | |||
| String key = Constant.subMallinfoPrev + parentTenantId; | |||
| ValueOperations<String, List<WxMall>> operations = subMallListRedisTemplate.opsForValue(); | |||
| if(subMallListRedisTemplate.hasKey(key)) { | |||
| List<WxMall> wxMalls = operations.get(key); | |||
| return wxMalls; | |||
| List<WxMall> mallList = RedisCacheUtils.getCacheListObject(subMallListRedisTemplate, key, WxMall.class); | |||
| if(null == mallList || mallList.size() == 0){ | |||
| WxMall q = new WxMall(); | |||
| q.setParentTenantId(parentTenantId); | |||
| mallList = wxMallMapper.selectList(new QueryWrapper<>(q)); | |||
| RedisCacheUtils.cache(subMallListRedisTemplate, key, mallList, 3600*24*7); | |||
| } | |||
| WxMall q = new WxMall(); | |||
| q.setParentTenantId(parentTenantId); | |||
| List<WxMall> mallList = wxMallMapper.selectList(new QueryWrapper<>(q)); | |||
| operations.set(key, mallList, 7, TimeUnit.DAYS); | |||
| return mallList; | |||
| } | |||
| @@ -243,14 +240,10 @@ public class WxMallServiceImpl implements WxMallService { | |||
| mallRedisTemplate.delete(key1); | |||
| } | |||
| String key2 = Constant.subMallinfoPrev + tenantEntity.getTenantId(); | |||
| if(subMallListRedisTemplate.hasKey(key2)){ | |||
| subMallListRedisTemplate.delete(key2); | |||
| } | |||
| RedisCacheUtils.removeCache(subMallListRedisTemplate, key2); | |||
| if(StringUtils.isNotBlank(tenantEntity.getParentTenantId())){ | |||
| String key3 = Constant.subMallinfoPrev + tenantEntity.getParentTenantId(); | |||
| if(subMallListRedisTemplate.hasKey(key3)){ | |||
| subMallListRedisTemplate.delete(key3); | |||
| } | |||
| RedisCacheUtils.removeCache(subMallListRedisTemplate, key3); | |||
| } | |||
| } | |||