forked from golang/hotime
重新索引
This commit is contained in:
parent
6ff34dc11b
commit
7c427d8692
@ -187,8 +187,11 @@ var User = Ctr{
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
user := this.Db.Get("user", "*", Map{"phone": phone})
|
||||
uWhere := Map{"phone": phone}
|
||||
if this.Session("user_id").ToCeilInt() != 0 {
|
||||
uWhere = Map{"id": this.Session("user_id").ToCeilInt()}
|
||||
}
|
||||
user := this.Db.Get("user", "*", uWhere)
|
||||
data := Map{"name": name,
|
||||
"phone": phone,
|
||||
//"org_id": orgId,
|
||||
|
@ -45,38 +45,104 @@ var Wechat = Ctr{
|
||||
},
|
||||
//微信注册,0已经完整的注册了,1还没有注册
|
||||
"codebase": func(this *Context) {
|
||||
//wx := Weixin(this)
|
||||
////auth := wx.GetOauth(this.Req, this.Resp)
|
||||
//auth := wx.GetOauth()
|
||||
//resToken, err := auth.GetUserAccessToken(this.Req.FormValue("code"))
|
||||
//if err != nil {
|
||||
// this.Display(6, "code错误")
|
||||
// return
|
||||
//}
|
||||
//
|
||||
////判断用户是否已经注册
|
||||
//user := this.Db.Get("wechat", Map{"[><]user": "wechat.user_id=user.id"}, "user.id,user.state", Map{"openid": resToken.OpenID})
|
||||
//if user != nil {
|
||||
// this.Session("user_id", user.Get("id"))
|
||||
// this.Display(0, 0)
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//user_id := this.Db.Insert("user", Map{"create_time": time.Now().Unix(), "modify_time": time.Now().Unix(), "state": 2})
|
||||
//if user_id == 0 {
|
||||
// this.Display(4, "创建用户失败")
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//wid := this.Db.Insert("wechat", Map{"openid": resToken.OpenID, "appid": this.Config.GetString("wechatAppID"), "state": 1, "user_id": user_id})
|
||||
//if wid == 0 {
|
||||
// this.Display(4, "关联微信失败!")
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//this.Session("user_id", user.Get("id"))
|
||||
//
|
||||
//this.Display(0, 1)
|
||||
|
||||
orgId := ObjToInt(this.Req.FormValue("org_id"))
|
||||
//if orgId==0{
|
||||
// this.Display(3, "缺少组织id")
|
||||
// return
|
||||
//}
|
||||
|
||||
wx := Weixin(this)
|
||||
//auth := wx.GetOauth(this.Req, this.Resp)
|
||||
auth := wx.GetOauth()
|
||||
resToken, err := auth.GetUserAccessToken(this.Req.FormValue("code"))
|
||||
if err != nil {
|
||||
this.Display(6, "code错误")
|
||||
this.Display(5, "code错误")
|
||||
return
|
||||
}
|
||||
|
||||
//判断用户是否已经注册
|
||||
user := this.Db.Get("wechat", Map{"[><]user": "wechat.user_id=user.id"}, "user.id,user.state", Map{"openid": resToken.OpenID})
|
||||
if user != nil {
|
||||
if user != nil && user.GetCeilInt("id") != 0 && user.GetCeilInt("state") == 0 {
|
||||
this.Session("user_id", user.Get("id"))
|
||||
this.Display(0, 0)
|
||||
this.Display(0, Map{"type": 0, "token": this.SessionId})
|
||||
return
|
||||
}
|
||||
//getUserInfo
|
||||
userInfo, err := auth.GetUserInfo(resToken.AccessToken, resToken.OpenID)
|
||||
if err != nil {
|
||||
this.Display(6, "微信个人信息无法获取")
|
||||
return
|
||||
}
|
||||
|
||||
user_id := this.Db.Insert("user", Map{"create_time": time.Now().Unix(), "modify_time": time.Now().Unix(), "state": 2})
|
||||
if user_id == 0 {
|
||||
this.Display(4, "创建用户失败")
|
||||
return
|
||||
fmt.Println(userInfo)
|
||||
|
||||
//wechatInfo := ObjToMap(userInfo)
|
||||
t := time.Now().Unix()
|
||||
wechatInfo := Map{
|
||||
"openid": userInfo.OpenID,
|
||||
"acttoken": resToken.AccessToken,
|
||||
"retoken": resToken.RefreshToken,
|
||||
"appid": this.Config.GetString("wechatAppID"),
|
||||
"unionid": userInfo.Unionid,
|
||||
"nickname": userInfo.Nickname,
|
||||
"avatar": userInfo.HeadImgURL,
|
||||
}
|
||||
if orgId != 0 {
|
||||
wechatInfo["org_id"] = orgId
|
||||
wechatInfo["status"] = 0
|
||||
}
|
||||
|
||||
wid := this.Db.Insert("wechat", Map{"openid": resToken.OpenID, "appid": this.Config.GetString("wechatAppID"), "state": 1, "user_id": user_id})
|
||||
if wid == 0 {
|
||||
this.Display(4, "关联微信失败!")
|
||||
return
|
||||
wechatDb := this.Db.Get("wechat", "*", Map{"openid": wechatInfo.GetString("openid")})
|
||||
|
||||
if wechatDb != nil {
|
||||
|
||||
this.Db.Update("wechat", wechatInfo, Map{"id": wechatDb.GetCeilInt("id")})
|
||||
//userInfo["wid"]=wechatDb.GetCeilInt("wid")
|
||||
} else {
|
||||
wechatInfo["create_time"] = t
|
||||
wechatInfo["id"] = this.Db.Insert("wechat", wechatInfo)
|
||||
}
|
||||
wechatDb = this.Db.Get("wechat", "*", Map{"openid": wechatInfo.GetString("openid")})
|
||||
|
||||
this.Session("user_id", user.Get("id"))
|
||||
this.Session("wechatInfo", wechatDb)
|
||||
fmt.Println(wechatDb)
|
||||
fmt.Println(this.Session("wechatInfo"))
|
||||
//this.Display(0, 1)
|
||||
this.Display(0, Map{"type": 1, "token": this.SessionId})
|
||||
|
||||
this.Display(0, 1)
|
||||
},
|
||||
//微信注册,0已经完整的注册了,1还没有注册
|
||||
"code": func(this *Context) {
|
||||
|
File diff suppressed because it is too large
Load Diff
BIN
iedc_go.exe
BIN
iedc_go.exe
Binary file not shown.
Loading…
Reference in New Issue
Block a user