Exemplo n.º 1
0
  /*
   * 根据制定用户的分享记录
   */
  public static List<SharedList> getSharedList(String wechatId) {

    List<SharedList> list = new ArrayList<SharedList>();
    String sql = "select * from shared_list where wechat_id = ?";

    Connection conn = new DBUtil().getConn();
    try {
      ps = conn.prepareStatement(sql);
      ps.setString(1, wechatId);
      rs = ps.executeQuery();
      while (rs.next()) {
        SharedList shared = new SharedList();
        shared.setFirendWechatId(rs.getString("friend_wechat_id"));
        shared.setWechatId(rs.getString("wechat_id"));
        shared.setGoodsId(rs.getInt("goods_id"));
        list.add(shared);
      }
    } catch (SQLException e) {
      e.printStackTrace();
      return null;
    } finally {
      clearUp(conn);
    }

    return list;
  }
Exemplo n.º 2
0
 public static boolean addSharedList(SharedList list) {
   String sql =
       "INSERT INTO `greenlife`.`shared_list` "
           + "(`wechat_id`, `friend_wechat_id`, `goods_id`) VALUES (?, ?, ?);";
   Connection conn = new DBUtil().getConn();
   try {
     ps = conn.prepareStatement(sql);
     ps.setString(1, list.getWechatId());
     ps.setString(2, list.getFirendWechatId());
     ps.setInt(3, list.getGoodsId());
     ps.execute();
   } catch (SQLException e) {
     e.printStackTrace();
     return false;
   } finally {
     clearUp(conn);
   }
   return true;
 }
Exemplo n.º 3
0
 public static boolean updateSharedList(SharedList list) {
   String sql =
       "UPDATE `greenlife`.`shared_list` SET "
           + "friend_wechat_id = (?) "
           + "goods_id = (?)"
           + "WHERE wechat_id = (?);";
   Connection conn = new DBUtil().getConn();
   try {
     ps = conn.prepareStatement(sql);
     ps.setString(1, list.getFirendWechatId());
     ps.setInt(2, list.getGoodsId());
     ps.setString(3, list.getWechatId());
     ps.execute();
   } catch (SQLException e) {
     e.printStackTrace();
     return false;
   } finally {
     clearUp(conn);
   }
   return true;
 }