aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--juick-api/src/main/java/com/juick/api/controllers/Messages.java3
-rw-r--r--juick-server/src/main/java/com/juick/service/MessagesService.java2
-rw-r--r--juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java18
3 files changed, 23 insertions, 0 deletions
diff --git a/juick-api/src/main/java/com/juick/api/controllers/Messages.java b/juick-api/src/main/java/com/juick/api/controllers/Messages.java
index 7348c54a..5863ec5f 100644
--- a/juick-api/src/main/java/com/juick/api/controllers/Messages.java
+++ b/juick-api/src/main/java/com/juick/api/controllers/Messages.java
@@ -69,6 +69,7 @@ public class Messages {
public ResponseEntity<List<com.juick.Message>> getMessages(
@RequestParam(required = false) String uname,
@RequestParam(defaultValue = "0") int before_mid,
+ @RequestParam(required = false, defaultValue = "0") int daysback,
@RequestParam(required = false) String withrecommended,
@RequestParam(required = false) String popular,
@RequestParam(required = false) String media,
@@ -91,6 +92,8 @@ public class Messages {
}
} else if (!StringUtils.isEmpty(withrecommended)) {
mids = messagesService.getUserBlogWithRecommendations(user.getUid(), 0, before_mid);
+ } else if (!StringUtils.isEmpty(daysback)) {
+ mids = messagesService.getUserBlogAtDay(user.getUid(), 0, daysback);
} else {
mids = messagesService.getUserBlog(user.getUid(), 0, before_mid);
}
diff --git a/juick-server/src/main/java/com/juick/service/MessagesService.java b/juick-server/src/main/java/com/juick/service/MessagesService.java
index ad7774b7..8948f083 100644
--- a/juick-server/src/main/java/com/juick/service/MessagesService.java
+++ b/juick-server/src/main/java/com/juick/service/MessagesService.java
@@ -62,6 +62,8 @@ public interface MessagesService {
List<Integer> getUserTag(int uid, int tid, int privacy, int before);
+ List<Integer> getUserBlogAtDay(int uid, int privacy, int daysback);
+
List<Integer> getUserBlogWithRecommendations(int uid, int privacy, int before);
List<Integer> getUserRecommendations(int uid, int before);
diff --git a/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java b/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java
index 0a35cee9..11ea0cbf 100644
--- a/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -590,6 +590,24 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
@Transactional(readOnly = true)
@Override
+ public List<Integer> getUserBlogAtDay(final int uid, final int privacy, final int daysback) {
+ SqlParameterSource sqlParameterSource = new MapSqlParameterSource()
+ .addValue("uid", uid)
+ .addValue("privacy", privacy)
+ .addValue("daysback", daysback);
+
+ return getNamedParameterJdbcTemplate().queryForList(
+ "SELECT message_id FROM messages WHERE user_id = :uid" +
+ (daysback > 0 ?
+ " AND ts >= date(NOW() - INTERVAL :daysback day)" +
+ " AND ts < date(NOW() - INTERVAL :daysback day + INTERVAL 1 day)" : StringUtils.EMPTY) +
+ " AND privacy >= :privacy ORDER BY message_id DESC LIMIT 20",
+ sqlParameterSource,
+ Integer.class);
+ }
+
+ @Transactional(readOnly = true)
+ @Override
public List<Integer> getUserBlogWithRecommendations(final int uid, final int privacy, final int before) {
SqlParameterSource sqlParameterSource = new MapSqlParameterSource()
.addValue("uid", uid)