aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/service
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/service')
-rw-r--r--src/main/java/com/juick/service/UserServiceImpl.java10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/main/java/com/juick/service/UserServiceImpl.java b/src/main/java/com/juick/service/UserServiceImpl.java
index 57fcd399..932be19c 100644
--- a/src/main/java/com/juick/service/UserServiceImpl.java
+++ b/src/main/java/com/juick/service/UserServiceImpl.java
@@ -439,11 +439,11 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
@Transactional(readOnly = true)
@Override
public List<User> getUserReadLeastPopular(final int uid, final int cnt) {
- return getJdbcTemplate().query(
- "SELECT users.id,users.nick FROM (subscr_users " +
- "INNER JOIN users_subscr ON (subscr_users.suser_id=? " +
- "AND subscr_users.user_id=users_subscr.user_id)) INNER JOIN users " +
- "ON subscr_users.user_id=users.id ORDER BY cnt " + limit(cnt),
+ return getJdbcTemplate().query("""
+ SELECT users.id,users.nick, (select count(*) from subscr_users where user_id=users.id) cnt
+ FROM subscr_users INNER JOIN users
+ ON subscr_users.user_id=users.id WHERE subscr_users.suser_id=? ORDER by cnt
+ """ + limit(cnt),
(rs, num) -> {
User u = new User();
u.setUid(rs.getInt(1));