コード例 #1
0
  /** 加入购物车 */
  public void addGoodsStore() throws IOException {
    try {
      goodStore.setState(0);
      goodStoreService.saveGoodStore(goodStore);
      m.put("msg", "1");
      ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

    } catch (Exception e) {
      e.printStackTrace();
      m.put("msg", "-1");
      ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));
    }
  }
コード例 #2
0
 /** 从购物车删除 */
 public void deleteGoodsStore() throws IOException {
   id = Integer.parseInt(ServletActionContext.getRequest().getParameter("id"));
   GoodStore goodStore = goodStoreService.getGoodsStore(id);
   goodStore.setState(-1);
   try {
     goodStoreService.saveOrUpdate(goodStore);
     m.put("msg", "1");
     ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));
   } catch (Exception e) {
     e.printStackTrace();
     m.put("msg", "-1");
     ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));
   }
 }
コード例 #3
0
  public void addGoodsStoredirect() throws IOException {
    id = Integer.parseInt(ServletActionContext.getRequest().getParameter("id"));
    goodId = Integer.parseInt(ServletActionContext.getRequest().getParameter("goodId"));
    count = Integer.parseInt(ServletActionContext.getRequest().getParameter("goodId"));
    GoodStore goodstore = new GoodStore();
    goodstore.setState(1);
    goodstore.setCount(count);
    goodstore.setAddressId(id);
    goodstore.setGoodId(goodId);

    try {
      goodStoreService.saveGoodStore(goodstore);
      m.put("msg", "1");
      ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));
    } catch (Exception e) {
      m.put("msg", "-1");
      e.printStackTrace();
      ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));
    }
  }
コード例 #4
0
  /** 从购物车提交 */
  public void commitGoodsStore() throws IOException {
    ids = ServletActionContext.getRequest().getParameter("ids");
    String str[] = ids.split(",");
    int array[] = new int[str.length];

    try {
      for (int i = 0; i < str.length; i++) {
        array[i] = Integer.parseInt(str[i]);
        goodStore = goodStoreService.getGoodsStore(array[i]);
        goodStore.setState(1);
        goodStoreService.saveOrUpdate(goodStore);
      }
      m.put("msg", "1");
      ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));
    } catch (Exception e) {
      m.put("msg", "-1");
      ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));
      e.printStackTrace();
    }
  }