aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-02-26 14:48:02 +0300
committerGravatar Vitaly Takmazov2019-02-26 15:03:20 +0300
commitdafee9c471e154e375cca19f5e96c9c6fc89033f (patch)
tree1f21d9545906fa010d961d55a9090867a7055664 /src/main/java/com
parent8531d6c7dd1acb4fdeddc5bad926b61e492ca1b4 (diff)
Display federated likes
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/juick/Message.java6
-rw-r--r--src/main/java/com/juick/service/MessagesService.java2
-rw-r--r--src/main/java/com/juick/service/MessagesServiceImpl.java14
3 files changed, 14 insertions, 8 deletions
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<String> recommendations;
+ private Set<User> recommendations;
private List<Entity> entities;
@@ -333,11 +333,11 @@ public class Message implements Comparable {
this.service = service;
}
- public Set<String> getRecommendations() {
+ public Set<User> getRecommendations() {
return recommendations;
}
- public void setRecommendations(Set<String> recommendations) {
+ public void setRecommendations(Set<User> 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<String> getMessageRecommendations(int mid);
+ List<User> getMessageRecommendations(int mid);
List<Integer> 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<String> getMessageRecommendations(final int mid) {
- return getJdbcTemplate().queryForList(
- "SELECT DISTINCT users.nick FROM favorites " +
+ public List<User> 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)