aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/server/SubscriptionsQueries.java
diff options
context:
space:
mode:
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;
+ }
+
}