aboutsummaryrefslogtreecommitdiff
path: root/juick-server-jdbc/src/main/java/com/juick/service
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server-jdbc/src/main/java/com/juick/service')
-rw-r--r--juick-server-jdbc/src/main/java/com/juick/service/TelegramServiceImpl.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/juick-server-jdbc/src/main/java/com/juick/service/TelegramServiceImpl.java b/juick-server-jdbc/src/main/java/com/juick/service/TelegramServiceImpl.java
index 14cdfc8f..4e37bfac 100644
--- a/juick-server-jdbc/src/main/java/com/juick/service/TelegramServiceImpl.java
+++ b/juick-server-jdbc/src/main/java/com/juick/service/TelegramServiceImpl.java
@@ -18,6 +18,7 @@
package com.juick.service;
import com.juick.User;
+import org.springframework.dao.DuplicateKeyException;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@@ -36,7 +37,11 @@ public class TelegramServiceImpl extends BaseJdbcService implements TelegramServ
@Transactional
@Override
public boolean addChat(final Long id) {
- return getJdbcTemplate().update("INSERT IGNORE INTO telegram_chats(chat_id) VALUES(?)", id) > 0;
+ try {
+ return getJdbcTemplate().update("INSERT INTO telegram_chats(chat_id) VALUES(?)", id) > 0;
+ } catch (DuplicateKeyException e) {
+ return true;
+ }
}
@Transactional