|
@@ -5,13 +5,19 @@ import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import com.caimei.modules.baike.dao.CmBaikeProductDao;
|
|
import com.caimei.modules.baike.dao.CmBaikeProductDao;
|
|
|
|
+import com.caimei.modules.baike.dao.CmBaikeProductRecommendDao;
|
|
|
|
+import com.caimei.modules.baike.dao.CmBaikeTypeDao;
|
|
import com.caimei.modules.baike.entity.*;
|
|
import com.caimei.modules.baike.entity.*;
|
|
import com.caimei.modules.baike.service.CmBaikeTypeService;
|
|
import com.caimei.modules.baike.service.CmBaikeTypeService;
|
|
import com.caimei.modules.info.dao.InfoDao;
|
|
import com.caimei.modules.info.dao.InfoDao;
|
|
import com.caimei.modules.opensearch.GenerateUtils;
|
|
import com.caimei.modules.opensearch.GenerateUtils;
|
|
import com.caimei.modules.oss.utils.OSSUtils;
|
|
import com.caimei.modules.oss.utils.OSSUtils;
|
|
|
|
+import com.caimei.modules.product.entity.CmProductRecommend;
|
|
|
|
+import com.caimei.modules.product.entity.Product;
|
|
import com.caimei.modules.user.entity.NewCmShop;
|
|
import com.caimei.modules.user.entity.NewCmShop;
|
|
|
|
+import com.caimei.utils.AppUtils;
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Maps;
|
|
|
|
+import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.ui.Model;
|
|
@@ -52,10 +58,13 @@ public class CmBaikeProductController extends BaseController {
|
|
private CmBaikeProductDao cmBaikeProductDao;
|
|
private CmBaikeProductDao cmBaikeProductDao;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
- private InfoDao infoDao;
|
|
|
|
|
|
+ private CmBaikeProductRecommendDao cmBaikeProductRecommendDao;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private CmBaikeTypeDao cmBaikeTypeDao;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
- private GenerateUtils generateUtils;
|
|
|
|
|
|
+ private InfoDao infoDao;
|
|
|
|
|
|
@ModelAttribute
|
|
@ModelAttribute
|
|
public CmBaikeProduct get(@RequestParam(required=false) String id) {
|
|
public CmBaikeProduct get(@RequestParam(required=false) String id) {
|
|
@@ -111,10 +120,13 @@ public class CmBaikeProductController extends BaseController {
|
|
cmBaikeProduct.setQuestionList(questionList);
|
|
cmBaikeProduct.setQuestionList(questionList);
|
|
// 视频列表
|
|
// 视频列表
|
|
List<CmBaikeProductFile> videoList = cmBaikeProductDao.findFileList(cmBaikeProduct.getId());
|
|
List<CmBaikeProductFile> videoList = cmBaikeProductDao.findFileList(cmBaikeProduct.getId());
|
|
|
|
+ StringBuilder fileIds = new StringBuilder();
|
|
videoList.forEach(video->{
|
|
videoList.forEach(video->{
|
|
OSSUtils.getOssUrl(video.getOssName());
|
|
OSSUtils.getOssUrl(video.getOssName());
|
|
|
|
+ fileIds.append(video.getId()).append(",");
|
|
});
|
|
});
|
|
cmBaikeProduct.setVideoList(videoList);
|
|
cmBaikeProduct.setVideoList(videoList);
|
|
|
|
+ cmBaikeProduct.setFileIds(fileIds.toString());
|
|
// 供应商列表
|
|
// 供应商列表
|
|
List<NewCmShop> shopList = cmBaikeProductDao.findShopList();
|
|
List<NewCmShop> shopList = cmBaikeProductDao.findShopList();
|
|
cmBaikeProduct.setShopList(shopList);
|
|
cmBaikeProduct.setShopList(shopList);
|
|
@@ -234,6 +246,12 @@ public class CmBaikeProductController extends BaseController {
|
|
// 问题列表
|
|
// 问题列表
|
|
List<CmBaikeProductQuestion> questionList = cmBaikeProductDao.findQuestionList(cmBaikeProduct.getId());
|
|
List<CmBaikeProductQuestion> questionList = cmBaikeProductDao.findQuestionList(cmBaikeProduct.getId());
|
|
cmBaikeProduct.setQuestionList(questionList);
|
|
cmBaikeProduct.setQuestionList(questionList);
|
|
|
|
+ // 视频列表
|
|
|
|
+ List<CmBaikeProductFile> videoList = cmBaikeProductDao.findFileList(cmBaikeProduct.getId());
|
|
|
|
+ videoList.forEach(video->{
|
|
|
|
+ OSSUtils.getOssUrl(video.getOssName());
|
|
|
|
+ });
|
|
|
|
+ cmBaikeProduct.setVideoList(videoList);
|
|
model.addAttribute("commodityType", commodityType);
|
|
model.addAttribute("commodityType", commodityType);
|
|
return "modules/baikePage/checkBaikePage";
|
|
return "modules/baikePage/checkBaikePage";
|
|
}
|
|
}
|
|
@@ -273,6 +291,15 @@ public class CmBaikeProductController extends BaseController {
|
|
// 问题列表
|
|
// 问题列表
|
|
List<CmBaikeProductQuestion> questionList = cmBaikeProductDao.findQuestionList(cmBaikeProduct.getId());
|
|
List<CmBaikeProductQuestion> questionList = cmBaikeProductDao.findQuestionList(cmBaikeProduct.getId());
|
|
cmBaikeProduct.setQuestionList(questionList);
|
|
cmBaikeProduct.setQuestionList(questionList);
|
|
|
|
+ // 视频列表
|
|
|
|
+ List<CmBaikeProductFile> videoList = cmBaikeProductDao.findFileList(cmBaikeProduct.getId());
|
|
|
|
+ StringBuilder fileIds = new StringBuilder();
|
|
|
|
+ videoList.forEach(video->{
|
|
|
|
+ OSSUtils.getOssUrl(video.getOssName());
|
|
|
|
+ fileIds.append(video.getId()).append(",");
|
|
|
|
+ });
|
|
|
|
+ cmBaikeProduct.setVideoList(videoList);
|
|
|
|
+ cmBaikeProduct.setFileIds(fileIds.toString());
|
|
model.addAttribute("commodityType", commodityType);
|
|
model.addAttribute("commodityType", commodityType);
|
|
CmBaikeType cmBaikeType = new CmBaikeType();
|
|
CmBaikeType cmBaikeType = new CmBaikeType();
|
|
cmBaikeType.setTypeSort(cmBaikeProduct.getCommodityType());
|
|
cmBaikeType.setTypeSort(cmBaikeProduct.getCommodityType());
|
|
@@ -313,4 +340,60 @@ public class CmBaikeProductController extends BaseController {
|
|
public void deleteFile(Integer fileId) {
|
|
public void deleteFile(Integer fileId) {
|
|
cmBaikeProductService.deleteFile(fileId);
|
|
cmBaikeProductService.deleteFile(fileId);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 相关商品推荐
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping(value = "recommend/form")
|
|
|
|
+ public String recommendForm(CmBaikeProduct cmBaikeProduct, Model model) {
|
|
|
|
+ List<CmBaikeProductRecommend> manualRecommendList = new ArrayList<>();
|
|
|
|
+ List<CmBaikeProductRecommend> autoRecommendList;
|
|
|
|
+ CmBaikeProductRecommend recommend = new CmBaikeProductRecommend();
|
|
|
|
+ recommend.setProductId(Integer.parseInt(cmBaikeProduct.getId()));
|
|
|
|
+ recommend.setRecommendType(cmBaikeProduct.getRecommendType());
|
|
|
|
+ recommend.setProductTypeId(cmBaikeProduct.getTypeId());
|
|
|
|
+ // 查询推荐列表
|
|
|
|
+ if (1 == cmBaikeProduct.getRecommendType()) {
|
|
|
|
+ manualRecommendList = cmBaikeProductRecommendDao.findList(recommend);
|
|
|
|
+ }
|
|
|
|
+ autoRecommendList = cmBaikeProductRecommendDao.findAutoRecommendList(recommend);
|
|
|
|
+ // 商品类型
|
|
|
|
+ String commodityType = cmBaikeProduct.getCommodityType() == 1 ? "产品" : "仪器";
|
|
|
|
+ model.addAttribute("commodityType", commodityType);
|
|
|
|
+ model.addAttribute("manualRecommendList", manualRecommendList);
|
|
|
|
+ model.addAttribute("autoRecommendList", autoRecommendList);
|
|
|
|
+ return "modules/baikePage/recommendForm";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 保存相关推荐
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping(value = "recommend/save")
|
|
|
|
+ public String recommendSave(CmBaikeProduct cmBaikeProduct, Model model) {
|
|
|
|
+ cmBaikeProductService.saveRecommend(cmBaikeProduct);
|
|
|
|
+ return "redirect:" + Global.getAdminPath() + "/baike/cmBaikeProduct/?repage&commodityType=" + cmBaikeProduct.getCommodityType() + "&publishSource=1";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 添加推荐产品
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping("/recommend/products")
|
|
|
|
+ public String findProductPage(CmBaikeProduct cmBaikeProduct, Model model, HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
+ Page<CmBaikeProduct> page = cmBaikeProductService.findPage(new Page<CmBaikeProduct>(request, response), cmBaikeProduct);
|
|
|
|
+ model.addAttribute("page", page);
|
|
|
|
+ // 商品类型
|
|
|
|
+ String commodityType = cmBaikeProduct.getCommodityType() == 1 ? "产品" : "仪器";
|
|
|
|
+ model.addAttribute("commodityType", commodityType);
|
|
|
|
+ // 分类列表
|
|
|
|
+ CmBaikeType cmBaikeType = new CmBaikeType();
|
|
|
|
+ cmBaikeType.setTypeSort(cmBaikeProduct.getCommodityType());
|
|
|
|
+ List<CmBaikeType> typeList = cmBaikeTypeDao.findList(cmBaikeType);
|
|
|
|
+ model.addAttribute("typeList", typeList);
|
|
|
|
+ return "modules/baikePage/addProductRecommend";
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|