mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-05-18 01:59:17 +08:00
db
This commit is contained in:
parent
dff32dd7ef
commit
88d6fc663a
@ -2,7 +2,9 @@ package db
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -157,7 +159,31 @@ func initMysqlDB() {
|
|||||||
im_mysql_model.FriendRequestDB = db.Table("friend_requests")
|
im_mysql_model.FriendRequestDB = db.Table("friend_requests")
|
||||||
im_mysql_model.GroupRequestDB = db.Table("group_requests")
|
im_mysql_model.GroupRequestDB = db.Table("group_requests")
|
||||||
im_mysql_model.AppDB = db.Table("app_db")
|
im_mysql_model.AppDB = db.Table("app_db")
|
||||||
|
InitManager()
|
||||||
|
}
|
||||||
|
|
||||||
|
func InitManager() {
|
||||||
|
for k, v := range config.Config.Manager.AppManagerUid {
|
||||||
|
_, err := im_mysql_model.GetUserByUserID(v)
|
||||||
|
if err != nil {
|
||||||
|
} else {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
var appMgr im_mysql_model.User
|
||||||
|
appMgr.UserID = v
|
||||||
|
if k == 0 {
|
||||||
|
appMgr.Nickname = config.Config.Manager.AppSysNotificationName
|
||||||
|
} else {
|
||||||
|
appMgr.Nickname = "AppManager" + utils.IntToString(k+1)
|
||||||
|
}
|
||||||
|
appMgr.AppMangerLevel = constant.AppAdmin
|
||||||
|
err = im_mysql_model.UserRegister(appMgr)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("AppManager insert error ", err.Error(), appMgr)
|
||||||
|
} else {
|
||||||
|
fmt.Println("AppManager insert ", appMgr)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mysqlDB) DefaultGormDB() *gorm.DB {
|
func (m *mysqlDB) DefaultGormDB() *gorm.DB {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package im_mysql_model
|
package im_mysql_model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"errors"
|
"errors"
|
||||||
@ -37,30 +36,6 @@ type User struct {
|
|||||||
status int32 `gorm:"column:status"`
|
status int32 `gorm:"column:status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
|
||||||
for k, v := range config.Config.Manager.AppManagerUid {
|
|
||||||
_, err := GetUserByUserID(v)
|
|
||||||
if err != nil {
|
|
||||||
} else {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
var appMgr User
|
|
||||||
appMgr.UserID = v
|
|
||||||
if k == 0 {
|
|
||||||
appMgr.Nickname = config.Config.Manager.AppSysNotificationName
|
|
||||||
} else {
|
|
||||||
appMgr.Nickname = "AppManager" + utils.IntToString(k+1)
|
|
||||||
}
|
|
||||||
appMgr.AppMangerLevel = constant.AppAdmin
|
|
||||||
err = UserRegister(appMgr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("AppManager insert error ", err.Error(), appMgr)
|
|
||||||
} else {
|
|
||||||
fmt.Println("AppManager insert ", appMgr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func UserRegister(user User) error {
|
func UserRegister(user User) error {
|
||||||
user.CreateTime = time.Now()
|
user.CreateTime = time.Now()
|
||||||
if user.AppMangerLevel == 0 {
|
if user.AppMangerLevel == 0 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user