aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/server/SubscriptionsQueries.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-06-29 15:09:47 +0300
committerGravatar Vitaly Takmazov2016-06-29 15:09:47 +0300
commit797942249b0d5e38285e806bc0e73e755e6ffede (patch)
tree6d785d6b59fbc57d6e0e82af157df1abf3e853be /src/main/java/com/juick/server/SubscriptionsQueries.java
parent87da42e3385e368f05d88ff125a78605a18f9cc3 (diff)
add more bot queries
Diffstat (limited to 'src/main/java/com/juick/server/SubscriptionsQueries.java')
-rw-r--r--src/main/java/com/juick/server/SubscriptionsQueries.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main/java/com/juick/server/SubscriptionsQueries.java b/src/main/java/com/juick/server/SubscriptionsQueries.java
index feebfb22..9f0372ff 100644
--- a/src/main/java/com/juick/server/SubscriptionsQueries.java
+++ b/src/main/java/com/juick/server/SubscriptionsQueries.java
@@ -4,6 +4,7 @@
*/
package com.juick.server;
+import com.juick.Tag;
import com.juick.User;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.StringUtils;
@@ -78,4 +79,25 @@ public class SubscriptionsQueries {
public static boolean subscribeMessage(JdbcTemplate sql, int mid, int vuid) {
return sql.update("INSERT IGNORE INTO subscr_messages(suser_id,message_id) VALUES (" + vuid + "," + mid + ")") == 1;
}
+ public static boolean unSubscribeMessage(JdbcTemplate sql, int mid, int vuid) {
+ return sql.update("DELETE FROM subscr_messages WHERE message_id=? AND suser_id=?",
+ mid, vuid) > 0;
+ }
+ public static boolean subscribeUser(JdbcTemplate sql, User user, User toUser) {
+ return sql.update("INSERT IGNORE INTO subscr_users(user_id,suser_id) VALUES (?,?)",
+ user.getUID(), toUser.getUID()) == 1;
+ }
+ public static boolean unSubscribeUser(JdbcTemplate sql, User user, User fromUser) {
+ return sql.update("DELETE FROM subscr_users WHERE suser_id=? AND user_id=?",
+ user.getUID(), fromUser.getUID()) > 0;
+ }
+ public static boolean subscribeTag(JdbcTemplate sql, User user, Tag toTag) {
+ return sql.update("INSERT IGNORE INTO subscr_tags(tag_id,suser_id) VALUES (?,?)",
+ toTag.TID, user.getUID()) == 1;
+ }
+ public static boolean unSubscribeTag(JdbcTemplate sql, User user, Tag toTag) {
+ return sql.update("DELETE FROM subscr_tags WHERE tag_id=? AND suser_id=?",
+ toTag.TID, user.getUID()) > 0;
+ }
+
}