|
@@ -1,21 +1,12 @@
|
|
package com.caimei.modules.newhome.web;
|
|
package com.caimei.modules.newhome.web;
|
|
|
|
|
|
-import com.caimei.modules.miniprogram.entity.CmWxArticle;
|
|
|
|
import com.caimei.modules.miniprogram.utils.DateUtils;
|
|
import com.caimei.modules.miniprogram.utils.DateUtils;
|
|
import com.caimei.modules.newhome.entity.ActType;
|
|
import com.caimei.modules.newhome.entity.ActType;
|
|
-import com.caimei.modules.newhome.entity.NewPageFloor;
|
|
|
|
-import com.caimei.modules.newhome.service.NewPageFloorService;
|
|
|
|
|
|
+import com.caimei.modules.opensearch.GenerateUtils;
|
|
import com.caimei.modules.product.entity.*;
|
|
import com.caimei.modules.product.entity.*;
|
|
-import com.caimei.modules.product.service.BigTypeService;
|
|
|
|
import com.caimei.modules.product.service.ProductService;
|
|
import com.caimei.modules.product.service.ProductService;
|
|
-import com.caimei.modules.product.service.SmallTypeService;
|
|
|
|
-import com.caimei.po.TinyType;
|
|
|
|
|
|
+import com.caimei.redis.RedisService;
|
|
import com.caimei.utils.AppUtils;
|
|
import com.caimei.utils.AppUtils;
|
|
-import com.cmme.modules.product.entity.CmmeBigtype;
|
|
|
|
-import com.cmme.modules.product.entity.CmmeSmalltype;
|
|
|
|
-import com.cmme.modules.product.service.CmmeBigtypeService;
|
|
|
|
-import com.cmme.modules.product.service.CmmeSmalltypeService;
|
|
|
|
-import com.google.common.collect.Maps;
|
|
|
|
import com.thinkgem.jeesite.common.config.Global;
|
|
import com.thinkgem.jeesite.common.config.Global;
|
|
import com.thinkgem.jeesite.common.persistence.Page;
|
|
import com.thinkgem.jeesite.common.persistence.Page;
|
|
import com.thinkgem.jeesite.common.utils.StringUtils;
|
|
import com.thinkgem.jeesite.common.utils.StringUtils;
|
|
@@ -28,9 +19,9 @@ import org.springframework.ui.Model;
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
-import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -43,10 +34,12 @@ import java.util.*;
|
|
@Controller
|
|
@Controller
|
|
@RequestMapping(value = "${adminPath}/newhome/newActivity")
|
|
@RequestMapping(value = "${adminPath}/newhome/newActivity")
|
|
public class NewActivityController extends BaseController {
|
|
public class NewActivityController extends BaseController {
|
|
-
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private RedisService redisService;
|
|
@Autowired
|
|
@Autowired
|
|
private ProductService productService;
|
|
private ProductService productService;
|
|
-
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private GenerateUtils generateUtils;
|
|
@ModelAttribute
|
|
@ModelAttribute
|
|
public Product get(@RequestParam(required=false) String id) {
|
|
public Product get(@RequestParam(required=false) String id) {
|
|
Product entity = null;
|
|
Product entity = null;
|
|
@@ -58,7 +51,7 @@ public class NewActivityController extends BaseController {
|
|
}
|
|
}
|
|
return entity;
|
|
return entity;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@RequiresPermissions("newhome:newActivity:view")
|
|
@RequiresPermissions("newhome:newActivity:view")
|
|
@RequestMapping(value = {"list","", "groupList"})
|
|
@RequestMapping(value = {"list","", "groupList"})
|
|
public String list(Product product,String message, HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
public String list(Product product,String message, HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
@@ -157,6 +150,7 @@ public class NewActivityController extends BaseController {
|
|
returnUrl = "/newhome/newActivity?repage";
|
|
returnUrl = "/newhome/newActivity?repage";
|
|
}
|
|
}
|
|
productService.save(product);
|
|
productService.save(product);
|
|
|
|
+ cleanRedisCache();
|
|
addMessage(redirectAttributes, "保存商品信息成功");
|
|
addMessage(redirectAttributes, "保存商品信息成功");
|
|
return "redirect:"+ Global.getAdminPath()+returnUrl;
|
|
return "redirect:"+ Global.getAdminPath()+returnUrl;
|
|
}
|
|
}
|
|
@@ -212,6 +206,7 @@ public class NewActivityController extends BaseController {
|
|
product.setActSort("1");
|
|
product.setActSort("1");
|
|
}
|
|
}
|
|
productService.updateActive(product);
|
|
productService.updateActive(product);
|
|
|
|
+ cleanRedisCache();
|
|
addMessage(redirectAttributes, "保存推荐商品成功");
|
|
addMessage(redirectAttributes, "保存推荐商品成功");
|
|
return "redirect:" + Global.getAdminPath() + "/newhome/newActivity/?repage";
|
|
return "redirect:" + Global.getAdminPath() + "/newhome/newActivity/?repage";
|
|
}
|
|
}
|
|
@@ -220,6 +215,7 @@ public class NewActivityController extends BaseController {
|
|
@RequestMapping(value = "updateActivity")
|
|
@RequestMapping(value = "updateActivity")
|
|
public String updateActivity(Product product,RedirectAttributes redirectAttributes) {
|
|
public String updateActivity(Product product,RedirectAttributes redirectAttributes) {
|
|
productService.updateActive(product);
|
|
productService.updateActive(product);
|
|
|
|
+ cleanRedisCache();
|
|
addMessage(redirectAttributes, "保存推荐商品成功");
|
|
addMessage(redirectAttributes, "保存推荐商品成功");
|
|
return "redirect:" + Global.getAdminPath() + "/newhome/newActivity/?repage";
|
|
return "redirect:" + Global.getAdminPath() + "/newhome/newActivity/?repage";
|
|
}
|
|
}
|
|
@@ -235,6 +231,7 @@ public class NewActivityController extends BaseController {
|
|
returnUrl = "/newhome/newActivity/groupList?repage";
|
|
returnUrl = "/newhome/newActivity/groupList?repage";
|
|
}
|
|
}
|
|
productService.deleteActive(product);
|
|
productService.deleteActive(product);
|
|
|
|
+ cleanRedisCache();
|
|
addMessage(redirectAttributes, "删除推荐成功");
|
|
addMessage(redirectAttributes, "删除推荐成功");
|
|
return "redirect:"+Global.getAdminPath()+returnUrl;
|
|
return "redirect:"+Global.getAdminPath()+returnUrl;
|
|
}
|
|
}
|
|
@@ -265,4 +262,18 @@ public class NewActivityController extends BaseController {
|
|
model.addAttribute("product", product);
|
|
model.addAttribute("product", product);
|
|
return "modules/newhome/updateActivityForm";
|
|
return "modules/newhome/updateActivityForm";
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 有数据变动时需要清除缓存
|
|
|
|
+ */
|
|
|
|
+ public void cleanRedisCache() {
|
|
|
|
+ //首页缓存
|
|
|
|
+ String homeData = "getHomeData*";
|
|
|
|
+ redisService.removePattern(homeData);
|
|
|
|
+ // 重新生成静态首页
|
|
|
|
+ generateUtils.generateHome();
|
|
|
|
+ redisService.removePattern("getHomeCommodityData*");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|