mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-05-09 20:49:34 +08:00
add mysql
This commit is contained in:
parent
1ce0a3b5d3
commit
c025d0d030
@ -4,6 +4,8 @@ import (
|
|||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
func IsLimitRegisterIp(RegisterIp string) (bool, error) {
|
func IsLimitRegisterIp(RegisterIp string) (bool, error) {
|
||||||
@ -84,7 +86,7 @@ func InsertIpRecord(userID, createIp string) error {
|
|||||||
|
|
||||||
func UpdateIpReocord(userID, ip string) (err error) {
|
func UpdateIpReocord(userID, ip string) (err error) {
|
||||||
record := &db.UserIpRecord{UserID: userID, LastLoginIp: ip, LastLoginTime: time.Now()}
|
record := &db.UserIpRecord{UserID: userID, LastLoginIp: ip, LastLoginTime: time.Now()}
|
||||||
result := db.DB.MysqlDB.DefaultGormDB().Model(&db.UserIpRecord{}).Where("user_id=?", userID).Updates(record).Updates("login_times = login_times + 1")
|
result := db.DB.MysqlDB.DefaultGormDB().Model(&db.UserIpRecord{}).Where("user_id=?", userID).Updates(record).Update("login_times", gorm.Expr("login_times+?", 1))
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
return utils.Wrap(result.Error, "")
|
return utils.Wrap(result.Error, "")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user