Pārlūkot izejas kodu

详情路径bugfix

zhijiezhao 2 gadi atpakaļ
vecāks
revīzija
2e0e80849c

+ 27 - 15
src/main/java/com/caimei/www/controller/unlimited/ProductController.java

@@ -36,7 +36,9 @@ public class ProductController extends BaseController {
     private static final String TEMPORARY_PAGE_PATH = "product/temporary";
     private static final String INSTRUMENT_LIST_PATH = "product/instruelist";
     // private static final String QUALITY_AUTHORRIZE_PATH = "product/qualityauthorize";
-    /** 新正品联盟页面 */
+    /**
+     * 新正品联盟页面
+     */
     private static final String QUALITY_AUTHORRIZE_PATH = "product/alliance-page";
     private static final String ACTIVITY_TOP_PATH = "activity/activityTopic";
     private static final String CLOUD_BEAUTY_PATH = "activity/beautyTopic";
@@ -101,21 +103,30 @@ public class ProductController extends BaseController {
     /**
      * 商品详情页
      */
-    @GetMapping("/product-{id}-{typeId}.html")
-    public String detail(final Model model, @PathVariable("id") Integer productId, @PathVariable("typeId") Integer typeId) {
+    @GetMapping("/product-{id}.html")
+    public String detail(final Model model, @PathVariable("id") String product) {
+        Integer productId = null;
+        Integer typeId = 0;
+        if (product.contains("-")) {
+            String[] split = product.split("-");
+            productId = Integer.valueOf(split[0]);
+            typeId = Integer.valueOf(split[1]);
+        } else {
+            productId = Integer.valueOf(product);
+        }
         ProductDetail detail = productService.getProductDetailById(productId);
         if (detail == null || detail.getValidFlag() == 0 || detail.getValidFlag() == 9) {
             return super.errorPath();
         }
-        List<String> images=productService.getImages(productId);
-        List<Parameter> params=productService.getParams(productId);
-        List<ProductList> productLists=productService.getProductLists(productId);
-        model.addAttribute("lists",productLists);
-        model.addAttribute("params",params);
-        model.addAttribute("images",images);
+        List<String> images = productService.getImages(productId);
+        List<Parameter> params = productService.getParams(productId);
+        List<ProductList> productLists = productService.getProductLists(productId);
+        model.addAttribute("lists", productLists);
+        model.addAttribute("params", params);
+        model.addAttribute("images", images);
         model.addAttribute("productId", productId);
         model.addAttribute("product", detail);
-        model.addAttribute("typeId",typeId);
+        model.addAttribute("typeId", typeId);
         return PRODUCT_DETAIL_PATH;
     }
 
@@ -219,13 +230,13 @@ public class ProductController extends BaseController {
             productParams.append("?id=").append(bigTypeId).append("&idType=1");
         }
         productParams.append("&pageNum=").append(pageNum).append("&pageSize=").append(pageSize).append("&sortField=").append(sortField).append("&sortType=").append(sortType);
-        if(newg!=null){
+        if (newg != null) {
             productParams.append("&newFlag=").append(newg);
         }
-        if(pro!=null){
+        if (pro != null) {
             productParams.append("&promotionFlag=").append(pro);
         }
-        if(!StringUtils.isEmpty(bpn)){
+        if (!StringUtils.isEmpty(bpn)) {
             productParams.append("&brandIds=").append(bpn);
         }
         JSONObject productObj = productService.getProductListJson(productParams.toString());
@@ -370,7 +381,9 @@ public class ProductController extends BaseController {
      * 认证通页面
      */
     @GetMapping("/attestation.html")
-    public String getAttestationPath() { return ACTIVITY_ATTESTAION; }
+    public String getAttestationPath() {
+        return ACTIVITY_ATTESTAION;
+    }
 
     /**
      * H5配套商品页
@@ -389,5 +402,4 @@ public class ProductController extends BaseController {
     }
 
 
-
 }