forked from TruthHun/BookStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub.go
More file actions
33 lines (27 loc) · 1005 Bytes
/
github.go
File metadata and controls
33 lines (27 loc) · 1005 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package models
import (
"github.com/TruthHun/BookStack/oauth"
"github.com/astaxie/beego/orm"
)
var ModelGithub = new(Github)
type Github struct {
oauth.GithubUser
}
//gitee用户的登录流程是这样的
//1、获取gitee的用户信息,用gitee的用户id查询member_id是否大于0,大于0则表示已绑定了用户信息,直接登录
//2、未绑定用户,先把gitee数据入库,然后再跳转绑定页面
//根据giteeid获取用户的gitee数据。这里可以查询用户是否绑定了或者数据是否在库中存在
func (this *Github) GetUserByGithubId(id int, cols ...string) (user Github, err error) {
qs := orm.NewOrm().QueryTable("md_github").Filter("id", id)
if len(cols) > 0 {
err = qs.One(&user, cols...)
} else {
err = qs.One(&user)
}
return
}
//绑定用户
func (this *Github) Bind(githubId, memberId interface{}) (err error) {
_, err = orm.NewOrm().QueryTable("md_github").Filter("id", githubId).Update(orm.Params{"member_id": memberId})
return
}