From 98b91289a497989e2c776c7e4e333ce6df719211 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 10 Jan 2016 15:10:16 +0300 Subject: ON/OFF --- src/main/java/com/juick/server/UserQueries.java | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/main/java/com/juick') 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); + } + } + } } -- cgit v1.2.3