aboutsummaryrefslogtreecommitdiff
path: root/juick-server-jdbc/src/main
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-12-25 12:55:10 +0300
committerGravatar Vitaly Takmazov2017-12-25 12:55:10 +0300
commite3a9e8a42bf980751db5f75c63ef9e17ab1ea8dc (patch)
tree3e7106a4883907368e60bd6372e809c27606afc4 /juick-server-jdbc/src/main
parentd767b84a27b6864897bbfbd8c9250550975c5d45 (diff)
add email from facebook
Diffstat (limited to 'juick-server-jdbc/src/main')
-rw-r--r--juick-server-jdbc/src/main/java/com/juick/service/EmailServiceImpl.java11
1 files changed, 8 insertions, 3 deletions
diff --git a/juick-server-jdbc/src/main/java/com/juick/service/EmailServiceImpl.java b/juick-server-jdbc/src/main/java/com/juick/service/EmailServiceImpl.java
index a8c0595e..0cbaec00 100644
--- a/juick-server-jdbc/src/main/java/com/juick/service/EmailServiceImpl.java
+++ b/juick-server-jdbc/src/main/java/com/juick/service/EmailServiceImpl.java
@@ -43,7 +43,7 @@ public class EmailServiceImpl extends BaseJdbcService implements EmailService {
try {
String address = getJdbcTemplate().queryForObject("SELECT account FROM auth WHERE user_id=? AND protocol='email' AND authcode=?",
String.class, userId, code);
- getJdbcTemplate().update("INSERT INTO emails(user_id,email) VALUES (?,?)", userId, address);
+ addEmail(userId, address);
getJdbcTemplate().update("DELETE FROM auth WHERE user_id=? AND authcode=?", userId, code);
} catch (EmptyResultDataAccessException e) {
return false;
@@ -58,6 +58,11 @@ public class EmailServiceImpl extends BaseJdbcService implements EmailService {
}
@Override
+ public boolean addEmail(Integer userId, String email) {
+ return getJdbcTemplate().update("INSERT INTO emails(user_id,email) VALUES (?,?)", userId, email) > 0;
+ }
+
+ @Override
public boolean deleteEmail(Integer userId, String account) {
return getNamedParameterJdbcTemplate().update("DELETE FROM emails " +
"WHERE (SELECT COUNT(*) cnt FROM (select user_id, email FROM emails e) c WHERE user_id=:uid) > 1 " +
@@ -76,8 +81,8 @@ public class EmailServiceImpl extends BaseJdbcService implements EmailService {
@Transactional(readOnly = true)
@Override
- public List<String> getEmails(Integer userId) {
+ public List<String> getEmails(Integer userId, boolean active) {
return getJdbcTemplate().queryForList("SELECT email FROM emails WHERE user_id=? " +
- "AND subscr_hour IS NOT NULL", String.class, userId);
+ (active ? "AND subscr_hour IS NOT NULL" : ""), String.class, userId);
}
}