From f08abdf936c6ebc303f1ade8d7bbc8dbe4c77708 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 23 Oct 2023 10:19:13 +0300 Subject: jdbc: row mapper usage refactoring --- src/main/java/com/juick/service/MessagesServiceImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/main/java/com/juick/service/MessagesServiceImpl.java') diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java index fc190c97..8b729c60 100644 --- a/src/main/java/com/juick/service/MessagesServiceImpl.java +++ b/src/main/java/com/juick/service/MessagesServiceImpl.java @@ -127,6 +127,8 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ } } + private final MessageMapper messageMapper = new MessageMapper(); + /** * @see Java, @@ -817,7 +819,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ subscr_messages.last_read_rid, users.premium"""; List msgs = getNamedParameterJdbcTemplate().query(query, new MapSqlParameterSource("ids", mids) - .addValue("uid", uid), new MessageMapper()); + .addValue("uid", uid), messageMapper); Map> likes = updateReactionsFor(mids); msgs.forEach(i -> i.setReactions(likes.get(i.getMid()))); msgs.sort(Comparator.comparing(item -> mids.indexOf(item.getMid()))); @@ -887,7 +889,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ .addValue("mid", mid) .addValue("uid", user.getUid()) .addValue("now", toDateTime(Instant.now().atOffset(ZoneOffset.UTC)), dateTimeType()), - new MessageMapper()); + messageMapper); replies.forEach(i -> { i.setEntities(MessageUtils.getEntities(i)); i.getUser().setAvatar(webApp.getAvatarUrl(i.getUser())); -- cgit v1.2.3