diff options
Diffstat (limited to 'juick-core/src/main')
-rw-r--r-- | juick-core/src/main/java/com/juick/server/PushQueries.java | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/juick-core/src/main/java/com/juick/server/PushQueries.java b/juick-core/src/main/java/com/juick/server/PushQueries.java index f4c98fcf..904b3c0d 100644 --- a/juick-core/src/main/java/com/juick/server/PushQueries.java +++ b/juick-core/src/main/java/com/juick/server/PushQueries.java @@ -4,12 +4,10 @@ */ package com.juick.server; -import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.util.StringUtils; import java.util.List; -import java.util.Optional; /** * @@ -17,13 +15,8 @@ import java.util.Optional; */ public class PushQueries { - public static Optional<String> getAndroidRegID(JdbcTemplate sql, int uid) { - try { - return Optional.of(sql.queryForObject("SELECT regid FROM android WHERE user_id=?", String.class, uid)); - } catch (EmptyResultDataAccessException e) { - return Optional.empty(); - } - + public static List<String> getAndroidRegID(JdbcTemplate sql, int uid) { + return sql.queryForList("SELECT regid FROM android WHERE user_id=?", String.class, uid); } public static List<String> getAndroidTokens(JdbcTemplate sql, List<Integer> uids) { @@ -31,12 +24,8 @@ public class PushQueries { "ON (users.id=android.user_id) WHERE users.id IN (" + StringUtils.collectionToCommaDelimitedString(uids) + ")", String.class); } - public static Optional<String> getWinPhoneURL(JdbcTemplate sql, int uid) { - try { - return Optional.of(sql.queryForObject("SELECT url FROM winphone WHERE user_id=?", String.class, uid)); - } catch (EmptyResultDataAccessException e) { - return Optional.empty(); - } + public static List<String> getWinPhoneURL(JdbcTemplate sql, int uid) { + return sql.queryForList("SELECT url FROM winphone WHERE user_id=?", String.class, uid); } public static List<String> getWindowsTokens(JdbcTemplate sql, List<Integer> uids) { @@ -44,17 +33,12 @@ public class PushQueries { "ON (users.id=winphone.user_id) WHERE users.id IN (" + StringUtils.collectionToCommaDelimitedString(uids) + ")", String.class); } - public static Optional<String> getAPNSToken(JdbcTemplate sql, int uid) { - try { - return Optional.of(sql.queryForObject("SELECT token from ios WHERE user_id=?", String.class, uid)); - } catch (EmptyResultDataAccessException e) { - return Optional.empty(); - } + public static List<String> getAPNSToken(JdbcTemplate sql, int uid) { + return sql.queryForList("SELECT token from ios WHERE user_id=?", String.class, uid); } public static List<String> getAPNSTokens(JdbcTemplate sql, List<Integer> uids) { return sql.queryForList("SELECT token FROM ios INNER JOIN users " + "ON (users.id=ios.user_id) WHERE users.id IN (" + StringUtils.collectionToCommaDelimitedString(uids) + ")", String.class); } - } |