Quellcode durchsuchen

促销活动清缓存

chao vor 4 Jahren
Ursprung
Commit
e28871336f

+ 15 - 4
src/main/java/com/caimei/modules/product/web/CmPromotionController.java

@@ -1,13 +1,12 @@
 package com.caimei.modules.product.web;
 
-import com.caimei.modules.brand.service.ShopModelService;
 import com.caimei.modules.bulkpurchase.entity.PurchaseProduct;
 import com.caimei.modules.cibe.entity.Shop;
-import com.caimei.modules.product.entity.CmActivity;
 import com.caimei.modules.product.entity.CmPromotion;
 import com.caimei.modules.product.entity.Product;
 import com.caimei.modules.product.service.CmPromotionService;
 import com.caimei.modules.product.service.ProductService;
+import com.caimei.redis.RedisService;
 import com.caimei.utils.AppUtils;
 import com.foxinmy.weixin4j.util.StringUtil;
 import com.thinkgem.jeesite.common.config.Global;
@@ -40,8 +39,8 @@ public class CmPromotionController extends BaseController {
     private CmPromotionService cmPromotionService;
     @Autowired
     private ProductService productService;
-
-
+    @Autowired
+    private RedisService redisService;
 
     @ModelAttribute
     public CmPromotion get(@RequestParam(required = false) String id) {
@@ -353,6 +352,7 @@ public class CmPromotionController extends BaseController {
             map.put("success", false);
             map.put("msg", "促销活动id不能为空");
         }
+        cleanRedisCache();
         return map;
     }
 
@@ -422,6 +422,7 @@ public class CmPromotionController extends BaseController {
         }
         cmPromotionService.save(cmPromotion);
         addMessage(redirectAttributes, "保存促销列表成功");
+        cleanRedisCache();
         return "redirect:" + Global.getAdminPath() + "/product/cmPromotions/?type="+cmPromotion.getType();
     }
 
@@ -434,4 +435,14 @@ public class CmPromotionController extends BaseController {
     public List<PurchaseProduct> getGifts(String id) {
         return cmPromotionService.findGiftPurchaseProduct(id);
     }
+
+
+    /**
+     * 有数据变动时需要清除缓存
+     */
+    public void cleanRedisCache() {
+        redisService.removePattern("getHomeData*");
+        redisService.removePattern("getHomeCommodityData*");
+        redisService.removePattern("insCommodityData*");
+    }
 }