Package com.lgx8.gateway.entities

Examples of com.lgx8.gateway.entities.Product


   * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
    IGatewayService gatewayService = (IGatewayService) ac.getBean("gatewayService");
    Product product = new Product();
   
    String name = request.getParameter("name");
    product.setName(name);
   
    String areaNode = request.getParameter("areaNode");
    product.setAreaNode(areaNode);
   
    String code = request.getParameter("code");
    product.setCode(code);
   
    String weight = request.getParameter("weight");
    product.setWeight(Double.parseDouble(weight));
   
    String productImageId = request.getParameter("productImageId");
    ProductImage image = null;
    if(productImageId!=null) {
      try {
        image = gatewayService.findProductImage(new Long(productImageId));
      } catch (Exception e) {
        image = null;
      }
    }
    if(image!=null) {
      product.setImage(image);
    }
    String price = request.getParameter("price");
    double pprice = 0;
    try {
      pprice = new Double(price);
    } catch (Exception e) {
      pprice = 0;
    }
    product.setPrice(pprice);
   
    String leaves = request.getParameter("leaves");
    int pleaves = 0;
    try {
      pleaves = new Integer(leaves);
    } catch (Exception e) {
      pleaves = 0;
    }
    product.setLeaves(pleaves);
   
    String onsale = request.getParameter("onsale");
    if("1".equals(onsale)) {
      product.setOnsale(1);
    } else {
      product.setOnsale(0);
    }
   
    String areaCategoryId = request.getParameter("areaCategoryId");
    AreaCategory areaCategory = null;
    try {
      areaCategory = gatewayService.findAreaCategory(new Long(areaCategoryId));
    } catch (Exception e) {
      areaCategory = null;
    }
    if(areaCategory!=null) {
      product.setAreaCategory(areaCategory);
    }
   
    String categoryId = request.getParameter("categoryId");
    Category category = null;
    try {
      category = gatewayService.findCategory(new Long(categoryId));
    } catch (Exception e) {
      category = null;
    }
    product.setCategory(category);
   
    String description = request.getParameter("description");
    product.setDescription(description);
   
    gatewayService.createProduct(product);
   
    PrintWriter out = response.getWriter();
    out.print("1");
View Full Code Here


    try {
      productId = Long.parseLong(id);
    } catch (Exception e1) {
      productId = 0;
    }
    Product product = null;
    ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
    IGatewayService gatewayService = (IGatewayService) ac.getBean("gatewayService");
   
    Map<Object, Object> root = new HashMap<Object, Object>();
    root.putAll(base);
   
    root.put("searchURL", Constants.SEARCH_URL);
   
    if(productId!=0) {
      product = gatewayService.findProductById(productId);
    }
    if(product!=null) {
      root.put("product", product);
      if(product.getColor()!=null&&!"".equals(product.getColor())) {
        List<ProductProperty> colors = gatewayService.findProductPropertyByIds(product.getColor().split(";"));
        if(colors!=null&&colors.size()>0) {
          root.put("colors", colors);
        }
      }
      if(product.getClothessize()!=null&&!"".equals(product.getClothessize())) {
        List<ProductProperty> clothesizes = gatewayService.findProductPropertyByIds(product.getClothessize().split(";"));
        if(clothesizes!=null&&clothesizes.size()>0) {
          root.put("clothesizes", clothesizes);
        }
      }
      if(product.getShoesize()!=null&&!"".equals(product.getShoesize())) {
        List<ProductProperty> shoesizes = gatewayService.findProductPropertyByIds(product.getShoesize().split(";"));
        if(shoesizes!=null&&shoesizes.size()>0) {
          root.put("shoesizes", shoesizes);
        }
      }
     
      long supplierid = -1;
      try {
        supplierid = product.getBrand().getSupplier().getId();
      } catch (Exception e) {
        supplierid = -1;
      }
      //供应商相关产品
      List<Product> relatedProducts = gatewayService.findProductBySupplier(supplierid, Product.ONSALE, Constants.RELATED_PRODUCT_SIZE);;
View Full Code Here

    try {
      productId = Long.parseLong(id);
    } catch (Exception e1) {
      productId = 0;
    }
    Product product = null;
    ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
    IGatewayService gatewayService = (IGatewayService) ac.getBean("gatewayService");
   
    Map<Object, Object> root = new HashMap<Object, Object>();
    root.putAll(base);
View Full Code Here

    this.productPropertyCategoryDao = productPropertyCategoryDao;
  }

  @Transactional
  public ProductProperty createProductProperty(Long categoryId, String value) {
    ProductProperty property = new ProductProperty();
    property.setEnabled(true);
   
    ProductPropertyCategory category = productPropertyCategoryDao.findProductPropertyCategoryById(categoryId);
   
    property.setCategory(category);
    property.setValue(value);
    getHibernateTemplate().persist(property);
    return property;
  }
View Full Code Here

    getHibernateTemplate().update(property);
    return property;
  }

  public ProductProperty findProductPropertyById(Long id) {
    ProductProperty property = getHibernateTemplate().get(ProductProperty.class, id);
    return property;
  }
View Full Code Here

    return property;
  }

  @Transactional
  public void deleteProductProperty(Long id) {
    ProductProperty property = findProductPropertyById(id);
    property.setEnabled(false);
    getHibernateTemplate().update(property);
  }
View Full Code Here

  @Transactional
  public ProductProperty createProductProperty(Long categoryId, String value) {
    ProductProperty property = new ProductProperty();
    property.setEnabled(true);
   
    ProductPropertyCategory category = productPropertyCategoryDao.findProductPropertyCategoryById(categoryId);
   
    property.setCategory(category);
    property.setValue(value);
    getHibernateTemplate().persist(property);
    return property;
View Full Code Here

public class ProductPropertyCategoryDao extends BaseDao implements IProductPropertyCategoryDao {

  @Transactional
  public ProductPropertyCategory createProductPropertyCategory(String name) {
    ProductPropertyCategory category = new ProductPropertyCategory();
    category.setEnabled(true);
    category.setName(name);
    getHibernateTemplate().persist(category);
    return category;
  }
View Full Code Here

  }

  @Transactional
  public void deleteProductPropertyCategory(Long id)
  {
    ProductPropertyCategory category = findProductPropertyCategoryById(id);
    category.setEnabled(false);
    getHibernateTemplate().update(category);
//    getHibernateTemplate().delete(findProductPropertyCategoryById(id));
  }
View Full Code Here

    List<ProductPropertyCategory> categorys = getHibernateTemplate().find(hql);
    return categorys;
  }

  public ProductPropertyCategory findProductPropertyCategoryById(Long id) {
    ProductPropertyCategory category = getHibernateTemplate().get(ProductPropertyCategory.class, id);
    return category;
  }
View Full Code Here

TOP

Related Classes of com.lgx8.gateway.entities.Product

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.