Package com.lgx8.gateway.entities

Examples of com.lgx8.gateway.entities.Category


    getHibernateTemplate().bulkUpdate("delete from Category c where c.id="+id);
  }
 
  public List<Category> findAllCategoryList(long id) {
    List<Category> list = new ArrayList<Category>();
    Category category = getHibernateTemplate().get(Category.class, id);
    if(category!=null) {
      list.add(category);
      List<Category> childs = findAllChilds(list);
      while(childs!=null&&childs.size()>0) {
        for(Category c:childs) {
View Full Code Here


    return findByPage4Report(hql, new Object[]{}, argment.getCurPage(), argment.getPageSize());
  }

  public List<Category> findAllCategoryList(long id) {
    List<Category> list = new ArrayList<Category>();
    Category category = findCategory(id);
    if(category!=null) {
      list.add(category);
      List<Category> childs = findAllChilds(list);
      while(childs!=null&&childs.size()>0) {
        for(Category c:childs) {
View Full Code Here

    }
  }
 
  @Transactional
  public void deleteCategory(long id) {
    Category category = findCategory(id);
    getHibernateTemplate().delete(category);
  }
View Full Code Here

    String operation = request.getParameter("operation");
    ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
    IGatewayService gatewayService = (IGatewayService) ac.getBean("gatewayService");
    if("3".equals(operation)) {
      try {
        Category category = gatewayService.findCategory(Long.parseLong(id));
        if(category!=null&&category.getChilds().size()>0) {
          PrintWriter pw = response.getWriter();
          pw.write("0:请先删除子类!");
          return;
        }
        gatewayService.deleteCategory(Long.parseLong(id));
        List<Category> categorys = (List<Category>) getServletContext().getAttribute("categorys");
//        categorys.clear();
//        categorys.addAll(gatewayService.findAllCategory());
       
        getServletContext().setAttribute("categorys", categorys);
       
//        Map<Long, Category> categoryMap = (Map<Long, Category>) getServletContext().getAttribute("categoryMap");
//        categoryMap = GatewayIndexListen.addCategoryToMap(categorys, categoryMap)
        Map<Long, Category> categoryMap = new HashMap<Long, Category>();
        GatewayIndexListen.addCategoryToMap(categorys, categoryMap);
        category  = categoryMap.get(Long.parseLong(id));
        if(category.getParent()==null) {
          categorys.remove(category);
        } else {
          category.getParent().getChilds().remove(category);
//          category.setParent(null);
        }
        getServletContext().setAttribute("categoryMap", categoryMap);
       
        PrintWriter pw = response.getWriter();
View Full Code Here

          entityId = advertisment.getMerchant().getID()+"";
        }
      }else if("8".equals(categoryType))
      {
        //商品分类
        Category area = gatewayService.findCategory(Long.parseLong(entityId));
        entityName = area.getName();
      }
     
      bc.clearKeyStore(request)
      PrintWriter pw = response.getWriter();
      response.setCharacterEncoding("UTF-8");
View Full Code Here

        out.print("({'result':'0','msg':'请选择商品分区!'})");
        out.flush();
        return;
      }
     
      Category category = null;
      try {
        category = gatewayService.findCategory(new Long(categoryId));
      } catch (Exception e) {
        category = null;
      }
      if(category!=null) {
        product.setCategory(category);
      } else {
        out.print("({'result':'0','msg':'请选择商品类型!'})");
        out.flush();
        return;
      }
     
      product.setDescription(description);
      product.setFarewaydesc(farewaydesc);
      product.setSaledesc(saledesc);
     
      if(colors!=null) {
        String color = "";
        for(int i=0;i<colors.length;i++) {
          if(i!=colors.length-1) {
            color = color+colors[i]+";";
          } else {
            color = color+colors[i];
          }
        }
        product.setColor(color);
      }
     
      if(colthesizes!=null) {
        String clothessize = "";
        for(int i=0;i<colthesizes.length;i++) {
          if(i!=colthesizes.length-1) {
            clothessize = clothessize+colthesizes[i]+";";
          } else {
            clothessize = clothessize+colthesizes[i];
          }
        }
        product.setClothessize(clothessize);
      }
     
      if(shoesizes!=null) {
        String shoesize = "";
        for(int i=0;i<shoesizes.length;i++) {
          if(i!=shoesizes.length-1) {
            shoesize = shoesize+shoesizes[i]+";";
          } else {
            shoesize = shoesize+shoesizes[i];
          }
        }
        product.setShoesize(shoesize);
      }
     
      if(fareways!=null) {
        String fareway = "";
        for(int i=0;i<fareways.length;i++) {
          if(i!=fareways.length-1) {
            fareway = fareway+fareways[i]+";";
          } else {
            fareway = fareway+fareways[i];
          }
        }
        product.setFareway(fareway);
      } else {
        out.print("({'result':'0','msg':'请选择商品运费支付方式!'})");
        out.flush();
        return;
      }
     
      product.setCreatedate(new Date());
     
      gatewayService.createProduct(product);
     
      out.print("({'result':'1','msg':'成功添加商品!'})");
      out.flush();
      return;
     
    } else if("3".equals(operation)) {
      String id = request.getParameter("id");
     
      long lid = -1;
      try {
        lid = Long.parseLong(id);
      } catch (Exception e) {
        lid = -1;
      }
      ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
      IGatewayService gatewayService = (IGatewayService) ac.getBean("gatewayService");
     
      gatewayService.deleteProduct(lid);
     
      request.getRequestDispatcher("page/gateway/admin/product/ProductList.jsp").forward(request, response);
    } else if("2".equals(operation)) {
      String id = request.getParameter("id");
     
      long lid = -1;
      try {
        lid = Long.parseLong(id);
      } catch (Exception e) {
        lid = -1;
      }
      ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
      IGatewayService gatewayService = (IGatewayService) ac.getBean("gatewayService");
     
      Product product = gatewayService.findProductById(lid);
      if(product==null) {
        out.print("({'result':'0','msg':'修改的商品信息不存在!'})");
        out.flush();
        return;
      }
      String name = request.getParameter("name");
      String areaNode = request.getParameter("areaNode");
      String weight = request.getParameter("weight");
      String productImageId = request.getParameter("productImageId");
      String price = request.getParameter("price");
      String amount = request.getParameter("amount");
      String leaves = request.getParameter("leaves");
      String brandId = request.getParameter("brandId");
      String onsale = request.getParameter("onsale");
      String areaCategoryId = request.getParameter("areaCategoryId");
      String categoryId = request.getParameter("categoryId");
      String[] colors = request.getParameterValues("color");
      String[] colthesizes = request.getParameterValues("colthesize");
      String[] shoesizes = request.getParameterValues("shoesize");
      String[] fareways = request.getParameterValues("fareway");
      String description = request.getParameter("description");
      String farewaydesc = request.getParameter("farewaydesc");
      String saledesc = request.getParameter("saledesc");
      String code = request.getParameter("code");
     
      product.setName(name);
      product.setAreaNode(areaNode);
      product.setWeight(Double.parseDouble(weight));
      product.setCode(code);
     
      long imageid = -1;
      try {
        imageid = Long.parseLong(productImageId);
      } catch (Exception e) {
        imageid = -1;
        out.print("({'result':'0','msg':'请上传商品图片!'})");
        out.flush();
        return;
      }
      ProductImage image = gatewayService.findProductImage(imageid);
      if(image!=null) {
        product.setImage(image);
      } else {
        out.print("({'result':'0','msg':'未找到商品图片!'})");
        out.flush();
        return;
      }
       
     
      long lbrandid = -1;
      try {
        lbrandid = Long.parseLong(brandId);
      } catch (Exception e) {
        lbrandid = -1;
        out.print("({'result':'0','msg':'请选择商品品牌!'})");
        out.flush();
        return;
      }
      Brand brand = gatewayService.findBrandById(lbrandid);
      if(brand!=null) {
        product.setBrand(brand);
      } else {
        out.print("({'result':'0','msg':'未找到商品品牌!'})");
        out.flush();
        return;
      }
     
      double pprice = 0;
      try {
        pprice = new Double(price);
      } catch (Exception e) {
        pprice = 0;
      }
      if(pprice<=0) {
        out.print("({'result':'0','msg':'请正确添加价格!'})");
        out.flush();
        return;
      }
      product.setPrice(pprice);
     
      int pleaves = 0;
      try {
        pleaves = new Integer(leaves);
      } catch (Exception e) {
        pleaves = 0;
      }
      if(pleaves<0) {
        out.print("({'result':'0','msg':'请正确填写库存!'})");
        out.flush();
        return;
      }
      product.setLeaves(pleaves);
     
      int pamount = 0;
      try {
        pamount = new Integer(amount);
      } catch (Exception e) {
        pamount = 0;
      }
      if(pamount<=0) {
        out.print("({'result':'0','msg':'请正确填写总量!'})");
        out.flush();
        return;
      }
      product.setAmount(pamount);
     
      if("1".equals(onsale)) {
        product.setOnsale(1);
      } else {
        product.setOnsale(0);
      }
     
      AreaCategory areaCategory = null;
      try {
        areaCategory = gatewayService.findAreaCategory(new Long(areaCategoryId));
      } catch (Exception e) {
        areaCategory = null;
      }
      if(areaCategory!=null) {
        product.setAreaCategory(areaCategory);
      } else {
        out.print("({'result':'0','msg':'请选择商品分区!'})");
        out.flush();
        return;
      }
     
      Category category = null;
      try {
        category = gatewayService.findCategory(new Long(categoryId));
      } catch (Exception e) {
        category = null;
      }
View Full Code Here

    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;
    }
View Full Code Here

    String sendMsg = request.getParameter("sendMsg");
   
    ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
   
    ICategoryDao categoryDao = (ICategoryDao)ac.getBean("categoryDao");
    Category category = categoryDao.findCategory(Long.parseLong(id));
   
    if(category != null)
    {
      category.setName(name);
      category.setDescription(description);
      category.setSendMsg(sendMsg);
      categoryDao.updateCategory(category);
    }
   
   
    IGatewayService gatewayService = (IGatewayService) ac.getBean("gatewayService");
View Full Code Here

    String sendMsg = request.getParameter("sendMsg");
   
    ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
    IGatewayService gatewayService = (IGatewayService) ac.getBean("gatewayService");
   
    Category category = new Category();
    category.setName(name);
    category.setUrl(url);
    category.setDescription(description);
    category.setSendMsg(sendMsg);
   
    Category parent = null;
    //非顶级目录
    if(parentid!=null&&!"-1".equals(parentid)) {
      parent = gatewayService.findCategory(new Long(parentid));
    }
    if(parent!=null) {
View Full Code Here

  }

  @Transactional
  public GatewayCategoryDetail updateGatewayCategoryDetail(
      Integer categoryId, Integer id, String layerOrder) {
    GatewayCategory category = gatewayCategoryDao.findGatewayCategoryById(categoryId);
    GatewayCategoryDetail detail = getHibernateTemplate().get(GatewayCategoryDetail.class, id);
    detail.setCategory(category);
    detail.setLayerOrder(layerOrder);
    getHibernateTemplate().update(detail);
    return detail;
View Full Code Here

TOP

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

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.