diff options
author | Vitaly Takmazov | 2018-04-10 14:21:20 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-04-10 14:21:20 +0300 |
commit | 4d8842d3254886b1925015e0cd24005dd927dd2a (patch) | |
tree | 211e2b180a4540d7e1f241cefabda63b4c6128fd /juick-server-jdbc | |
parent | ffc282136234eeb9caf169794fd25e34ee9d5bd2 (diff) |
server: add minimal telegram test
Diffstat (limited to 'juick-server-jdbc')
-rw-r--r-- | juick-server-jdbc/src/main/java/com/juick/service/TelegramServiceImpl.java | 7 |
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 |