diff options
author | Vitaly Takmazov | 2017-10-24 17:18:29 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2017-10-24 22:34:41 +0300 |
commit | de2cc2db73a5de42d9bfaeb92604f28abe2a328a (patch) | |
tree | 352a3d76fcbc987f068527ff043174308a666654 /juick-server-jdbc | |
parent | 881a546bf7a56550eec1e38ce839f47a1cb1a750 (diff) |
crosspost: refactoring
* spring-social
* get tokens via service api
Diffstat (limited to 'juick-server-jdbc')
-rw-r--r-- | juick-server-jdbc/build.gradle | 1 | ||||
-rw-r--r-- | juick-server-jdbc/src/main/java/com/juick/service/CrosspostServiceImpl.java | 12 |
2 files changed, 7 insertions, 6 deletions
diff --git a/juick-server-jdbc/build.gradle b/juick-server-jdbc/build.gradle index a9da3dff..895b36f1 100644 --- a/juick-server-jdbc/build.gradle +++ b/juick-server-jdbc/build.gradle @@ -21,7 +21,6 @@ dependencies { providedCompile "org.slf4j:log4j-over-slf4j:${rootProject.slf4jVersion}" providedCompile "org.slf4j:jul-to-slf4j:${rootProject.slf4jVersion}" - compile "org.apache.httpcomponents:httpclient:4.5.3" providedCompile "org.apache.commons:commons-lang3:3.6" providedCompile "org.apache.commons:commons-collections4:4.1" providedCompile "org.apache.commons:commons-text:1.1" diff --git a/juick-server-jdbc/src/main/java/com/juick/service/CrosspostServiceImpl.java b/juick-server-jdbc/src/main/java/com/juick/service/CrosspostServiceImpl.java index afa23059..dec8db5b 100644 --- a/juick-server-jdbc/src/main/java/com/juick/service/CrosspostServiceImpl.java +++ b/juick-server-jdbc/src/main/java/com/juick/service/CrosspostServiceImpl.java @@ -17,6 +17,7 @@ package com.juick.service; +import com.juick.ExternalToken; import com.juick.server.helpers.ApplicationStatus; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; @@ -42,14 +43,15 @@ public class CrosspostServiceImpl extends BaseJdbcService implements CrosspostSe @Transactional(readOnly = true) @Override - public Optional<Pair<String, String>> getTwitterTokens(final int uid) { - List<Optional<Pair<String, String>>> list = getJdbcTemplate().query( - "SELECT access_token,access_token_secret FROM twitter WHERE user_id = ? AND crosspost = 1", - (rs, num) -> Optional.of(Pair.of(rs.getString(1), rs.getString(2))), + public Optional<ExternalToken> getTwitterToken(final int uid) { + List<ExternalToken> list = getJdbcTemplate().query( + "SELECT uname, access_token, access_token_secret FROM twitter WHERE user_id = ? AND crosspost = 1", + (rs, num) -> new ExternalToken(rs.getString(1), "twitter", + rs.getString(2), rs.getString(3)), uid); return list.isEmpty() ? - Optional.empty() : list.get(0); + Optional.empty() : Optional.of(list.get(0)); } @Transactional |