|
@@ -12,6 +12,7 @@ import com.caimei.modules.user.entity.CmUserOrganize;
|
|
|
import com.caimei.modules.user.service.CmUserOrganizeService;
|
|
|
import com.caimei.po.ProductImage;
|
|
|
import com.caimei.po.ProductLadderPrice;
|
|
|
+import com.caimei.redis.RedisService;
|
|
|
import com.caimei.utils.AppUtils;
|
|
|
import com.caimei.vo.JsonModel;
|
|
|
import com.google.common.collect.Maps;
|
|
@@ -69,6 +70,8 @@ public class ProductNewController extends BaseController {
|
|
|
private CmBrandService cmBrandService;
|
|
|
@Resource
|
|
|
private CmSecondHandDetailService cmSecondHandDetailService;
|
|
|
+ @Autowired
|
|
|
+ private RedisService redisService;
|
|
|
|
|
|
@ModelAttribute
|
|
|
public Product get(@RequestParam(required = false) String id) {
|
|
@@ -324,7 +327,6 @@ public class ProductNewController extends BaseController {
|
|
|
addMessage(redirectAttributes, "保存商品成功");
|
|
|
// 更新索引
|
|
|
searchUitls.updateProductIndex(product.getProductID());
|
|
|
-
|
|
|
String editFlag = product.getEditFlag();
|
|
|
if (StringUtils.equals("1", editFlag)) {
|
|
|
redirectAttributes.addAttribute("id", product.getId());
|
|
@@ -342,7 +344,8 @@ public class ProductNewController extends BaseController {
|
|
|
redirectAttributes.addAttribute("searchPreferredFlag", product.getSearchPreferredFlag());
|
|
|
redirectAttributes.addAttribute("searchProductCategory", product.getSearchProductCategory());
|
|
|
}
|
|
|
-
|
|
|
+ // 有数据变动时需要清除缓存
|
|
|
+ cleanRedisCache();
|
|
|
return "redirect:" + Global.getAdminPath() + "/product/new/list/";
|
|
|
}
|
|
|
|
|
@@ -475,6 +478,8 @@ public class ProductNewController extends BaseController {
|
|
|
redirectAttributes.addAttribute("searchBrandID", product.getSearchBrandID());
|
|
|
redirectAttributes.addAttribute("searchPreferredFlag", product.getSearchPreferredFlag());
|
|
|
redirectAttributes.addAttribute("searchProductCategory", product.getSearchProductCategory());
|
|
|
+ // 有数据变动时需要清除缓存
|
|
|
+ cleanRedisCache();
|
|
|
return "redirect:" + Global.getAdminPath() + "/product/new/list/";
|
|
|
}
|
|
|
|
|
@@ -595,6 +600,8 @@ public class ProductNewController extends BaseController {
|
|
|
map.put("msg", "操作成功");
|
|
|
// 更新索引
|
|
|
searchUitls.updateProductIndex(productID);
|
|
|
+ // 有数据变动时需要清除缓存
|
|
|
+ cleanRedisCache();
|
|
|
} catch (Exception e) {
|
|
|
logger.debug(e.toString(), e);
|
|
|
map.put("success", false);
|
|
@@ -851,6 +858,14 @@ public class ProductNewController extends BaseController {
|
|
|
return "redirect:" + Global.getAdminPath() + "/product/new/recommend?id=" + productID;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 有数据变动时需要清除缓存
|
|
|
+ */
|
|
|
+ public void cleanRedisCache() {
|
|
|
+ // 首页缓存
|
|
|
+ String homeData = "getHomeData*";
|
|
|
+ redisService.removePattern(homeData);
|
|
|
+ redisService.removePattern("getHomeCommodityData*");
|
|
|
+ }
|
|
|
}
|
|
|
|