From d05897b15a84b3ac51fe8f123baeef948a371e24 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Fri, 10 Mar 2017 20:28:32 +0300
Subject: juick-www: using @RequestParam to match juick-api
---
.../main/java/com/juick/www/controllers/User.java | 24 ++++++++--------------
1 file changed, 9 insertions(+), 15 deletions(-)
(limited to 'juick-www/src/main')
diff --git a/juick-www/src/main/java/com/juick/www/controllers/User.java b/juick-www/src/main/java/com/juick/www/controllers/User.java
index 1ab7e691..e84c8913 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/User.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/User.java
@@ -30,6 +30,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
import javax.inject.Inject;
import javax.servlet.ServletException;
@@ -62,7 +63,8 @@ public class User {
@RequestMapping("/{uname}/")
protected void doGetBlog(HttpServletRequest request, HttpServletResponse response,
- @PathVariable String uname) throws IOException {
+ @PathVariable String uname,
+ @RequestParam(required = false, defaultValue = "0") Integer before) throws IOException {
com.juick.User user = userService.getUserByName(uname);
com.juick.User visitor = webApp.getVisitorUser(request, response);
if (user.isBanned()) {
@@ -90,14 +92,6 @@ public class User {
}
}
- int paramBefore = 0;
- String paramBeforeStr = request.getParameter("before");
- if (paramBeforeStr != null) {
- try {
- paramBefore = Integer.parseInt(paramBeforeStr);
- } catch (NumberFormatException e) {
- }
- }
String paramSearch = request.getParameter("search");
if (paramSearch != null && paramSearch.length() > 64) {
@@ -117,20 +111,20 @@ public class User {
if (paramShow == null) {
if (paramTag != null) {
title = "Блог " + user.getName() + ": *" + StringEscapeUtils.escapeHtml4(paramTag.getName());
- mids = messagesService.getUserTag(user.getUid(), paramTag.TID, privacy, paramBefore);
+ mids = messagesService.getUserTag(user.getUid(), paramTag.TID, privacy, before);
} else if (paramSearch != null) {
title = "Блог " + user.getName() + ": " + StringEscapeUtils.escapeHtml4(paramSearch);
- mids = messagesService.getUserSearch(user.getUid(), Utils.encodeSphinx(paramSearch), privacy, paramBefore);
+ mids = messagesService.getUserSearch(user.getUid(), Utils.encodeSphinx(paramSearch), privacy, before);
} else {
title = "Блог " + user.getName();
- mids = messagesService.getUserBlog(user.getUid(), privacy, paramBefore);
+ mids = messagesService.getUserBlog(user.getUid(), privacy, before);
}
} else if (paramShow.equals("recomm")) {
title = "Рекомендации " + user.getName();
- mids = messagesService.getUserRecommendations(user.getUid(), paramBefore);
+ mids = messagesService.getUserRecommendations(user.getUid(), before);
} else if (paramShow.equals("photos")) {
title = "Фотографии " + user.getName();
- mids = messagesService.getUserPhotos(user.getUid(), privacy, paramBefore);
+ mids = messagesService.getUserPhotos(user.getUid(), privacy, before);
} else {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
@@ -142,7 +136,7 @@ public class User {
user.getName() + "\" href=\"//rss.juick.com/" + user.getName() + "/blog\"/>";
if (paramTag != null && tagService.getTagNoIndex(paramTag.TID)) {
head += "";
- } else if (paramBefore > 0 || paramShow != null) {
+ } else if (before > 0 || paramShow != null) {
head += "";
}
templates.pageHead(out, visitor, title, head);
--
cgit v1.2.3