|
@@ -10,6 +10,7 @@ import com.caimei.modules.baike.entity.CmBaikeProductQuestion;
|
|
|
import com.caimei.modules.baike.entity.CmBaikeType;
|
|
|
import com.caimei.modules.baike.service.CmBaikeTypeService;
|
|
|
import com.caimei.modules.info.entity.Info;
|
|
|
+import com.caimei.modules.opensearch.GenerateUtils;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
@@ -48,6 +49,9 @@ public class CmBaikeProductController extends BaseController {
|
|
|
|
|
|
@Resource
|
|
|
private CmBaikeProductDao cmBaikeProductDao;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private GenerateUtils generateUtils;
|
|
|
|
|
|
@ModelAttribute
|
|
|
public CmBaikeProduct get(@RequestParam(required=false) String id) {
|
|
@@ -69,7 +73,7 @@ public class CmBaikeProductController extends BaseController {
|
|
|
List<CmBaikeType> typeList = cmBaikeTypeService.findList(cmBaikeType);
|
|
|
String commodityType = cmBaikeProduct.getCommodityType() == 1 ? "产品" : "仪器";
|
|
|
// 置顶数量
|
|
|
- Integer topLength = cmBaikeProductDao.findTopLength(cmBaikeProduct.getCommodityType());
|
|
|
+ Integer topLength = cmBaikeProductDao.findTopLength();
|
|
|
model.addAttribute("page", page);
|
|
|
model.addAttribute("typeList", typeList);
|
|
|
model.addAttribute("commodityType", commodityType);
|
|
@@ -110,6 +114,7 @@ public class CmBaikeProductController extends BaseController {
|
|
|
}
|
|
|
cmBaikeProductService.save(cmBaikeProduct);
|
|
|
addMessage(redirectAttributes, "保存产品成功");
|
|
|
+ cleanRedisCache();
|
|
|
return "redirect:" + Global.getAdminPath() + "/baike/cmBaikeProduct/?repage&commodityType=" + cmBaikeProduct.getCommodityType();
|
|
|
}
|
|
|
|
|
@@ -117,6 +122,7 @@ public class CmBaikeProductController extends BaseController {
|
|
|
public String delete(CmBaikeProduct cmBaikeProduct, RedirectAttributes redirectAttributes) {
|
|
|
cmBaikeProductService.delete(cmBaikeProduct);
|
|
|
addMessage(redirectAttributes, "删除产品成功");
|
|
|
+ cleanRedisCache();
|
|
|
return "redirect:" + Global.getAdminPath() + "/baike/cmBaikeProduct/?repage&commodityType=" + cmBaikeProduct.getCommodityType();
|
|
|
}
|
|
|
|
|
@@ -127,6 +133,7 @@ public class CmBaikeProductController extends BaseController {
|
|
|
cmBaikeProductDao.updateStatus(status, productId);
|
|
|
result.put("success", true);
|
|
|
result.put("msg", (status == 1 ? "启用" : "停用") + "成功");
|
|
|
+ cleanRedisCache();
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -172,4 +179,13 @@ public class CmBaikeProductController extends BaseController {
|
|
|
}
|
|
|
return map;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 有数据变动时需要清除缓存
|
|
|
+ */
|
|
|
+ public void cleanRedisCache() {
|
|
|
+ // 重新生成采美百科产品仪器页
|
|
|
+ generateUtils.generateBaikePage(1);
|
|
|
+ generateUtils.generateBaikePage(2);
|
|
|
+ }
|
|
|
}
|