コード例 #1
0
ファイル: ModelController.java プロジェクト: toannh/ecommerce
 /**
  * gen images
  *
  * @param id
  * @throws Exception
  */
 public void genImages(Model model) throws Exception {
   List<String> imgs = new ArrayList<>();
   for (String img : model.getImages()) {
     imgs.add(imageService.getUrl(img).thumbnail(100, 100, "outbound").getUrl(model.getName()));
   }
   model.setImages(imgs);
 }
コード例 #2
0
ファイル: ModelController.java プロジェクト: toannh/ecommerce
  /**
   * Lấy thông tin thuộc tính model theo id
   *
   * @param id
   * @return
   */
  @RequestMapping(value = "/getproperties", method = RequestMethod.GET)
  @ResponseBody
  public Response getProperties(@RequestParam(value = "id", defaultValue = "") String id)
      throws Exception {
    Model model = modelService.getModel(id);
    if (model == null) {
      throw new Exception("Model không tồn tại");
    }
    HashMap<String, Object> data = new HashMap<>();
    List<ModelProperty> properties = modelService.getProperties(id);
    data.put("model", model);
    data.put("properties", properties);
    data.put("categoryProperties", categoryService.getProperties(model.getCategoryId()));
    data.put(
        "categoryPropertyValues",
        categoryService.getPropertyValuesWithCategoryId(model.getCategoryId()));

    return new Response(true, "Thông tin model", data);
  }
コード例 #3
0
  /**
   * Sửa model
   *
   * @param form
   * @return
   * @throws Exception
   */
  @RequestMapping(value = "/edit", method = RequestMethod.POST)
  @ResponseBody
  public Response edit(@RequestBody ModelForm form) throws Exception {
    String id = "test";
    if (viewer != null && viewer.getAdministrator() != null) {
      id = viewer.getAdministrator().getId();
    }
    Model model = new Model();
    model.setCategoryId(form.getCategoryId());
    model.setId(form.getId());
    model.setManufacturerId(form.getManufacturerId());
    model.setEbayKeyword(form.getEbayKeyword());
    model.setName(form.getName());
    if (form.getActive() > 0) {
      model.setActive(form.getActive() == ModelForm.TRUE);
    }

    return modelService.edit(model, id);
  }
コード例 #4
0
ファイル: ModelController.java プロジェクト: toannh/ecommerce
 /**
  * Lấy thông tin chi tiết model theo id
  *
  * @param modelId
  * @return
  */
 @RequestMapping(value = "/getmodel", method = RequestMethod.GET)
 @ResponseBody
 public Response get(@RequestParam(value = "id", defaultValue = "") String id) throws Exception {
   Model model = modelService.getModel(id);
   if (model == null) {
     throw new Exception("Model không tồn tại");
   }
   List<String> images = model.getImages();
   List<String> imgs = new ArrayList<>();
   for (String img : images) {
     imgs.add(imageService.getUrl(img).thumbnail(100, 100, "outbound").getUrl(model.getName()));
   }
   model.setImages(imgs);
   model.setProperties(modelService.getProperties(model.getId()));
   ModelSeo modelSeo = modelService.getModelSeo(id);
   if (modelSeo != null) {
     model.setModelSeo(modelSeo);
   }
   return new Response(true, "Thông tin chi tiết model", model);
 }