From 842e903d5b987dd23e82a423bddae75acdea0c9c Mon Sep 17 00:00:00 2001 From: mykhailo.dubovskyi Date: Wed, 18 Apr 2018 15:57:53 +0300 Subject: Like -> Reaction --- juick-common/src/main/java/com/juick/Message.java | 16 ++++++++ juick-common/src/main/java/com/juick/Reaction.java | 45 ++++++++++++++++++++++ .../java/com/juick/service/MessagesService.java | 8 ++++ 3 files changed, 69 insertions(+) create mode 100644 juick-common/src/main/java/com/juick/Reaction.java (limited to 'juick-common/src') diff --git a/juick-common/src/main/java/com/juick/Message.java b/juick-common/src/main/java/com/juick/Message.java index 72a25dfb..45a0fdd4 100644 --- a/juick-common/src/main/java/com/juick/Message.java +++ b/juick-common/src/main/java/com/juick/Message.java @@ -27,7 +27,9 @@ import javax.xml.bind.annotation.*; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import java.time.Instant; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; /** * @author Ugnich Anton @@ -72,9 +74,12 @@ public class Message implements Comparable { private User to; private Recommendation Recommendation; private String replyQuote; + @XmlTransient + private Set reactions; public Message() { tags = new ArrayList<>(); + reactions = new HashSet<>(); } @Override @@ -91,6 +96,7 @@ public class Message implements Comparable { .append("VisitorCanComment", VisitorCanComment) .append("replies", replies) .append("likes", likes) + .append("reactions", reactions) .toString(); } @@ -301,4 +307,14 @@ public class Message implements Comparable { public void setUnread(boolean unread) { this.unread = unread; } + + + @XmlTransient + public Set getReactions() { + return reactions; + } + + public void setReactions(Set reactions) { + this.reactions = reactions; + } } diff --git a/juick-common/src/main/java/com/juick/Reaction.java b/juick-common/src/main/java/com/juick/Reaction.java new file mode 100644 index 00000000..536ac241 --- /dev/null +++ b/juick-common/src/main/java/com/juick/Reaction.java @@ -0,0 +1,45 @@ +package com.juick; + +import org.apache.commons.lang3.builder.ToStringBuilder; + +public class Reaction { + + public static final int LIKE = 1; + + private final int id; + private String description; + private int count; + + public Reaction(int id) { + this.id = id; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("id", getId()) + .append("description", description) + .append("count", count) + .build(); + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + public int getId() { + return id; + } +} diff --git a/juick-common/src/main/java/com/juick/service/MessagesService.java b/juick-common/src/main/java/com/juick/service/MessagesService.java index 34c15271..853e4271 100644 --- a/juick-common/src/main/java/com/juick/service/MessagesService.java +++ b/juick-common/src/main/java/com/juick/service/MessagesService.java @@ -17,11 +17,14 @@ package com.juick.service; +import com.juick.Reaction; import com.juick.User; import com.juick.server.helpers.ResponseReply; import java.util.Collection; import java.util.List; +import java.util.Map; +import java.util.Set; /** * Created by aalexeev on 11/13/16. @@ -41,6 +44,9 @@ public interface MessagesService { RecommendStatus recommendMessage(int mid, int vuid); + RecommendStatus likeMessage(int mid, int vuid, int reactionId); + + boolean canViewThread(int mid, int uid); boolean isReadOnly(int mid); @@ -95,6 +101,8 @@ public interface MessagesService { List getMessages(List mids); + Map> updateReactionsFor(final List mid); + List getReplies(User user, int mid); boolean setMessagePopular(int mid, int popular); -- cgit v1.2.3