diff options
author | Ugnich Anton | 2012-01-27 08:34:31 +0700 |
---|---|---|
committer | Ugnich Anton | 2012-01-27 08:34:31 +0700 |
commit | f656d844d0096cf8637746afaa1fab7dadaef261 (patch) | |
tree | 9c8145d8d72ed548f37d2e82596cfa9d63136ca0 /src/com/juick/server | |
parent | 55f03c70caeec32ae71e5afe99c4eae5b6b192d3 (diff) |
User.getCanMedia, Tag.getUserTagsAll
Diffstat (limited to 'src/com/juick/server')
-rw-r--r-- | src/com/juick/server/TagQueries.java | 25 | ||||
-rw-r--r-- | src/com/juick/server/UserQueries.java | 20 |
2 files changed, 45 insertions, 0 deletions
diff --git a/src/com/juick/server/TagQueries.java b/src/com/juick/server/TagQueries.java index 8cb7ee1a..7d78e345 100644 --- a/src/com/juick/server/TagQueries.java +++ b/src/com/juick/server/TagQueries.java @@ -22,6 +22,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; +import java.util.ArrayList; /** * @@ -65,4 +66,28 @@ public class TagQueries { return tid; } + + public static ArrayList<com.juick.Tag> getUserTagsAll(Connection sql, int uid) { + ArrayList<com.juick.Tag> tags = new ArrayList<com.juick.Tag>(); + + PreparedStatement stmt = null; + ResultSet rs = null; + try { + stmt = sql.prepareStatement("SELECT tags.name,COUNT(messages.message_id) FROM (messages INNER JOIN messages_tags ON (messages.user_id=? AND messages.message_id=messages_tags.message_id)) INNER JOIN tags ON messages_tags.tag_id=tags.tag_id GROUP BY tags.tag_id ORDER BY tags.name ASC"); + stmt.setInt(1, uid); + rs = stmt.executeQuery(); + rs.beforeFirst(); + while (rs.next()) { + com.juick.Tag t = new com.juick.Tag(); + t.Name = rs.getString(1); + t.UsageCnt = rs.getInt(2); + tags.add(t); + } + } catch (SQLException e) { + System.err.println(e); + } finally { + Utils.finishSQL(rs, stmt); + } + return tags; + } } diff --git a/src/com/juick/server/UserQueries.java b/src/com/juick/server/UserQueries.java index 97cae91f..906f7742 100644 --- a/src/com/juick/server/UserQueries.java +++ b/src/com/juick/server/UserQueries.java @@ -215,4 +215,24 @@ public class UserQueries { Utils.finishSQL(null, stmt); } } + + public static boolean getCanMedia(Connection sql, int uid) { + boolean ret = false; + + PreparedStatement stmt = null; + ResultSet rs = null; + try { + stmt = sql.prepareStatement("SELECT users.lastphoto-UNIX_TIMESTAMP() FROM users WHERE id=?"); + stmt.setInt(1, uid); + rs = stmt.executeQuery(); + if (rs.first()) { + ret = rs.getInt(1) < 3600; + } + } catch (SQLException e) { + System.err.println(e); + } finally { + Utils.finishSQL(rs, stmt); + } + return ret; + } } |