|
|
|
@@ -47,7 +47,7 @@ func BindWechatOpenId(userId int64, wechatOpenId string) error { |
|
|
|
return sess.Commit() |
|
|
|
} |
|
|
|
|
|
|
|
func UnbindWechatOpenId(userId int64) error { |
|
|
|
func UnbindWechatOpenId(userId int64, oldWechatOpenID string) error { |
|
|
|
sess := x.NewSession() |
|
|
|
defer sess.Close() |
|
|
|
if err := sess.Begin(); err != nil { |
|
|
|
@@ -55,7 +55,7 @@ func UnbindWechatOpenId(userId int64) error { |
|
|
|
} |
|
|
|
|
|
|
|
param := &User{WechatOpenId: ""} |
|
|
|
n, err := x.Where("ID = ?", userId).Update(param) |
|
|
|
n, err := x.Where("ID = ? AND wechat_open_id =?", userId, oldWechatOpenID).Update(param) |
|
|
|
if err != nil { |
|
|
|
log.Error("update wechat_open_id failed,e=%v", err) |
|
|
|
return err |
|
|
|
@@ -64,10 +64,10 @@ func UnbindWechatOpenId(userId int64) error { |
|
|
|
log.Error("update wechat_open_id failed,user not exist,userId=%d", userId) |
|
|
|
return nil |
|
|
|
} |
|
|
|
//todo 是否记录原有微信openId |
|
|
|
logParam := &WechatBindLog{ |
|
|
|
UserID: userId, |
|
|
|
Action: int(WECHAT_UNBIND), |
|
|
|
UserID: userId, |
|
|
|
WechatOpenId: oldWechatOpenID, |
|
|
|
Action: int(WECHAT_UNBIND), |
|
|
|
} |
|
|
|
sess.Insert(logParam) |
|
|
|
return sess.Commit() |
|
|
|
|