aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/service/PushQueriesServiceImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/main/java/com/juick/service/PushQueriesServiceImpl.java')
-rw-r--r--juick-server/src/main/java/com/juick/service/PushQueriesServiceImpl.java70
1 files changed, 70 insertions, 0 deletions
diff --git a/juick-server/src/main/java/com/juick/service/PushQueriesServiceImpl.java b/juick-server/src/main/java/com/juick/service/PushQueriesServiceImpl.java
new file mode 100644
index 00000000..91861bd9
--- /dev/null
+++ b/juick-server/src/main/java/com/juick/service/PushQueriesServiceImpl.java
@@ -0,0 +1,70 @@
+package com.juick.service;
+
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.StringUtils;
+
+import javax.inject.Inject;
+import java.util.List;
+
+/**
+ * Created by aalexeev on 11/13/16.
+ */
+@Repository
+@Transactional(readOnly = true)
+public class PushQueriesServiceImpl extends BaseJdbcService implements PushQueriesService {
+
+ @Inject
+ public PushQueriesServiceImpl(JdbcTemplate jdbcTemplate) {
+ super(jdbcTemplate, null);
+ }
+
+ @Override
+ public List<String> getAndroidRegID(final int uid) {
+ return getJdbcTemplate().queryForList(
+ "SELECT regid FROM android WHERE user_id=?",
+ String.class,
+ uid);
+ }
+
+ @Override
+ public List<String> getAndroidTokens(final List<Integer> uids) {
+ return getJdbcTemplate().queryForList(
+ "SELECT regid FROM android INNER JOIN users " +
+ "ON (users.id=android.user_id) WHERE users.id IN (" + StringUtils.collectionToCommaDelimitedString(uids) + ")",
+ String.class);
+ }
+
+ @Override
+ public List<String> getWinPhoneURL(final int uid) {
+ return getJdbcTemplate().queryForList(
+ "SELECT url FROM winphone WHERE user_id=?",
+ String.class,
+ uid);
+ }
+
+ @Override
+ public List<String> getWindowsTokens(final List<Integer> uids) {
+ return getJdbcTemplate().queryForList(
+ "SELECT url FROM winphone INNER JOIN users " +
+ "ON (users.id=winphone.user_id) WHERE users.id IN (" + StringUtils.collectionToCommaDelimitedString(uids) + ")",
+ String.class);
+ }
+
+ @Override
+ public List<String> getAPNSToken(final int uid) {
+ return getJdbcTemplate().queryForList(
+ "SELECT token from ios WHERE user_id=?",
+ String.class,
+ uid);
+ }
+
+ @Override
+ public List<String> getAPNSTokens(final List<Integer> uids) {
+ return getJdbcTemplate().queryForList(
+ "SELECT token FROM ios INNER JOIN users " +
+ "ON (users.id=ios.user_id) WHERE users.id IN (" + StringUtils.collectionToCommaDelimitedString(uids) + ")",
+ String.class);
+ }
+}