Exemple #1
0
  /**
   * 店铺内商品列表
   *
   * @param shopId:店铺ID
   * @param globalCatId:全站分类Id
   * @param catId:店铺分类Id
   * @param page:页码
   * @param size:每页显示商品数量
   * @param order:排序方式,1:促销,2:新品,3:销量,4:价格
   * @param x:经度
   * @param y:纬度
   * @return
   */
  @RequestMapping(value = "/productlist", method = RequestMethod.GET)
  @ResponseBody
  public Result productList(
      Long shopId, Long globalCatId, Long catId, Integer page, Integer size, Integer order) {

    log.warn(
        "shopId = "
            + shopId
            + " , catId = "
            + catId
            + " , globalCatId = "
            + globalCatId
            + " , order = "
            + order);

    if (shopId == null) {
      throw new BusinessException(" parameter 'shopId' can not be null !");
    }

    if (page == null) page = 1;
    if (size == null) size = 10;
    if (order == null) order = 1;

    Shop shop = shopService.find(shopId);

    if (shop == null) {
      throw new BusinessException(" Invalid parameter 'shopId' ! ");
    }

    ShopCategory shopCategory = null;

    if (catId != null) {
      shopCategory = shopCategoryService.find(catId);
    }

    ProductCategory productCategory = null;

    if (globalCatId != null) {
      productCategory = productCategoryService.find(globalCatId);
    }

    ItemPage<Product> itemPage =
        productService.findShopProductList(shop, productCategory, shopCategory, page, size, order);

    return new Result(Code.SUCCESS, 1, "", getProductItems(itemPage.getList()));
  }
Exemple #2
0
  /**
   * 店铺列表 首页和一级分类下的商铺推荐,点击更多,显示该分类下推荐的店铺列表
   *
   * @return
   */
  @RequestMapping(value = "/list", method = RequestMethod.GET)
  @ResponseBody
  public Result list(Long catId, String city) {

    if (catId == null) {
      throw new BusinessException(" Parameter 'catId' can not be null ! ");
    }

    if (city == null || city.trim().equals("")) {
      throw new BusinessException(" Parameter 'city' can not be empty ! ");
    }

    ProductCategory category = productCategoryService.find(catId);

    if (category == null) {
      throw new BusinessException(" Invalid Parameter 'catId' ! ");
    }

    List<Shop> shopList = shopService.findRecommendList(city, category);

    return new Result(Code.SUCCESS, 1, "", getShopItems(shopList, null, null));
  }
 /** 首页 */
 @RequestMapping(method = RequestMethod.GET)
 public String index(ModelMap model) {
   model.addAttribute("rootProductCategories", productCategoryService.findRoots());
   return "/shop/product_category/index";
 }