diff options
author | Vitaly Takmazov | 2016-01-10 15:10:16 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-01-10 15:10:32 +0300 |
commit | 98b91289a497989e2c776c7e4e333ce6df719211 (patch) | |
tree | 5ce5bf6fdefed9e51ff28aae671e03dc96cf9e35 /src/main/java/com/juick/server/UserQueries.java | |
parent | 23666546ca2c0f1ee492b1bea8c0ea83c8c04a2b (diff) |
ON/OFF
Diffstat (limited to 'src/main/java/com/juick/server/UserQueries.java')
-rw-r--r-- | src/main/java/com/juick/server/UserQueries.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/main/java/com/juick/server/UserQueries.java b/src/main/java/com/juick/server/UserQueries.java index d1313715..9140e8ea 100644 --- a/src/main/java/com/juick/server/UserQueries.java +++ b/src/main/java/com/juick/server/UserQueries.java @@ -589,4 +589,29 @@ public class UserQueries { public static int getStatsReplies(Connection sql, int uid) { return SQLHelpers.getInt(sql, "SELECT COUNT(*) FROM replies WHERE user_id=?", uid, 0); } + + public enum ActiveStatus { + Inactive, + Active + } + + public static boolean setActiveStatusForJID(Connection sql, String JID, ActiveStatus jidStatus) { + User user = getUserByJID(sql, JID); + if (user != null) { + PreparedStatement preparedStatement = null; + try { + preparedStatement = sql.prepareStatement( + "UPDATE jids SET active=? WHERE user_id=? AND jid=?"); + int newStatus = jidStatus == ActiveStatus.Active ? 1 : 0; + preparedStatement.setInt(1, newStatus); + preparedStatement.setInt(2, user.UID); + preparedStatement.setString(3, JID); + return preparedStatement.executeUpdate() >= 0; + } catch (SQLException e) { + e.printStackTrace(); + } finally { + Utils.finishSQL(null, preparedStatement); + } + } + } } |