123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- package com.overseas.website.controller;
- import com.alibaba.fastjson.JSONObject;
- import com.overseas.website.utils.RequestUtil;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.Model;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.PathVariable;
- import java.util.HashMap;
- import java.util.Map;
- /**
- * Description
- *
- * @author : Charles
- * @date : 2021/10/18
- */
- @Controller
- public class PageController {
- /**
- * 页面路径
- */
- @GetMapping("/{path}.html")
- public String page(final Model model, @PathVariable("path") String path) {
- model.addAttribute("path", path);
- return path;
- }
- /**
- * 商品详情页面
- */
- @GetMapping("/product/{id}.html")
- public String product(final Model model, @PathVariable("id") String productId) {
- model.addAttribute("path", "product");
- Map<String, Object> product = new HashMap<>();
- try {
- String floorResult = RequestUtil.sendGet("https://core.caimei365.com/commodity/product/details?productId="+productId);
- Map<String, Object> floorMap = JSONObject.parseObject(floorResult, Map.class);
- product = JSONObject.parseObject(String.valueOf(floorMap.get("data")), Map.class);
- } catch (Exception e) {
- return null;
- }
- model.addAttribute("product", product);
- return "product";
- }
- }
|