aboutsummaryrefslogtreecommitdiff
path: root/juick-server-jdbc/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server-jdbc/src/main/java/com')
-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);
}
}