aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/api/Others.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-07-07 15:16:21 +0300
committerGravatar Vitaly Takmazov2016-07-07 15:16:21 +0300
commite5c286017b59a0862f2ccc4d9f905d8a3b0008ac (patch)
tree6522c6c00f64491fb1c9aca7cc8f36ad3c581954 /src/main/java/com/juick/api/Others.java
parente5c8298beee5dde90ca98cc4707faac4bf0e2f0c (diff)
parenta2d11294adca359bb6f7021a9b5db13647b5f504 (diff)
merge api
Diffstat (limited to 'src/main/java/com/juick/api/Others.java')
-rw-r--r--src/main/java/com/juick/api/Others.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/main/java/com/juick/api/Others.java b/src/main/java/com/juick/api/Others.java
new file mode 100644
index 00000000..12849f90
--- /dev/null
+++ b/src/main/java/com/juick/api/Others.java
@@ -0,0 +1,53 @@
+package com.juick.api;
+
+import com.juick.User;
+import com.juick.json.UserSerializer;
+import com.juick.server.PMQueries;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.sql.Connection;
+import java.util.List;
+
+/**
+ *
+ * @author ugnich
+ */
+public class Others {
+
+ JdbcTemplate sql;
+
+ UserSerializer userSerializer = new UserSerializer();
+
+ public Others(JdbcTemplate sql) {
+ this.sql = sql;
+ }
+
+ public void doGetGroupsPMs(HttpServletRequest request,
+ HttpServletResponse response, int vuid)
+ throws ServletException, IOException {
+ int cnt = 5;
+ try {
+ String cntStr = request.getParameter("cnt");
+ cnt = Integer.parseInt(cntStr);
+ if (cnt < 3) {
+ cnt = 3;
+ }
+ if (cnt > 10) {
+ cnt = 10;
+ }
+ } catch (Exception e) {
+ }
+
+ List<User> lastconv = PMQueries.getPMLastConversationsUsers(sql, vuid, cnt);
+ if (lastconv != null && !lastconv.isEmpty()) {
+ String json = "{\"pms\":" + userSerializer.serializeList(lastconv) + "}";
+ Main.replyJSON(request, response, json);
+ } else {
+ response.sendError(404);
+ }
+ }
+}