diff --git a/models/user.go b/models/user.go index 0103a6c0b..5b90c38b5 100755 --- a/models/user.go +++ b/models/user.go @@ -179,7 +179,8 @@ type User struct { PrivateKey string `xorm:"INDEX"` //Wechat - WechatOpenId string `xorm:"INDEX"` + WechatOpenId string `xorm:"INDEX"` + WechatBindTime time.Time } // SearchOrganizationsOptions options to filter organizations diff --git a/models/wechat_bind.go b/models/wechat_bind.go index 3cca4888a..5609fa259 100644 --- a/models/wechat_bind.go +++ b/models/wechat_bind.go @@ -27,7 +27,7 @@ func BindWechatOpenId(userId int64, wechatOpenId string) error { return err } - param := &User{WechatOpenId: wechatOpenId} + param := &User{WechatOpenId: wechatOpenId, WechatBindTime: time.Now()} n, err := sess.Where("ID = ?", userId).Update(param) if err != nil { log.Error("update wechat_open_id failed,e=%v", err) @@ -66,7 +66,7 @@ func UnbindWechatOpenId(userId int64, oldWechatOpenID string) error { return err } - n, err := x.Table(new(User)).Where("ID = ? AND wechat_open_id =?", userId, oldWechatOpenID).Update(map[string]interface{}{"wechat_open_id": ""}) + n, err := x.Table(new(User)).Where("ID = ? AND wechat_open_id =?", userId, oldWechatOpenID).Update(map[string]interface{}{"wechat_open_id": "", "wechat_bind_time": nil}) if err != nil { log.Error("update wechat_open_id failed,e=%v", err) return err