diff options
Diffstat (limited to 'juick-server/src/main/java/com/juick')
-rw-r--r-- | juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java | 32 |
1 files changed, 10 insertions, 22 deletions
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 6f33bbf3a..25ce61fbc 100644 --- a/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java +++ b/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java @@ -83,11 +83,6 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ } /** - * @param uid - * @param txt - * @param attachment - * @param tags - * @return * @see <a href="https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-type-conversions.html">Java, JDBC and MySQL Types</a> */ @Transactional @@ -129,7 +124,6 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ tasNamesBuilder.append(tag.getName()); params.add(new Object[]{mid, tag.TID}); } - tagsNames = tasNamesBuilder.toString(); getJdbcTemplate().batchUpdate( @@ -169,7 +163,6 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ getJdbcTemplate().update( "UPDATE messages SET replies = replies + 1 WHERE message_id = ?", mid); - return ridnew; } @@ -211,11 +204,10 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ "INSERT IGNORE INTO favorites(user_id, message_id) VALUES (?, ?)", vuid, mid) == 1; - if (res) { + if (res) getJdbcTemplate().update( "UPDATE messages SET likes = likes + 1 WHERE message_id = ?", mid); - } return res; } @@ -234,8 +226,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ }, mid); - PrivacyOpts privacyOpts = list.isEmpty() ? - null : list.get(0); + PrivacyOpts privacyOpts = list.isEmpty() ? null : list.get(0); return privacyOpts == null || privacyOpts.getPrivacy() >= 0 || @@ -252,7 +243,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ new Object[]{mid}, Integer.class); - return !list.isEmpty() || list.get(0) == 1; + return !list.isEmpty() && list.get(0) == 1; } @Transactional(readOnly = true) @@ -263,7 +254,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ new Object[]{uid, mid}, Integer.class); - return !list.isEmpty() || list.get(0) == 1; + return !list.isEmpty() && list.get(0) == 1; } @Transactional(readOnly = true) @@ -274,8 +265,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ new Object[]{mid}, Integer.class); - return list.isEmpty() ? - -4 : list.get(0); + return list.isEmpty() ? -4 : list.get(0); } @Transactional(readOnly = true) @@ -297,8 +287,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ new MessageMapper(), mid); - return list.isEmpty() ? - null : list.get(0); + return list.isEmpty() ? null : list.get(0); } @Transactional(readOnly = true) @@ -334,8 +323,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ }, mid, rid); - return list.isEmpty() ? - null : list.get(0); + return list.isEmpty() ? null : list.get(0); } @Transactional(readOnly = true) @@ -427,7 +415,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ "INNER JOIN messages USING(message_id) WHERE " + (before > 0 ? " messages.message_id < :before AND " : "") + - " 1 = 1 AND (messages.privacy > 0 OR messages.user_id = :visitorUid) ORDER BY message_id DESC LIMIT :cnt", + "(messages.privacy > 0 OR messages.user_id = :visitorUid) ORDER BY message_id DESC LIMIT :cnt", sqlParameterSource, Integer.class); } @@ -582,7 +570,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ @Transactional(readOnly = true) @Override public List<Integer> getSearch(final String search, final int before) { - List<Integer> mids = searchService.getMessageIdsInAllMessages(search, before); + List<Integer> mids = searchService.searchInAllMessages(search, before); if (!mids.isEmpty()) return getNamedParameterJdbcTemplate().queryForList( @@ -665,7 +653,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ @Transactional(readOnly = true) @Override public List<Integer> getUserSearch(final JdbcTemplate sqlSearch, final int UID, final String search, final int privacy, final int before) { - List<Integer> mids = searchService.getMessageIdsByUser(search, UID, before); + List<Integer> mids = searchService.searchByStringAndUser(search, UID, before); if (!mids.isEmpty()) { return getNamedParameterJdbcTemplate().queryForList( |