Browse Source

#1494

update wechat bind time
tags/v1.22.2.2^2
chenyifan01 3 years ago
parent
commit
54c1428236
2 changed files with 4 additions and 3 deletions
  1. +1
    -1
      models/user.go
  2. +3
    -2
      models/wechat_bind.go

+ 1
- 1
models/user.go View File

@@ -180,7 +180,7 @@ type User struct {


//Wechat //Wechat
WechatOpenId string `xorm:"INDEX"` WechatOpenId string `xorm:"INDEX"`
WechatBindTime time.Time
WechatBindUnix timeutil.TimeStamp
} }


// SearchOrganizationsOptions options to filter organizations // SearchOrganizationsOptions options to filter organizations


+ 3
- 2
models/wechat_bind.go View File

@@ -2,6 +2,7 @@ package models


import ( import (
"code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/timeutil"
"time" "time"
) )


@@ -27,7 +28,7 @@ func BindWechatOpenId(userId int64, wechatOpenId string) error {
return err return err
} }


param := &User{WechatOpenId: wechatOpenId, WechatBindTime: time.Now()}
param := &User{WechatOpenId: wechatOpenId, WechatBindUnix: timeutil.TimeStampNow()}
n, err := sess.Where("ID = ?", userId).Update(param) n, err := sess.Where("ID = ?", userId).Update(param)
if err != nil { if err != nil {
log.Error("update wechat_open_id failed,e=%v", err) log.Error("update wechat_open_id failed,e=%v", err)
@@ -66,7 +67,7 @@ func UnbindWechatOpenId(userId int64, oldWechatOpenID string) error {
return err return err
} }


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})
n, err := x.Table(new(User)).Where("ID = ? AND wechat_open_id =?", userId, oldWechatOpenID).Update(map[string]interface{}{"wechat_open_id": "", "wechat_bind_unix": nil})
if err != nil { if err != nil {
log.Error("update wechat_open_id failed,e=%v", err) log.Error("update wechat_open_id failed,e=%v", err)
return err return err


Loading…
Cancel
Save