remove follow

This commit is contained in:
aisensiy
2017-08-16 17:13:24 +08:00
parent daaf2070c7
commit 0c12253ef0
7 changed files with 67 additions and 2 deletions

View File

@@ -43,11 +43,18 @@ public class MyBatisUserRepository implements UserRepository {
@Override
public void saveRelation(FollowRelation followRelation) {
userMapper.saveRelation(followRelation);
if (!findRelation(followRelation.getUserId(), followRelation.getTargetId()).isPresent()) {
userMapper.saveRelation(followRelation);
}
}
@Override
public Optional<FollowRelation> findRelation(String userId, String targetId) {
return Optional.ofNullable(userMapper.findRelation(userId, targetId));
}
@Override
public void removeRelation(FollowRelation followRelation) {
userMapper.deleteRelation(followRelation);
}
}

View File

@@ -21,4 +21,6 @@ public interface UserMapper {
FollowRelation findRelation(@Param("userId") String userId, @Param("targetId") String targetId);
void saveRelation(@Param("followRelation") FollowRelation followRelation);
void deleteRelation(@Param("followRelation") FollowRelation followRelation);
}