diff options
author | Alexander Alexeev | 2016-11-18 01:38:11 +0700 |
---|---|---|
committer | Vitaly Takmazov | 2016-11-23 13:02:58 +0300 |
commit | d64b673c0d69309ff7ad75ffd1d3d7c3f664c8a1 (patch) | |
tree | d8e7eb964cececa686297e4c4a3142fa5ffa24e5 | |
parent | 36f0ced4b46a1823a15d3e33e664891c92618b78 (diff) |
bugfixes
-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 6f33bbf3..25ce61fb 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( |