aboutsummaryrefslogtreecommitdiff
path: root/juick-server-jdbc/src/main/java/com/juick/service
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-10-12 12:55:15 +0300
committerGravatar Vitaly Takmazov2017-10-12 12:55:15 +0300
commit5439a0fa2fd0d778561e20f089af7dd9de7a5511 (patch)
tree3579c8bd3814f64374034ae9a232c9b0bcf8d417 /juick-server-jdbc/src/main/java/com/juick/service
parent753d79d6bbabfdac33c6c382717fe0acaec2a3bd (diff)
api: fill uname in /pm
Diffstat (limited to 'juick-server-jdbc/src/main/java/com/juick/service')
-rw-r--r--juick-server-jdbc/src/main/java/com/juick/service/PMQueriesServiceImpl.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/juick-server-jdbc/src/main/java/com/juick/service/PMQueriesServiceImpl.java b/juick-server-jdbc/src/main/java/com/juick/service/PMQueriesServiceImpl.java
index 80be200b..8b7ba42e 100644
--- a/juick-server-jdbc/src/main/java/com/juick/service/PMQueriesServiceImpl.java
+++ b/juick-server-jdbc/src/main/java/com/juick/service/PMQueriesServiceImpl.java
@@ -116,14 +116,16 @@ public class PMQueriesServiceImpl extends BaseJdbcService implements PMQueriesSe
.addValue("uidTo", uidTo);
List<com.juick.Message> msgs = getNamedParameterJdbcTemplate().query(
- "SELECT user_id, txt,ts FROM pm WHERE (user_id = :uid AND user_id_to = :uidTo) "
+ "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 LIMIT 20",
sqlParameterSource,
(rs, rowNum) -> {
com.juick.Message msg = new com.juick.Message();
int uuid = rs.getInt(1);
- msg.setUser(new User());
- msg.getUser().setUid(uuid);
+ User user = new User();
+ user.setUid(uuid);
+ user.setName(rs.getString(4));
+ msg.setUser(user);
msg.setText(rs.getString(2));
msg.setTimestamp(rs.getTimestamp(3).toInstant());
return msg;