diff options
author | Vitaly Takmazov | 2015-12-01 16:27:32 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2015-12-01 16:27:32 +0300 |
commit | 79e48598873f6a2b4ec1aa850e310a689d862afa (patch) | |
tree | 8e08e9a147349559321a014d1ebe86c06044ffc8 /src | |
parent | 0a00a5e5625ea0241c0effb3ed6f715fd737a04d (diff) |
link twitter account query
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/juick/server/UserQueries.java | 29 |
1 files changed, 29 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..470f3c8e 100644 --- a/src/main/java/com/juick/server/UserQueries.java +++ b/src/main/java/com/juick/server/UserQueries.java @@ -17,6 +17,8 @@ */ package com.juick.server; +import com.juick.User; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -574,6 +576,33 @@ public class UserQueries { return users; } + public static boolean linkTwitterAccount(Connection sql, User user, String accessToken, + String accessTokenSecret, String screenName) { + try { + PreparedStatement stmt = + sql.prepareStatement("INSERT INTO twitter(user_id,access_token,access_token_secret,uname) " + + "VALUES (?,?,?,?)" + + " ON DUPLICATE KEY UPDATE access_token=?,access_token_secret=?,uname=?;"); + stmt.setInt(1, user.UID); + stmt.setString(2, accessToken); + stmt.setString(3, accessTokenSecret); + stmt.setString(4, screenName); + stmt.setString(5, accessToken); + stmt.setString(6, accessTokenSecret); + stmt.setString(7, screenName); + if (stmt.execute()) { + PreparedStatement stmt2 = + sql.prepareStatement("INSERT INTO subscr_users(user_id,suser_id,jid) " + + "VALUES (?,1741,'juick\\@twitter.juick.com')"); + stmt2.setInt(1, user.UID); + return stmt2.execute(); + } + } catch (SQLException e) { + + } + return false; + } + public static int getStatsIRead(Connection sql, int uid) { return SQLHelpers.getInt(sql, "SELECT COUNT(*) FROM subscr_users WHERE suser_id=?", uid, 0); } |