From 8ae5d9e3ce643bf0b8488c4566eff133b2cb2f11 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 17 Jan 2016 01:36:57 +0300 Subject: fix replyidincrement --- src/main/java/com/juick/server/MessagesQueries.java | 3 ++- src/main/java/com/juick/server/SubscriptionsQueries.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src/main/java/com/juick') diff --git a/src/main/java/com/juick/server/MessagesQueries.java b/src/main/java/com/juick/server/MessagesQueries.java index bcb2d08d..422cfe7d 100644 --- a/src/main/java/com/juick/server/MessagesQueries.java +++ b/src/main/java/com/juick/server/MessagesQueries.java @@ -119,7 +119,8 @@ public class MessagesQueries { } public static int getReplyIDIncrement(JdbcTemplate sql, int mid) { - return sql.update("UPDATE messages SET maxreplyid=maxreplyid+1 WHERE message_id=?", mid); + sql.update("UPDATE messages SET maxreplyid=maxreplyid+1 WHERE message_id=?", mid); + return sql.queryForObject("SELECT maxreplyid FROM messages WHERE message_id=?", new Object[] {mid}, Integer.class); } public static boolean recommendMessage(JdbcTemplate sql, int mid, int vuid) { diff --git a/src/main/java/com/juick/server/SubscriptionsQueries.java b/src/main/java/com/juick/server/SubscriptionsQueries.java index 8207f499..3a76e23e 100644 --- a/src/main/java/com/juick/server/SubscriptionsQueries.java +++ b/src/main/java/com/juick/server/SubscriptionsQueries.java @@ -93,6 +93,6 @@ public class SubscriptionsQueries { } public static boolean subscribeMessage(JdbcTemplate sql, int mid, int vuid) { - return sql.update("INSERT INTO subscr_messages(suser_id,message_id) VALUES (" + vuid + "," + mid + ")") == 1; + return sql.update("INSERT IGNORE INTO subscr_messages(suser_id,message_id) VALUES (" + vuid + "," + mid + ")") == 1; } } -- cgit v1.2.3