Authored by Lixiaodi

缓存清理

... ... @@ -30,9 +30,6 @@ public class DepositController {
private final Logger LOG = LoggerFactory.getLogger(this.getClass());
@Autowired
private ControllerCacheAop cacheAop;
@Autowired
private DepositService depositService;
@RequestMapping(params = "method=ufo.deposit.queryUserDoposit")
... ... @@ -131,24 +128,7 @@ public class DepositController {
Integer productId = bo.getProductId();
Integer storageId = bo.getStorageId();
LOG.info("in clearUserDepositCache bo={}", bo);
try {
Method queryUserDoposit = DepositController.class.getMethod("queryUserDoposit", new Class[]{Integer.class, Integer.class, Integer.class});
cacheAop.clearCache(queryUserDoposit, new Object[]{uid, 0, 0});
Method queryUserDopositBackDetail = DepositController.class.getMethod("queryUserDopositBackDetail", new Class[]{Integer.class, Integer.class, Integer.class});
cacheAop.clearCache(queryUserDopositBackDetail, new Object[]{uid, 0, 0});
Method queryUserDopositing = DepositController.class.getMethod("queryUserDopositing", new Class[]{Integer.class, Integer.class, Integer.class, Integer.class});
cacheAop.clearCache(queryUserDopositBackDetail, new Object[]{uid, productId, 0, 0});
Method queryUserStorageOffCount = DepositController.class.getMethod("queryUserStorageOffCount", new Class[]{Integer.class, Integer.class});
cacheAop.clearCache(queryUserStorageOffCount, new Object[]{uid, storageId});
Method queryUserStorageCount = DepositController.class.getMethod("queryUserStorageCount", new Class[]{Integer.class});
cacheAop.clearCache(queryUserStorageCount, new Object[]{uid});
} catch (Exception e) {
LOG.error("删除用户寄存缓存失败!", e);
}
depositService.clearCache(uid, productId, storageId);
return new ApiResponse(200, "缓存清除成功!", Boolean.TRUE);
}
}
... ...
... ... @@ -41,6 +41,8 @@ public interface DepositService {
// 剩余存储天数
int getRemainDay(Integer uid, String depositCode);
void clearCache(Integer uid, Integer productId, Integer storageId);
int changeStorageStatus(String depositCode, int status, int orderStatus);
/**
... ...
... ... @@ -7,6 +7,8 @@ import com.yohobuy.ufo.model.order.bo.DepositProductBo;
import com.yohobuy.ufo.model.order.constants.DepositOrderStatusEnum;
import com.yohobuy.ufo.model.order.constants.StorageDepositStatusEnum;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.cache.ControllerCacheAop;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.common.helper.ImageUrlAssist;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
... ... @@ -14,6 +16,7 @@ import com.yohoufo.dal.order.StorageDepositMapper;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.dal.order.model.StorageDeposit;
import com.yohoufo.dal.order.model.StorageDepositCount;
import com.yohoufo.order.controller.DepositController;
import com.yohoufo.order.service.DepositService;
import com.yohoufo.order.service.proxy.ProductProxyService;
import org.slf4j.Logger;
... ... @@ -21,6 +24,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
... ... @@ -33,6 +37,9 @@ public class DepositServiceImpl implements DepositService {
private final Logger LOGGER = LoggerFactory.getLogger(DepositServiceImpl.class);
@Autowired
private ControllerCacheAop cacheAop;
@Autowired
private ProductProxyService productProxyService;
@Autowired
... ... @@ -285,6 +292,34 @@ public class DepositServiceImpl implements DepositService {
return storageDepositMapper.updateStorageStatus(depositCode, status, orderStatus);
}
public void clearCache(Integer uid, Integer productId, Integer storageId) {
if (uid == null) {
return;
}
try {
Method queryUserDoposit = DepositController.class.getMethod("queryUserDoposit", new Class[]{Integer.class, Integer.class, Integer.class});
cacheAop.clearCache(queryUserDoposit, new Object[]{uid, 0, 0});
Method queryUserDopositBackDetail = DepositController.class.getMethod("queryUserDopositBackDetail", new Class[]{Integer.class, Integer.class, Integer.class});
cacheAop.clearCache(queryUserDopositBackDetail, new Object[]{uid, 0, 0});
if (productId != null) {
Method queryUserDopositing = DepositController.class.getMethod("queryUserDopositing", new Class[]{Integer.class, Integer.class, Integer.class, Integer.class});
cacheAop.clearCache(queryUserDopositBackDetail, new Object[]{uid, productId, 0, 0});
}
if (storageId != null) {
Method queryUserStorageOffCount = DepositController.class.getMethod("queryUserStorageOffCount", new Class[]{Integer.class, Integer.class});
cacheAop.clearCache(queryUserStorageOffCount, new Object[]{uid, storageId});
}
Method queryUserStorageCount = DepositController.class.getMethod("queryUserStorageCount", new Class[]{Integer.class});
cacheAop.clearCache(queryUserStorageCount, new Object[]{uid});
} catch (Exception e) {
LOGGER.error("删除用户寄存缓存失败!", e);
}
}
/**
* Do 转 Vo
* @param storageDeposit
... ...