From 779024f65c14436b48e015eaaef0f4956bd5aa8a Mon Sep 17 00:00:00 2001 From: Evgeniy Shishkin Date: Thu, 9 Mar 2017 16:25:30 +0300 Subject: timehop api --- .../main/java/com/juick/service/MessagesService.java | 2 ++ .../java/com/juick/service/MessagesServiceImpl.java | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) (limited to 'juick-server/src') 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 getUserTag(int uid, int tid, int privacy, int before); + List getUserBlogAtDay(int uid, int privacy, int daysback); + List getUserBlogWithRecommendations(int uid, int privacy, int before); List 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 @@ -588,6 +588,24 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ Integer.class); } + @Transactional(readOnly = true) + @Override + public List 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 getUserBlogWithRecommendations(final int uid, final int privacy, final int before) { -- cgit v1.2.3