aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/service/MessagesServiceImpl.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2023-02-03 04:22:50 +0300
committerGravatar Vitaly Takmazov2023-02-03 04:22:50 +0300
commit73b8c2dc544df207d8c7b9e36d20955ff1d88577 (patch)
treef5c25f04ca48157dd1ebe6ff7dbd5992a6de9aaa /src/main/java/com/juick/service/MessagesServiceImpl.java
parent26ef36070cb02bb6522a347d8692b6534d550a7c (diff)
Make SQL vendor queries private
Diffstat (limited to 'src/main/java/com/juick/service/MessagesServiceImpl.java')
-rw-r--r--src/main/java/com/juick/service/MessagesServiceImpl.java6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java
index eb1acd59..c5b29fd5 100644
--- a/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -789,8 +789,8 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
@Override
public List<Message> getMessages(int uid, final List<Integer> mids) {
if (CollectionUtils.isNotEmpty(mids)) {
- var query = (omitRecursiveKeyword ? "WITH " : "WITH RECURSIVE ") + """
- banned(message_id, reply_id)
+ var query = withRecursive() + """
+ banned(message_id, reply_id)
AS (SELECT message_id, reply_id FROM replies WHERE replies.message_id IN (:ids)
AND (EXISTS (SELECT 1 FROM bl_users b WHERE b.user_id = :uid AND b.bl_user_id = replies.user_id)
OR EXISTS (SELECT 1 from users u WHERE u.banned = 1 and u.id = replies.user_id and u.id <> :uid))
@@ -882,7 +882,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
@Transactional
@Override
public List<Message> getReplies(final User user, final int mid) {
- List<Message> replies = getNamedParameterJdbcTemplate().query((omitRecursiveKeyword ? "WITH " : "WITH RECURSIVE ") + "banned(reply_id, user_id) AS ("
+ List<Message> replies = getNamedParameterJdbcTemplate().query(withRecursive() + " banned(reply_id, user_id) AS ("
+ "SELECT reply_id, user_id FROM replies " + "WHERE replies.message_id = :mid "
+ "AND EXISTS (SELECT 1 FROM bl_users b WHERE b.user_id = :uid AND b.bl_user_id = replies.user_id) "
+ "UNION ALL SELECT replies.reply_id, replies.user_id FROM replies "