Authored by Lixiaodi

缓存清理

@@ -30,9 +30,6 @@ public class DepositController { @@ -30,9 +30,6 @@ public class DepositController {
30 private final Logger LOG = LoggerFactory.getLogger(this.getClass()); 30 private final Logger LOG = LoggerFactory.getLogger(this.getClass());
31 31
32 @Autowired 32 @Autowired
33 - private ControllerCacheAop cacheAop;  
34 -  
35 - @Autowired  
36 private DepositService depositService; 33 private DepositService depositService;
37 34
38 @RequestMapping(params = "method=ufo.deposit.queryUserDoposit") 35 @RequestMapping(params = "method=ufo.deposit.queryUserDoposit")
@@ -131,24 +128,7 @@ public class DepositController { @@ -131,24 +128,7 @@ public class DepositController {
131 Integer productId = bo.getProductId(); 128 Integer productId = bo.getProductId();
132 Integer storageId = bo.getStorageId(); 129 Integer storageId = bo.getStorageId();
133 LOG.info("in clearUserDepositCache bo={}", bo); 130 LOG.info("in clearUserDepositCache bo={}", bo);
134 - try {  
135 - Method queryUserDoposit = DepositController.class.getMethod("queryUserDoposit", new Class[]{Integer.class, Integer.class, Integer.class});  
136 - cacheAop.clearCache(queryUserDoposit, new Object[]{uid, 0, 0});  
137 -  
138 - Method queryUserDopositBackDetail = DepositController.class.getMethod("queryUserDopositBackDetail", new Class[]{Integer.class, Integer.class, Integer.class});  
139 - cacheAop.clearCache(queryUserDopositBackDetail, new Object[]{uid, 0, 0});  
140 -  
141 - Method queryUserDopositing = DepositController.class.getMethod("queryUserDopositing", new Class[]{Integer.class, Integer.class, Integer.class, Integer.class});  
142 - cacheAop.clearCache(queryUserDopositBackDetail, new Object[]{uid, productId, 0, 0});  
143 -  
144 - Method queryUserStorageOffCount = DepositController.class.getMethod("queryUserStorageOffCount", new Class[]{Integer.class, Integer.class});  
145 - cacheAop.clearCache(queryUserStorageOffCount, new Object[]{uid, storageId});  
146 -  
147 - Method queryUserStorageCount = DepositController.class.getMethod("queryUserStorageCount", new Class[]{Integer.class});  
148 - cacheAop.clearCache(queryUserStorageCount, new Object[]{uid});  
149 - } catch (Exception e) {  
150 - LOG.error("删除用户寄存缓存失败!", e);  
151 - } 131 + depositService.clearCache(uid, productId, storageId);
152 return new ApiResponse(200, "缓存清除成功!", Boolean.TRUE); 132 return new ApiResponse(200, "缓存清除成功!", Boolean.TRUE);
153 } 133 }
154 } 134 }
@@ -41,6 +41,8 @@ public interface DepositService { @@ -41,6 +41,8 @@ public interface DepositService {
41 // 剩余存储天数 41 // 剩余存储天数
42 int getRemainDay(Integer uid, String depositCode); 42 int getRemainDay(Integer uid, String depositCode);
43 43
  44 + void clearCache(Integer uid, Integer productId, Integer storageId);
  45 +
44 int changeStorageStatus(String depositCode, int status, int orderStatus); 46 int changeStorageStatus(String depositCode, int status, int orderStatus);
45 47
46 /** 48 /**
@@ -7,6 +7,8 @@ import com.yohobuy.ufo.model.order.bo.DepositProductBo; @@ -7,6 +7,8 @@ import com.yohobuy.ufo.model.order.bo.DepositProductBo;
7 import com.yohobuy.ufo.model.order.constants.DepositOrderStatusEnum; 7 import com.yohobuy.ufo.model.order.constants.DepositOrderStatusEnum;
8 import com.yohobuy.ufo.model.order.constants.StorageDepositStatusEnum; 8 import com.yohobuy.ufo.model.order.constants.StorageDepositStatusEnum;
9 import com.yohobuy.ufo.model.order.resp.PageResp; 9 import com.yohobuy.ufo.model.order.resp.PageResp;
  10 +import com.yohoufo.common.ApiResponse;
  11 +import com.yohoufo.common.cache.ControllerCacheAop;
10 import com.yohoufo.common.exception.UfoServiceException; 12 import com.yohoufo.common.exception.UfoServiceException;
11 import com.yohoufo.common.helper.ImageUrlAssist; 13 import com.yohoufo.common.helper.ImageUrlAssist;
12 import com.yohoufo.dal.order.SellerOrderGoodsMapper; 14 import com.yohoufo.dal.order.SellerOrderGoodsMapper;
@@ -14,6 +16,7 @@ import com.yohoufo.dal.order.StorageDepositMapper; @@ -14,6 +16,7 @@ import com.yohoufo.dal.order.StorageDepositMapper;
14 import com.yohoufo.dal.order.model.SellerOrderGoods; 16 import com.yohoufo.dal.order.model.SellerOrderGoods;
15 import com.yohoufo.dal.order.model.StorageDeposit; 17 import com.yohoufo.dal.order.model.StorageDeposit;
16 import com.yohoufo.dal.order.model.StorageDepositCount; 18 import com.yohoufo.dal.order.model.StorageDepositCount;
  19 +import com.yohoufo.order.controller.DepositController;
17 import com.yohoufo.order.service.DepositService; 20 import com.yohoufo.order.service.DepositService;
18 import com.yohoufo.order.service.proxy.ProductProxyService; 21 import com.yohoufo.order.service.proxy.ProductProxyService;
19 import org.slf4j.Logger; 22 import org.slf4j.Logger;
@@ -21,6 +24,7 @@ import org.slf4j.LoggerFactory; @@ -21,6 +24,7 @@ import org.slf4j.LoggerFactory;
21 import org.springframework.beans.factory.annotation.Autowired; 24 import org.springframework.beans.factory.annotation.Autowired;
22 import org.springframework.stereotype.Service; 25 import org.springframework.stereotype.Service;
23 26
  27 +import java.lang.reflect.Method;
24 import java.math.BigDecimal; 28 import java.math.BigDecimal;
25 import java.util.*; 29 import java.util.*;
26 import java.util.function.Function; 30 import java.util.function.Function;
@@ -33,6 +37,9 @@ public class DepositServiceImpl implements DepositService { @@ -33,6 +37,9 @@ public class DepositServiceImpl implements DepositService {
33 private final Logger LOGGER = LoggerFactory.getLogger(DepositServiceImpl.class); 37 private final Logger LOGGER = LoggerFactory.getLogger(DepositServiceImpl.class);
34 38
35 @Autowired 39 @Autowired
  40 + private ControllerCacheAop cacheAop;
  41 +
  42 + @Autowired
36 private ProductProxyService productProxyService; 43 private ProductProxyService productProxyService;
37 44
38 @Autowired 45 @Autowired
@@ -285,6 +292,34 @@ public class DepositServiceImpl implements DepositService { @@ -285,6 +292,34 @@ public class DepositServiceImpl implements DepositService {
285 return storageDepositMapper.updateStorageStatus(depositCode, status, orderStatus); 292 return storageDepositMapper.updateStorageStatus(depositCode, status, orderStatus);
286 } 293 }
287 294
  295 + public void clearCache(Integer uid, Integer productId, Integer storageId) {
  296 + if (uid == null) {
  297 + return;
  298 + }
  299 + try {
  300 + Method queryUserDoposit = DepositController.class.getMethod("queryUserDoposit", new Class[]{Integer.class, Integer.class, Integer.class});
  301 + cacheAop.clearCache(queryUserDoposit, new Object[]{uid, 0, 0});
  302 +
  303 + Method queryUserDopositBackDetail = DepositController.class.getMethod("queryUserDopositBackDetail", new Class[]{Integer.class, Integer.class, Integer.class});
  304 + cacheAop.clearCache(queryUserDopositBackDetail, new Object[]{uid, 0, 0});
  305 +
  306 + if (productId != null) {
  307 + Method queryUserDopositing = DepositController.class.getMethod("queryUserDopositing", new Class[]{Integer.class, Integer.class, Integer.class, Integer.class});
  308 + cacheAop.clearCache(queryUserDopositBackDetail, new Object[]{uid, productId, 0, 0});
  309 + }
  310 +
  311 + if (storageId != null) {
  312 + Method queryUserStorageOffCount = DepositController.class.getMethod("queryUserStorageOffCount", new Class[]{Integer.class, Integer.class});
  313 + cacheAop.clearCache(queryUserStorageOffCount, new Object[]{uid, storageId});
  314 + }
  315 +
  316 + Method queryUserStorageCount = DepositController.class.getMethod("queryUserStorageCount", new Class[]{Integer.class});
  317 + cacheAop.clearCache(queryUserStorageCount, new Object[]{uid});
  318 + } catch (Exception e) {
  319 + LOGGER.error("删除用户寄存缓存失败!", e);
  320 + }
  321 + }
  322 +
288 /** 323 /**
289 * Do 转 Vo 324 * Do 转 Vo
290 * @param storageDeposit 325 * @param storageDeposit