From e3a9e8a42bf980751db5f75c63ef9e17ab1ea8dc Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 25 Dec 2017 12:55:10 +0300 Subject: add email from facebook --- .../src/main/java/com/juick/service/EmailServiceImpl.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'juick-server-jdbc') 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; @@ -57,6 +57,11 @@ public class EmailServiceImpl extends BaseJdbcService implements EmailService { userId, account, code) > 0; } + @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 " + @@ -76,8 +81,8 @@ public class EmailServiceImpl extends BaseJdbcService implements EmailService { @Transactional(readOnly = true) @Override - public List getEmails(Integer userId) { + public List 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); } } -- cgit v1.2.3