Example #1
0
 /**
  * map mới 1 thương hiệu và danh mục
  *
  * @param manuId
  * @param cateId
  * @return
  */
 @RequestMapping(value = "/addmapmanufacturer", method = RequestMethod.GET)
 @ResponseBody
 public Response addMap(
     @RequestParam(value = "manuId", defaultValue = "") String manuId,
     @RequestParam(value = "cateId", defaultValue = "") String cateId) {
   CategoryManufacturer map = new CategoryManufacturer();
   map.setCategoryId(cateId);
   map.setManufacturerId(manuId);
   try {
     return manufacturerService.addMap(map);
   } catch (Exception ex) {
     return new Response(false, ex.getMessage());
   }
 }
Example #2
0
 /**
  * service Xóa Giá Trị Thuộc tính
  *
  * @param catid
  * @param manufacturerId
  * @return
  */
 @ResponseBody
 @RequestMapping(value = "/delmapmanufacturer", method = RequestMethod.GET)
 public Response delMapManuFacturer(
     @RequestParam(value = "catid", defaultValue = "") String catid,
     @RequestParam(value = "manufacturerId", defaultValue = "") String manufacturerId) {
   try {
     CategoryManufacturer CM = new CategoryManufacturer();
     CM.setCategoryId(catid);
     CM.setManufacturerId(manufacturerId);
     manufacturerService.removeMap(CM);
   } catch (Exception e) {
     return new Response(false, e.getMessage());
   }
   return new Response(true, "Đã xóa thành công thương hiệu đã map");
 }
Example #3
0
  /**
   * autocomplate mf
   *
   * @param keyword
   * @param cateId
   * @return
   */
  @RequestMapping(value = "/searchmf", method = RequestMethod.GET)
  @ResponseBody
  public Response searchmf(
      @RequestParam(value = "keyword", defaultValue = "") String keyword,
      @RequestParam(value = "cateId", defaultValue = "") String cateId) {

    ManufacturerSearch search = new ManufacturerSearch();
    search.setName(keyword.trim());
    if (cateId != null && !"".equals(cateId.trim()) && !"0".equals(cateId.trim())) {
      search.setCategoryId(cateId);
    }

    search.setPageIndex(0);
    search.setPageSize(100);
    DataPage<Manufacturer> dataPage = manufacturerService.search(search);
    return new Response(true, "Danh sách thương hiệu", dataPage);
  }
Example #4
0
 /**
  * service Lấy danh sách thương hiệu theo mã danh mục sản phẩm
  *
  * @param id
  * @param manufacturerId
  * @param manufacturerName
  * @param pageIndex
  * @param pageSize
  * @return
  */
 @ResponseBody
 @RequestMapping(value = "/viewmanufacturer", method = RequestMethod.GET)
 public Response viewManuFacturerByIdCategory(
     @RequestParam(value = "id", defaultValue = "") String id,
     @RequestParam(value = "manufacturerId", defaultValue = "") String manufacturerId,
     @RequestParam(value = "manufacturerName", defaultValue = "") String manufacturerName,
     @RequestParam(value = "pageIndex", defaultValue = "0") int pageIndex,
     @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
   ManufacturerSearch manufacturerSearch = new ManufacturerSearch();
   manufacturerSearch.setCategoryId(id);
   manufacturerSearch.setManufacturerId(manufacturerId);
   if (pageIndex == 0) {
     manufacturerSearch.setPageIndex(pageIndex);
   } else {
     manufacturerSearch.setPageIndex(pageIndex - 1);
   }
   manufacturerSearch.setPageSize(pageSize);
   if (!manufacturerName.equals("")) {
     manufacturerSearch.setName(manufacturerName);
   }
   return new Response(true, "Load thành công", manufacturerService.search(manufacturerSearch));
 }
  /**
   * Danh sách sản phẩm cần review
   *
   * @param modelMap
   * @param session
   * @param page
   * @return
   */
  @RequestMapping(
      value = {"/reviewitem"},
      method = RequestMethod.GET)
  public String reviewList(
      ModelMap modelMap,
      HttpSession session,
      @RequestParam(value = "page", defaultValue = "0") int page) {

    ItemSearch itemSearch = new ItemSearch();
    itemSearch.setStatus(4);
    List<String> cateIds = new ArrayList<>();
    List<String> shopCateIds = new ArrayList<>();
    List<String> manufIds = new ArrayList<>();
    List<String> modelIds = new ArrayList<>();
    if (itemSearch.getCategoryIds() == null) {
      itemSearch.setCategoryIds(new ArrayList<String>());
    }
    itemSearch.setSource(ItemSource.SELLER);
    long createTime = 1388509200 * 1000L;
    itemSearch.setCreateTimeFrom(createTime);
    itemSearch.setCreateTimeTo(System.currentTimeMillis());
    if (session.getAttribute("itemSearch") != null && page != 0) {
      itemSearch = (ItemSearch) session.getAttribute("itemSearch");
    } else {
      session.setAttribute("itemSearch", itemSearch);
    }
    Map<String, Object> parentCategorys = new HashMap<>();
    getAncestors(itemSearch, parentCategorys);

    if (page > 0) {
      itemSearch.setPageIndex(page - 1);
    } else {
      itemSearch.setPageIndex(0);
    }
    itemSearch.setPageSize(50);

    DataPage<Item> itemPage = itemService.searchMongo(itemSearch);
    for (Item item : itemPage.getData()) {
      if (item.getCategoryId() != null
          && !item.getCategoryId().equals("")
          && !cateIds.contains(item.getCategoryId())) {
        cateIds.add(item.getCategoryId());
      }
      if (item.getShopCategoryId() != null
          && !item.getShopCategoryId().equals("")
          && !shopCateIds.contains(item.getShopCategoryId())) {
        shopCateIds.add(item.getShopCategoryId());
      }
      if (item.getManufacturerId() != null
          && !item.getManufacturerId().equals("")
          && !manufIds.contains(item.getManufacturerId())) {
        manufIds.add(item.getManufacturerId());
      }
      if (item.getModelId() != null
          && !item.getModelId().equals("")
          && !modelIds.contains(item.getModelId())) {
        modelIds.add(item.getModelId());
      }
    }
    for (Item item : itemPage.getData()) {
      List<String> images = new ArrayList<>();
      if (item != null && item.getImages() != null && !item.getImages().isEmpty()) {
        for (String img : item.getImages()) {
          images.add(
              imageService.getUrl(img).thumbnail(200, 200, "outbound").getUrl(item.getName()));
        }
        item.setImages(images);
      }
      if (item.getSellerName() == null || item.getSellerName().equals("")) {
        try {
          User seller = userService.get(item.getSellerId());
          item.setSellerName(seller.getEmail());
        } catch (Exception ex) {
        }
      }
    }
    List<City> cities = cityService.list();
    modelMap.put("itemSearch", itemSearch);
    modelMap.put("itemPage", itemPage);
    modelMap.put("cities", cities);
    modelMap.put("itemCates", categoryService.getCategories(cateIds));
    modelMap.put("itemShopCates", shopCategoryService.get(shopCateIds));
    modelMap.put("itemManuf", manufacturerService.getManufacturers(manufIds));
    modelMap.put("itemModels", modelService.getModels(modelIds));
    modelMap.put(
        "clientScript",
        "category = "
            + gson.toJson(categoryService.getChilds(null))
            + ",cities="
            + gson.toJson(cities)
            + ";reviewitem.init({parentCategorys:"
            + gson.toJson(parentCategorys)
            + ", categoryId:'"
            + (itemSearch.getCategoryIds().isEmpty() ? "" : itemSearch.getCategoryIds().get(0))
            + "'});");
    return "cp.item.review";
  }
  /**
   * Tìm kiếm tất cả sản phẩm
   *
   * @param itemSearch
   * @param session
   * @param modelMap
   * @return
   */
  @RequestMapping(
      value = {"/reviewitem"},
      method = RequestMethod.POST)
  public String reviewSearch(
      @ModelAttribute("itemSearch") ItemSearch itemSearch, HttpSession session, ModelMap modelMap) {
    Map<String, Object> parentCategorys = new HashMap<>();
    List<String> cateIds = new ArrayList<>();
    List<String> shopCateIds = new ArrayList<>();
    List<String> manufIds = new ArrayList<>();
    List<String> modelIds = new ArrayList<>();

    itemSearch.setPageIndex(0);
    itemSearch.setPageSize(50);
    if (itemSearch.getCategoryId() != null && !itemSearch.getCategoryId().equals("")) {
      itemSearch.setCategoryIds(new ArrayList<String>());
      itemSearch.getCategoryIds().add(itemSearch.getCategoryId());
    }
    getAncestors(itemSearch, parentCategorys);
    session.setAttribute("itemSearch", itemSearch);
    DataPage<Item> itemPage = itemService.searchMongo(itemSearch);
    for (Item item : itemPage.getData()) {
      if (item.getCategoryId() != null
          && !item.getCategoryId().equals("")
          && !cateIds.contains(item.getCategoryId())) {
        cateIds.add(item.getCategoryId());
      }
      if (item.getShopCategoryId() != null
          && !item.getShopCategoryId().equals("")
          && !shopCateIds.contains(item.getShopCategoryId())) {
        shopCateIds.add(item.getShopCategoryId());
      }
      if (item.getManufacturerId() != null
          && !item.getManufacturerId().equals("")
          && !manufIds.contains(item.getManufacturerId())) {
        manufIds.add(item.getManufacturerId());
      }
      if (item.getModelId() != null
          && !item.getModelId().equals("")
          && !modelIds.contains(item.getModelId())) {
        modelIds.add(item.getModelId());
      }
    }
    for (Item item : itemPage.getData()) {
      List<String> images = new ArrayList<>();
      if (item != null && item.getImages() != null && !item.getImages().isEmpty()) {
        for (String img : item.getImages()) {
          images.add(
              imageService.getUrl(img).thumbnail(200, 200, "outbound").getUrl(item.getName()));
        }
        item.setImages(images);
      }
      if (item.getSellerName() == null || item.getSellerName().equals("")) {
        try {
          User seller = userService.get(item.getSellerId());
          item.setSellerName(seller.getEmail());
        } catch (Exception ex) {
        }
      }
    }
    if (itemSearch.getCategoryIds() == null) {
      itemSearch.setCategoryIds(new ArrayList<String>());
    }
    List<City> cities = cityService.list();
    modelMap.put("itemSearch", itemSearch);
    modelMap.put("itemPage", itemPage);
    modelMap.put("cities", cities);
    modelMap.put("itemCates", categoryService.getCategories(cateIds));
    modelMap.put("itemShopCates", shopCategoryService.get(shopCateIds));
    modelMap.put("itemManuf", manufacturerService.getManufacturers(manufIds));
    modelMap.put("itemModels", modelService.getModels(modelIds));
    modelMap.put(
        "clientScript",
        "category = "
            + gson.toJson(categoryService.getChilds(null))
            + ",cities="
            + gson.toJson(cities)
            + ";reviewitem.init({parentCategorys:"
            + gson.toJson(parentCategorys)
            + ", categoryId:'"
            + (itemSearch.getCategoryIds().isEmpty() ? "" : itemSearch.getCategoryIds().get(0))
            + "'});");
    return "cp.item.review";
  }