aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/service/UserServiceImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/service/UserServiceImpl.java')
-rw-r--r--src/main/java/com/juick/service/UserServiceImpl.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main/java/com/juick/service/UserServiceImpl.java b/src/main/java/com/juick/service/UserServiceImpl.java
index ab947bac..69ca7569 100644
--- a/src/main/java/com/juick/service/UserServiceImpl.java
+++ b/src/main/java/com/juick/service/UserServiceImpl.java
@@ -783,6 +783,22 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
return list.isEmpty() ?
StringUtils.EMPTY : list.get(0);
}
+ @Override
+ @Transactional(readOnly = true)
+ public Optional<User> getUserByTelegramId(Long id) {
+ List<User> list = getJdbcTemplate().query(
+ """
+ SELECT DISTINCT u.id, u.nick, u.passw, u.banned, u.last_seen,
+ COALESCE(f.fb_id, vk.vk_id, t.tg_id, e.user_id, 0) AS verified
+ FROM users u LEFT JOIN facebook f ON f.user_id = u.id
+ LEFT JOIN vk ON u.id = vk.user_id LEFT JOIN telegram t ON u.id = t.user_id
+ LEFT JOIN emails e ON e.user_id = u.id
+ WHERE t.tg_id = ?""",
+ new UserMapper(), id
+ );
+
+ return list.isEmpty() ? Optional.empty() : Optional.of(list.get(0));
+ }
@Transactional(readOnly = true)
@Override