mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-12 21:16:00 +08:00
用户表增加注册IP 登陆IP
1、用户表增加注册IP 登陆IP 2、新增ip_limit表、user_ip_limit表 3、用户创建需要增加createIp参数同步 用户登录需要增加loginIp参数同步 login_limit 限制说明 0:读取ip_limits表 限制用户注册+用户登陆IP 1:读取user_ip_limits表 限制用户在指定IP登陆 2:读取black_lists表 限制用户在限制时间不能登陆
This commit is contained in:
+14
-3
@@ -2,14 +2,13 @@ package db
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"gorm.io/gorm/logger"
|
||||
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/logger"
|
||||
)
|
||||
|
||||
type mysqlDB struct {
|
||||
@@ -79,7 +78,7 @@ func initMysqlDB() {
|
||||
&GroupMember{},
|
||||
&GroupRequest{},
|
||||
&User{},
|
||||
&Black{}, &ChatLog{}, &Register{}, &Conversation{}, &AppVersion{}, &Department{})
|
||||
&Black{}, &ChatLog{}, &Register{}, &Conversation{}, &AppVersion{}, &Department{}, &BlackList{}, &IpLimit{}, &UserIpLimit{})
|
||||
db.Set("gorm:table_options", "CHARSET=utf8")
|
||||
db.Set("gorm:table_options", "collation=utf8_unicode_ci")
|
||||
|
||||
@@ -143,6 +142,18 @@ func initMysqlDB() {
|
||||
fmt.Println("CreateTable DepartmentMember")
|
||||
db.Migrator().CreateTable(&AppVersion{})
|
||||
}
|
||||
if !db.Migrator().HasTable(&BlackList{}) {
|
||||
fmt.Println("CreateTable BlackList")
|
||||
db.Migrator().CreateTable(&BlackList{})
|
||||
}
|
||||
if !db.Migrator().HasTable(&IpLimit{}) {
|
||||
fmt.Println("CreateTable IpLimit")
|
||||
db.Migrator().CreateTable(&IpLimit{})
|
||||
}
|
||||
if !db.Migrator().HasTable(&UserIpLimit{}) {
|
||||
fmt.Println("CreateTable UserIpLimit")
|
||||
db.Migrator().CreateTable(&UserIpLimit{})
|
||||
}
|
||||
DB.MysqlDB.db = db
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user