Ejemplo n.º 1
0
  public static Couple<String, String> gift(
      int giftGameID, long matchID, long uid, String uids, int number)
      throws SQLException, SimpleException {
    String query = "{call MakeGiftGame(?,?,?,?,?)}";
    int res = 0;
    try (Connection conn = DBPoolConnection.getConnection()) {
      CallableStatement cs = conn.prepareCall(query);
      cs.clearParameters();
      cs.setLong(1, uid);
      cs.setLong(2, matchID);
      cs.setInt(3, number);
      cs.setString(4, uids);
      cs.setInt(5, giftGameID);

      ResultSet rs = cs.executeQuery();
      if (rs != null && rs.next()) {
        res = rs.getInt("result");
      }
    }
    if (res == 1) {
      return giftGameChat(giftGameID);
    } else {
      throw new SimpleException("Không tặng được");
    }
  }
Ejemplo n.º 2
0
  public static void reload() throws SQLException {
    String query = "{call GetGift()}";
    try (Connection conn = DBPoolConnection.getConnection();
        CallableStatement cs = conn.prepareCall(query);
        ResultSet rs = cs.executeQuery()) {
      if (rs != null) {
        while (rs.next()) {
          int id = rs.getInt("GiftGameID");
          String name = rs.getString("name");
          String category = rs.getString("typeName");
          String icon = rs.getString("icon");
          String bigIcon = rs.getString("bigIcon");
          long price = rs.getLong("price");
          int giftTypeID = rs.getInt("giftTypeID");
          String activeChat = rs.getString("activeChat");
          String passiveChat = rs.getString("passiveChat");
          GiftGameEntity ent =
              new GiftGameEntity(
                  id, name, category, giftTypeID, icon, bigIcon, price, activeChat, passiveChat);

          giftGames.put(ent.id, ent);
          if (!giftType.containsKey(giftTypeID)) {
            giftType.put(giftTypeID, category);
          }
        }
      }
    }
  }