|
@@ -3,6 +3,7 @@ package com.caimei.modules.brand.web;
|
|
|
import com.caimei.modules.brand.entity.BrandAndProductType;
|
|
|
import com.caimei.modules.brand.entity.CmBrand;
|
|
|
import com.caimei.modules.brand.service.CmBrandService;
|
|
|
+import com.caimei.modules.opensearch.CoreServiceUitls;
|
|
|
import com.caimei.modules.product.dao.ProductDao;
|
|
|
import com.caimei.modules.product.entity.Product;
|
|
|
import com.caimei.modules.sys.utils.SMSUtils;
|
|
@@ -59,7 +60,8 @@ public class CmBrandController extends BaseController {
|
|
|
private CmBrandService cmBrandService;
|
|
|
@Autowired
|
|
|
private ProductDao productDao;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private CoreServiceUitls coreServiceUitls;
|
|
|
@ModelAttribute
|
|
|
public CmBrand get(@RequestParam(required = false) String id) {
|
|
|
CmBrand entity = null;
|
|
@@ -150,17 +152,32 @@ public class CmBrandController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-
|
|
|
cmBrand.setUpdateDate(new Date());
|
|
|
cmBrandService.save(cmBrand);
|
|
|
+ // 更新商品索引
|
|
|
+ updateProductIndexByBrand(cmBrand.getId());
|
|
|
+
|
|
|
addMessage(redirectAttributes, "保存品牌成功");
|
|
|
}
|
|
|
return "redirect:" + Global.getAdminPath() + "/brand/cmBrand/";
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据品牌Id更新商品索引
|
|
|
+ * @param brandId
|
|
|
+ */
|
|
|
+ private void updateProductIndexByBrand(String brandId) {
|
|
|
+ // 更新商品索引
|
|
|
+ List<Integer> productIds = productDao.getProductIdByBrandId(brandId);
|
|
|
+ for (Integer productId : productIds) {
|
|
|
+ if (null != productId) {
|
|
|
+ coreServiceUitls.updateProductIndex(productId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@RequiresPermissions("brand:cmBrand:delete")
|
|
|
@RequestMapping(value = "delete")
|
|
|
public String delete(CmBrand cmBrand, RedirectAttributes redirectAttributes) {
|
|
@@ -171,6 +188,8 @@ public class CmBrandController extends BaseController {
|
|
|
cmBrandService.delete(cmBrand);
|
|
|
//清理对应品牌商品信息(标记品牌为null)
|
|
|
productDao.updateProductByBrandId(Integer.parseInt(cmBrand.getId()));
|
|
|
+ // 更新商品索引
|
|
|
+ updateProductIndexByBrand(cmBrand.getId());
|
|
|
addMessage(redirectAttributes, "删除品牌成功");
|
|
|
return "redirect:" + Global.getAdminPath() + "/brand/cmBrand/?repage";
|
|
|
}
|
|
@@ -502,4 +521,4 @@ public class CmBrandController extends BaseController {
|
|
|
this.errorMsg = errorMsg;
|
|
|
}
|
|
|
|
|
|
-}
|
|
|
+}
|