zqbao 9 ay önce
ebeveyn
işleme
6de9309296
2 değiştirilmiş dosya ile 5 ekleme ve 4 silme
  1. 2 1
      controllers/wechat.go
  2. 3 3
      models/wx_sesssion.go

+ 2 - 1
controllers/wechat.go

@@ -219,7 +219,8 @@ func (this *WechatController) Login() {
 			UnionId:    userInfo.UnionID,
 			CreateTime: time.Now(),
 		}
-		er := session.Insert()
+		insertId, er := session.Insert()
+		session.WxSessionId = int(insertId)
 		if er != nil {
 			br.Msg = "用户登录失败"
 			br.ErrMsg = "用户登录获取失败,系统错误,Err:" + er.Error()

+ 3 - 3
models/wx_sesssion.go

@@ -7,7 +7,7 @@ import (
 )
 
 type WxSession struct {
-	WxSessionId    string    `orm:"pk" description:"id"`
+	WxSessionId    int       `orm:"pk" description:"id"`
 	OpenId         string    `description:"openId"`
 	UnionId        string    `description:"unionId"`
 	AccessToken    string    `description:"微信token"`
@@ -15,9 +15,9 @@ type WxSession struct {
 	LastUpdateTime time.Time `description:"最后更新时间"`
 }
 
-func (w *WxSession) Insert() (err error) {
+func (w *WxSession) Insert() (insertId int64, err error) {
 	o := orm.NewOrm()
-	_, err = o.Insert(w)
+	insertId, err = o.Insert(w)
 	return
 }