diff options
Diffstat (limited to 'src/main/java/com/juick/service')
4 files changed, 9 insertions, 59 deletions
diff --git a/src/main/java/com/juick/service/MessagesService.java b/src/main/java/com/juick/service/MessagesService.java index bb12a61e..5e3a1e83 100644 --- a/src/main/java/com/juick/service/MessagesService.java +++ b/src/main/java/com/juick/service/MessagesService.java @@ -85,8 +85,6 @@ public interface MessagesService { List<Integer> getRecommended(int uid, int before); - List<Integer> getPopular(int visitorUid, int before); - List<Integer> getPhotos(int visitorUid, int before); List<Integer> getSearch(User visitor, String search, int page); @@ -97,7 +95,7 @@ public interface MessagesService { List<Integer> getUserBlogAtDay(int uid, int privacy, int daysback); - List<Integer> getUserBlogWithRecommendations(int uid, int privacy, int before); + List<Integer> getUserBlogWithRecommendations(User user, User visitor, int privacy, int before); List<Integer> getUserRecommendations(int uid, int before); @@ -111,8 +109,6 @@ public interface MessagesService { List<Message> getReplies(User user, int mid); - boolean setMessagePopular(int mid, int popular); - boolean setMessagePrivacy(int mid); boolean deleteMessage(int uid, int mid); diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java index c2e5d15d..0625716a 100644 --- a/src/main/java/com/juick/service/MessagesServiceImpl.java +++ b/src/main/java/com/juick/service/MessagesServiceImpl.java @@ -623,20 +623,6 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ @Transactional(readOnly = true) @Override - public List<Integer> getPopular(final int visitorUid, final int before) { - SqlParameterSource sqlParameterSource = new MapSqlParameterSource().addValue("vid", visitorUid) - .addValue("before", before); - - return getNamedParameterJdbcTemplate().queryForList("SELECT m.message_id FROM messages m WHERE m.privacy > 0 " - + (before > 0 ? " AND m.message_id < :before " : StringUtils.EMPTY) - + " AND m.popular > 0 AND NOT EXISTS (SELECT 1 FROM bl_users b WHERE b.user_id = :vid and b.bl_user_id = m.user_id) " - + " AND NOT EXISTS (SELECT 1 FROM bl_tags bt WHERE bt.tag_id IN " - + "(SELECT tag_id FROM messages_tags WHERE message_id = m.message_id) and :vid = bt.user_id)" - + " ORDER BY m.message_id DESC LIMIT 20", sqlParameterSource, Integer.class); - } - - @Transactional(readOnly = true) - @Override public List<Integer> getPhotos(final int visitorUid, final int before) { SqlParameterSource sqlParameterSource = new MapSqlParameterSource().addValue("vid", visitorUid) .addValue("before", before); @@ -705,9 +691,11 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ @Transactional(readOnly = true) @Override - public List<Integer> getUserBlogWithRecommendations(final int uid, final int privacy, final int before) { - SqlParameterSource sqlParameterSource = new MapSqlParameterSource().addValue("uid", uid) - .addValue("privacy", privacy).addValue("before", before); + public List<Integer> getUserBlogWithRecommendations(final User user, final User visitor, final int privacy, final int before) { + SqlParameterSource sqlParameterSource = new MapSqlParameterSource() + .addValue("uid", user.getUid()) + .addValue("vid", visitor.getUid()) + .addValue("privacy", privacy).addValue("before", before); return getNamedParameterJdbcTemplate() .queryForList("SELECT message_id FROM " + "(SELECT message_id FROM favorites " + " INNER JOIN users" @@ -716,6 +704,9 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ + " ORDER BY message_id DESC LIMIT 20) as r" + " UNION ALL " + "SELECT message_id FROM " + "(SELECT message_id FROM messages" + " INNER JOIN users" + " ON messages.user_id = users.id" + " WHERE user_id = :uid AND users.banned = 0" + + " AND NOT EXISTS (SELECT 1 FROM bl_users b WHERE b.user_id = :vid and b.bl_user_id = messages.user_id) " + + " AND NOT EXISTS (SELECT 1 FROM bl_tags bt WHERE bt.tag_id IN " + + "(SELECT tag_id FROM messages_tags WHERE message_id = messages.message_id) and :vid = bt.user_id)" + (before > 0 ? " AND message_id < :before" : StringUtils.EMPTY) + " AND privacy >= :privacy ORDER BY message_id DESC LIMIT 20) as m " + "ORDER BY message_id DESC LIMIT 20", sqlParameterSource, Integer.class); @@ -870,33 +861,6 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ @Transactional @Override - public boolean setMessagePopular(final int mid, final int popular) { - int ret; - MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource().addValue("mid", mid).addValue("popular", - popular); - - switch (popular) { - case -2: - ret = getNamedParameterJdbcTemplate().update("UPDATE messages SET hidden = 1 WHERE message_id = :mid", - sqlParameterSource); - break; - case -1: - sqlParameterSource.addValue("popular", 0); - default: - ret = getNamedParameterJdbcTemplate() - .update("UPDATE messages SET popular = :popular WHERE message_id = :mid", sqlParameterSource); - break; - } - - if (popular == -1) - ret = getNamedParameterJdbcTemplate().update("INSERT INTO top_ignore_messages VALUES (:mid)", - sqlParameterSource); - - return ret > 0; - } - - @Transactional - @Override public boolean setMessagePrivacy(final int mid) { return getJdbcTemplate().update("UPDATE messages SET privacy=1 WHERE message_id=?", mid) > 0; } diff --git a/src/main/java/com/juick/service/UserService.java b/src/main/java/com/juick/service/UserService.java index dc879821..c0428169 100644 --- a/src/main/java/com/juick/service/UserService.java +++ b/src/main/java/com/juick/service/UserService.java @@ -131,8 +131,6 @@ public interface UserService { boolean isAdminUser(User user); - boolean isServiceUser(User user); - Optional<ExternalToken> getTwitterToken(int uid); boolean deleteTwitterToken(Integer uid); diff --git a/src/main/java/com/juick/service/UserServiceImpl.java b/src/main/java/com/juick/service/UserServiceImpl.java index 9762802f..e73f4ea3 100644 --- a/src/main/java/com/juick/service/UserServiceImpl.java +++ b/src/main/java/com/juick/service/UserServiceImpl.java @@ -60,9 +60,6 @@ public class UserServiceImpl extends BaseJdbcService implements UserService { @Value("${juick.admin_users:}") List<String> adminUsers; - @Value("${service_user:juick}") - private String serviceUser; - private class UserMapper implements RowMapper<User> { @Override public User mapRow(@Nonnull ResultSet rs, int rowNum) throws SQLException { @@ -669,11 +666,6 @@ public class UserServiceImpl extends BaseJdbcService implements UserService { public boolean isAdminUser(User user) { return adminUsers.contains(user.getName()); } - - @Override - public boolean isServiceUser(User user) { - return user.getName().equals(serviceUser); - } @Transactional(readOnly = true) @Override |