MCPcopy Index your code
hub / github.com/TruthHun/BookStack / FollowOrCancel

Method FollowOrCancel

models/fans.go:33–47  ·  view source on GitHub ↗

关注和取消关注

(uid, fansId int)

Source from the content-addressed store, hash-verified

31
32//关注和取消关注
33func (this *Fans) FollowOrCancel(uid, fansId int) (cancel bool, err error) {
34 var fans Fans
35 o := orm.NewOrm()
36 qs := o.QueryTable(tableFans).Filter("uid", uid).Filter("fans_id", fansId)
37 qs.One(&fans)
38 if fans.Id > 0 { //已关注,则取消关注
39 _, err = qs.Delete()
40 cancel = true
41 } else { //未关注,则新增关注
42 fans.Uid = uid
43 fans.FansId = fansId
44 _, err = o.Insert(&fans)
45 }
46 return
47}
48
49//查询是否已经关注了用户
50func (this *Fans) Relation(uid, fansId interface{}) (ok bool) {

Callers 1

SetFollowMethod · 0.80

Calls 2

DeleteMethod · 0.45
InsertMethod · 0.45

Tested by

no test coverage detected