|
@@ -1,9 +1,15 @@
|
|
package com.caimei.www.controller;
|
|
package com.caimei.www.controller;
|
|
|
|
|
|
|
|
+import com.caimei.module.base.entity.bo.JsonModel;
|
|
|
|
+import com.caimei.www.pojo.product.ProductDetail;
|
|
|
|
+import com.caimei.www.pojo.product.ProductParameter;
|
|
|
|
+import com.caimei.www.service.ProductService;
|
|
|
|
+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;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
/**
|
|
/**
|
|
*cription
|
|
*cription
|
|
@@ -17,23 +23,74 @@ public class ProductController extends BaseController {
|
|
private static final String PRODUCT_LIST_PATH = "product/list";
|
|
private static final String PRODUCT_LIST_PATH = "product/list";
|
|
private static final String PRODUCT_DETAIL_PATH = "product/detail";
|
|
private static final String PRODUCT_DETAIL_PATH = "product/detail";
|
|
|
|
|
|
|
|
+ private ProductService productService;
|
|
|
|
+ @Autowired
|
|
|
|
+ public void setProductService(ProductService productService) {
|
|
|
|
+ this.productService = productService;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 商品分类列表页
|
|
|
|
+ */
|
|
@GetMapping("/product/list.html")
|
|
@GetMapping("/product/list.html")
|
|
public String hello(final Model model) {
|
|
public String hello(final Model model) {
|
|
model.addAttribute("searchFlag", "0");
|
|
model.addAttribute("searchFlag", "0");
|
|
return PRODUCT_LIST_PATH;
|
|
return PRODUCT_LIST_PATH;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 商品搜索结果页
|
|
|
|
+ */
|
|
@GetMapping("/product/search.html")
|
|
@GetMapping("/product/search.html")
|
|
public String hello2(final Model model) {
|
|
public String hello2(final Model model) {
|
|
model.addAttribute("searchFlag", "1");
|
|
model.addAttribute("searchFlag", "1");
|
|
return PRODUCT_LIST_PATH;
|
|
return PRODUCT_LIST_PATH;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 商品详情页
|
|
|
|
+ */
|
|
@GetMapping("/product/detail.html")
|
|
@GetMapping("/product/detail.html")
|
|
public String listPage(final Model model, @RequestParam("pid") Integer productId) {
|
|
public String listPage(final Model model, @RequestParam("pid") Integer productId) {
|
|
- model.addAttribute("msg", productId);
|
|
|
|
|
|
+ ProductDetail detail = productService.getProductDetailById(productId);
|
|
|
|
+ model.addAttribute("product", detail);
|
|
return PRODUCT_DETAIL_PATH;
|
|
return PRODUCT_DETAIL_PATH;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 详情-图片
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/product/images")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public JsonModel getProductDetailImages(Integer productId) {
|
|
|
|
+ return productService.getProductDetailImages(productId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 详情-相关推荐
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/product/recommend")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public JsonModel getProductDetailRecommends(Integer productId, Integer recommendType) {
|
|
|
|
+ return productService.getProductDetailRecommends(productId, recommendType);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 详情-相关参数
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/product/parameter")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public JsonModel getProductParameters(Integer productId) {
|
|
|
|
+ return productService.getProductParameters(productId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|