diff options
author | 2016-11-14 15:56:32 +0700 | |
---|---|---|
committer | 2016-11-14 15:56:32 +0700 | |
commit | d03e8b19d346563afec5fb2b6b9c9dcea68040e0 (patch) | |
tree | beb150d73b7734b5ee3823f4b38c68fa2f88f5af /server-core/src/main/java/com/juick/service/PrivacyQueriesServiceImpl.java | |
parent | ecbc4907669c06c7a71ffda3bd78a163ee1287fe (diff) |
jdbc services
Diffstat (limited to 'server-core/src/main/java/com/juick/service/PrivacyQueriesServiceImpl.java')
-rw-r--r-- | server-core/src/main/java/com/juick/service/PrivacyQueriesServiceImpl.java | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/server-core/src/main/java/com/juick/service/PrivacyQueriesServiceImpl.java b/server-core/src/main/java/com/juick/service/PrivacyQueriesServiceImpl.java index d4e43728..b83f61c1 100644 --- a/server-core/src/main/java/com/juick/service/PrivacyQueriesServiceImpl.java +++ b/server-core/src/main/java/com/juick/service/PrivacyQueriesServiceImpl.java @@ -1,10 +1,48 @@ package com.juick.service; +import com.juick.Tag; +import com.juick.User; import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; /** * Created by aalexeev on 11/13/16. */ @Repository -public class PrivacyQueriesServiceImpl extends BaseJdbcDao implements PrivacyQueriesService { +@Transactional +public class PrivacyQueriesServiceImpl extends BaseJdbcService implements PrivacyQueriesService { + + @Override + public PrivacyResult blacklistUser(final User user, final User target) { + int result = getJdbcTemplate().update( + "DELETE FROM bl_users WHERE user_id=? AND bl_user_id=?", + user.getUID(), + target.getUID()); + if (result > 0) { + return PrivacyResult.Removed; + } else { + getJdbcTemplate().update( + "INSERT INTO bl_users(user_id,bl_user_id) VALUES (?,?)", + user.getUID(), + target.getUID()); + return PrivacyResult.Added; + } + } + + @Override + public PrivacyResult blacklistTag(final User user, final Tag tag) { + int result = getJdbcTemplate().update( + "DELETE FROM bl_tags WHERE user_id=? AND tag_id=?", + user.getUID(), + tag.TID); + if (result > 0) { + return PrivacyResult.Removed; + } else { + getJdbcTemplate().update( + "INSERT INTO bl_tags(user_id,tag_id) VALUES (?,?)", + user.getUID(), + tag.TID); + return PrivacyResult.Added; + } + } } |