aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/service/ChatServiceImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/service/ChatServiceImpl.java')
-rw-r--r--src/main/java/com/juick/service/ChatServiceImpl.java11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/main/java/com/juick/service/ChatServiceImpl.java b/src/main/java/com/juick/service/ChatServiceImpl.java
index d1c4ce96..c0d2f17b 100644
--- a/src/main/java/com/juick/service/ChatServiceImpl.java
+++ b/src/main/java/com/juick/service/ChatServiceImpl.java
@@ -56,7 +56,7 @@ public class ChatServiceImpl extends BaseJdbcService implements ChatService {
Chat u = new Chat();
u.setUid(rs.getInt(1));
u.setName(rs.getString(2));
- u.setLastMessageTimestamp(rs.getTimestamp(3).toInstant());
+ u.setLastMessageTimestamp(getOffsetDateTime(rs,3).toInstant());
u.setLastMessageText(rs.getString(4).trim());
return u;
},
@@ -72,7 +72,7 @@ public class ChatServiceImpl extends BaseJdbcService implements ChatService {
return getNamedParameterJdbcTemplate().query(
"SELECT pm.user_id, pm.txt, pm.ts, users.nick FROM pm INNER JOIN users ON users.id=pm.user_id WHERE (user_id = :uid AND user_id_to = :uidTo) "
- + "OR (user_id_to = :uid AND user_id = :uidTo) ORDER BY ts DESC OFFSET 0 ROWS FETCH NEXT 20 ROWS ONLY",
+ + "OR (user_id_to = :uid AND user_id = :uidTo) ORDER BY ts DESC " + limit(20),
sqlParameterSource,
(rs, rowNum) -> {
Message msg = new Message();
@@ -82,7 +82,7 @@ public class ChatServiceImpl extends BaseJdbcService implements ChatService {
user.setName(rs.getString(4));
msg.setUser(user);
msg.setText(rs.getString(2).trim());
- msg.setCreated(rs.getTimestamp(3).toInstant());
+ msg.setCreated(getOffsetDateTime(rs,3).toInstant());
return msg;
});
}
@@ -92,7 +92,8 @@ public class ChatServiceImpl extends BaseJdbcService implements ChatService {
public List<Message> getInbox(final int uid) {
return getJdbcTemplate().query(
"SELECT pm.user_id, users.nick, pm.txt, pm.ts " +
- "FROM pm INNER JOIN users ON pm.user_id=users.id WHERE pm.user_id_to=? ORDER BY pm.ts DESC OFFSET 0 ROWS FETCH NEXT 20 ROWS ONLY",
+ "FROM pm INNER JOIN users ON pm.user_id=users.id WHERE pm.user_id_to=? ORDER BY pm.ts DESC " +
+ limit(20),
(rs, num) -> {
Message msg = new Message();
msg.setUser(new User());
@@ -111,7 +112,7 @@ public class ChatServiceImpl extends BaseJdbcService implements ChatService {
return getJdbcTemplate().query(
"SELECT pm.user_id_to, users.nick, pm.txt, " +
"pm.ts FROM pm INNER JOIN users ON pm.user_id_to=users.id " +
- "WHERE pm.user_id=? ORDER BY pm.ts DESC OFFSET 0 ROWS FETCH NEXT 20 ROWS ONLY",
+ "WHERE pm.user_id=? ORDER BY pm.ts DESC " + limit(20),
(rs, num) -> {
Message msg = new Message();
msg.setUser(new User());