From 7d75cabd9ea4c80348d5e98ac08347a204c60fc4 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 20 Jun 2017 09:41:28 +0300 Subject: mail wip --- .../src/main/java/com/juick/service/UserService.java | 2 ++ .../src/main/java/com/juick/service/UserServiceImpl.java | 15 +++++++++++++++ 2 files changed, 17 insertions(+) (limited to 'juick-server/src/main/java/com/juick/service') diff --git a/juick-server/src/main/java/com/juick/service/UserService.java b/juick-server/src/main/java/com/juick/service/UserService.java index 661f386c..7f4bb1fe 100644 --- a/juick-server/src/main/java/com/juick/service/UserService.java +++ b/juick-server/src/main/java/com/juick/service/UserService.java @@ -30,6 +30,8 @@ public interface UserService { User getFullyUserByName(String username); + User getUserByEmail(String email); + List getFullyUsersByNames(Collection usernames); User getUserByJID(String jid); diff --git a/juick-server/src/main/java/com/juick/service/UserServiceImpl.java b/juick-server/src/main/java/com/juick/service/UserServiceImpl.java index 0b8ed13b..1fc72525 100644 --- a/juick-server/src/main/java/com/juick/service/UserServiceImpl.java +++ b/juick-server/src/main/java/com/juick/service/UserServiceImpl.java @@ -141,6 +141,21 @@ public class UserServiceImpl extends BaseJdbcService implements UserService { return null; } + @Override + @Transactional(readOnly = true) + public User getUserByEmail(String email) { + if (StringUtils.isNotBlank(email)) { + List list = getJdbcTemplate().query( + "SELECT id, nick, banned, lang FROM users WHERE id = (SELECT user_id FROM emails WHERE email = ?)", + new UserMapper(), + email); + + if (!list.isEmpty()) + return list.get(0); + } + return AnonymousUser.INSTANCE; + } + @Transactional(readOnly = true) @Override public List getFullyUsersByNames(final Collection usernames) { -- cgit v1.2.3