From d64b673c0d69309ff7ad75ffd1d3d7c3f664c8a1 Mon Sep 17 00:00:00 2001
From: Alexander Alexeev
Date: Fri, 18 Nov 2016 01:38:11 +0700
Subject: bugfixes
---
.../com/juick/service/MessagesServiceImpl.java | 32 +++++++---------------
1 file changed, 10 insertions(+), 22 deletions(-)
(limited to 'juick-server/src/main/java')
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 Java, JDBC and MySQL Types
*/
@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 getSearch(final String search, final int before) {
- List mids = searchService.getMessageIdsInAllMessages(search, before);
+ List 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 getUserSearch(final JdbcTemplate sqlSearch, final int UID, final String search, final int privacy, final int before) {
- List mids = searchService.getMessageIdsByUser(search, UID, before);
+ List mids = searchService.searchByStringAndUser(search, UID, before);
if (!mids.isEmpty()) {
return getNamedParameterJdbcTemplate().queryForList(
--
cgit v1.2.3