Ejemplo n.º 1
0
	def unfollow(cls, fansUid, friendUid):
		''' 取消关注 '''
		# 创建session对象:
		session = DBSession()
		ret = session.query(cls).filter(cls.friend_uid==friendUid, cls.fans_uid==fansUid).delete()
		session.commit()
		session.close()


		# 更新uid为fansUid的关注人数和粉丝数
		following = cls.countFollowing(fansUid)
		follower = cls.countFollower(fansUid)
		Users.updateFollowCount(fansUid, follower, following)

		# 更新uid为friendUid的关注人数和粉丝数
		following = cls.countFollowing(friendUid)
		follower = cls.countFollower(friendUid)
		Users.updateFollowCount(friendUid, follower, following)
		return True
Ejemplo n.º 2
0
	def follow(cls, fansUid, friendUid):
		''' 
		添加关注
		同时更新用户表的粉丝数和关注数
		'''
		ret = cls(fans_uid = fansUid, friend_uid = friendUid)
		session = DBSession()
		session.add(ret)
		session.commit()
		session.close()


		# 更新uid为fansUid的关注人数和粉丝数
		following = cls.countFollowing(fansUid)
		follower = cls.countFollower(fansUid)
		Users.updateFollowCount(fansUid, follower, following)

		# 更新uid为friendUid的关注人数和粉丝数
		following = cls.countFollowing(friendUid)
		follower = cls.countFollower(friendUid)
		Users.updateFollowCount(friendUid, follower, following)
		return True