本文整理匯總了Golang中github.com/beego/wetalk/modules/models.User.Following方法的典型用法代碼示例。如果您正苦於以下問題:Golang User.Following方法的具體用法?Golang User.Following怎麽用?Golang User.Following使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/beego/wetalk/modules/models.User
的用法示例。
在下文中一共展示了User.Following方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: UserFollow
func UserFollow(user *models.User, theUser *models.User) {
if theUser.Read() == nil {
var mutual bool
tFollow := models.Follow{User: theUser, FollowUser: user}
if err := tFollow.Read("User", "FollowUser"); err == nil {
mutual = true
}
follow := models.Follow{User: user, FollowUser: theUser, Mutual: mutual}
if err := follow.Insert(); err == nil && mutual {
tFollow.Mutual = mutual
tFollow.Update("Mutual")
}
if nums, err := user.FollowingUsers().Count(); err == nil {
user.Following = int(nums)
user.Update("Following")
}
if nums, err := theUser.FollowerUsers().Count(); err == nil {
theUser.Followers = int(nums)
theUser.Update("Followers")
}
}
}
示例2: UserUnFollow
func UserUnFollow(user *models.User, theUser *models.User) {
num, _ := user.FollowingUsers().Filter("FollowUser", theUser.Id).Delete()
if num > 0 {
theUser.FollowingUsers().Filter("FollowUser", user.Id).Update(orm.Params{
"Mutual": false,
})
if nums, err := user.FollowingUsers().Count(); err == nil {
user.Following = int(nums)
user.Update("Following")
}
if nums, err := theUser.FollowerUsers().Count(); err == nil {
theUser.Followers = int(nums)
theUser.Update("Followers")
}
}
}