aboutsummaryrefslogtreecommitdiff
path: root/juick-server-jdbc/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-03-14 10:04:40 +0300
committerGravatar Vitaly Takmazov2018-03-14 10:04:40 +0300
commitb2f3afebc7de684d1d49042f5f79a9cbf9c1f2f2 (patch)
treeb7d5c7ca5b728751fa16d0085486b305da87d61d /juick-server-jdbc/src/main/java/com
parentb1e8980ed1460340fe4e8db2ce0d7ee1d213854a (diff)
refactor email settings
Diffstat (limited to 'juick-server-jdbc/src/main/java/com')
-rw-r--r--juick-server-jdbc/src/main/java/com/juick/service/EmailServiceImpl.java8
-rw-r--r--juick-server-jdbc/src/main/java/com/juick/service/UserServiceImpl.java12
2 files changed, 8 insertions, 12 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 1921354a..0cccc915 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
@@ -68,6 +68,14 @@ public class EmailServiceImpl extends BaseJdbcService implements EmailService {
.addValue("email", account)) > 0;
}
+ @Transactional(readOnly = true)
+ @Override
+ public String getNotificationsEmail(Integer userId) {
+ List<String> list = getJdbcTemplate().queryForList(
+ "SELECT email FROM emails WHERE user_id=? AND subscr_hour IS NOT NULL", String.class, userId);
+ return list.isEmpty() ? StringUtils.EMPTY : list.get(0);
+ }
+
@Override
public boolean setNotificationsEmail(Integer userId, String account) {
getJdbcTemplate().update("UPDATE emails SET subscr_hour=NULL WHERE user_id=?", userId);
diff --git a/juick-server-jdbc/src/main/java/com/juick/service/UserServiceImpl.java b/juick-server-jdbc/src/main/java/com/juick/service/UserServiceImpl.java
index 770819ec..3f7cebf6 100644
--- a/juick-server-jdbc/src/main/java/com/juick/service/UserServiceImpl.java
+++ b/juick-server-jdbc/src/main/java/com/juick/service/UserServiceImpl.java
@@ -20,13 +20,11 @@ package com.juick.service;
import com.juick.User;
import com.juick.server.helpers.AnonymousUser;
import com.juick.server.helpers.Auth;
-import com.juick.server.helpers.EmailOpts;
import com.juick.server.helpers.UserInfo;
import com.juick.server.util.HashUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.dao.DuplicateKeyException;
-import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.support.GeneratedKeyHolder;
@@ -34,7 +32,6 @@ import org.springframework.jdbc.support.KeyHolder;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
-import javax.inject.Inject;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -629,15 +626,6 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
@Transactional(readOnly = true)
@Override
- public EmailOpts getEmailOpts(final User user) {
- List<EmailOpts> list = getJdbcTemplate().query(
- "SELECT email,subscr_hour FROM emails WHERE user_id=? AND subscr_hour IS NOT NULL",
- (rs, num) -> new EmailOpts(rs.getString(1), rs.getInt(2)), user.getUid());
- return list.isEmpty() ? new EmailOpts("", 0) : list.get(0);
- }
-
- @Transactional(readOnly = true)
- @Override
public String getEmailHash(final User user) {
List<String> list = getJdbcTemplate().queryForList(
"SELECT hash FROM mail WHERE user_id = ?",