From b2c48c5a77ca119276cab2ad6df4db4841376f04 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 5 Sep 2018 13:10:24 +0300 Subject: ActivityStreams: followers and following collections --- .../src/main/java/com/juick/service/UserServiceImpl.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'juick-server/src/main/java/com/juick/service') diff --git a/juick-server/src/main/java/com/juick/service/UserServiceImpl.java b/juick-server/src/main/java/com/juick/service/UserServiceImpl.java index e841b539..bd72bed9 100644 --- a/juick-server/src/main/java/com/juick/service/UserServiceImpl.java +++ b/juick-server/src/main/java/com/juick/service/UserServiceImpl.java @@ -26,6 +26,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.dao.DuplicateKeyException; +import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; import org.springframework.jdbc.support.GeneratedKeyHolder; @@ -498,6 +499,16 @@ public class UserServiceImpl extends BaseJdbcService implements UserService { uid); } + @Transactional(readOnly = true) + @Override + public Integer getUserRecommendations(User user) { + try { + return jdbcTemplate.queryForObject("SELECT COUNT(*) FROM favorites WHERE user_id=?", Integer.class, user.getUid()); + } catch (EmptyResultDataAccessException e) { + return 0; + } + } + @Transactional(readOnly = true) @Override public List getUserBLUsers(final int uid) { -- cgit v1.2.3