From dafee9c471e154e375cca19f5e96c9c6fc89033f Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 26 Feb 2019 14:48:02 +0300 Subject: Display federated likes --- src/main/java/com/juick/Message.java | 6 +++--- src/main/java/com/juick/service/MessagesService.java | 2 +- src/main/java/com/juick/service/MessagesServiceImpl.java | 14 ++++++++++---- 3 files changed, 14 insertions(+), 8 deletions(-) (limited to 'src/main/java/com/juick') diff --git a/src/main/java/com/juick/Message.java b/src/main/java/com/juick/Message.java index 00527b41..617ed834 100644 --- a/src/main/java/com/juick/Message.java +++ b/src/main/java/com/juick/Message.java @@ -81,7 +81,7 @@ public class Message implements Comparable { private URI replyToUri; private boolean html; - private Set recommendations; + private Set recommendations; private List entities; @@ -333,11 +333,11 @@ public class Message implements Comparable { this.service = service; } - public Set getRecommendations() { + public Set getRecommendations() { return recommendations; } - public void setRecommendations(Set recommendations) { + public void setRecommendations(Set recommendations) { this.recommendations = recommendations; } diff --git a/src/main/java/com/juick/service/MessagesService.java b/src/main/java/com/juick/service/MessagesService.java index 4bcdba46..37da98a8 100644 --- a/src/main/java/com/juick/service/MessagesService.java +++ b/src/main/java/com/juick/service/MessagesService.java @@ -68,7 +68,7 @@ public interface MessagesService { User getMessageAuthor(int mid); - List getMessageRecommendations(int mid); + List getMessageRecommendations(int mid); List getAll(int visitorUid, int before); diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java index c3d319d5..01e96d6e 100644 --- a/src/main/java/com/juick/service/MessagesServiceImpl.java +++ b/src/main/java/com/juick/service/MessagesServiceImpl.java @@ -477,15 +477,21 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ @Transactional(readOnly = true) @Override - public List getMessageRecommendations(final int mid) { - return getJdbcTemplate().queryForList( - "SELECT DISTINCT users.nick FROM favorites " + + public List getMessageRecommendations(final int mid) { + return getJdbcTemplate().query( + "SELECT DISTINCT users.id, users.nick, favorites.user_uri FROM favorites " + "INNER JOIN users ON (favorites.message_id = ? AND favorites.user_id = users.id) " + "INNER JOIN messages m ON favorites.message_id=m.message_id WHERE favorites.like_id=1 " + "AND NOT EXISTS (SELECT 1 FROM bl_users WHERE " + "(user_id = favorites.user_id AND bl_user_id = m.user_id) " + "OR (user_id = m.user_id AND bl_user_id = favorites.user_id))", - String.class, mid); + (rs, rowNum) -> { + User user = new User(); + user.setUid(rs.getInt(1)); + user.setName(rs.getString(2)); + user.setUri(URI.create(rs.getString(3))); + return user; + }, mid); } @Transactional(readOnly = true) -- cgit v1.2.3