33 lines
551 B
Go
33 lines
551 B
Go
package module
|
|
|
|
import (
|
|
"git.hlsq.asia/mmorpg/service-common/config"
|
|
"git.hlsq.asia/mmorpg/service-common/log"
|
|
"git.hlsq.asia/mmorpg/service-common/utils"
|
|
"math/rand"
|
|
)
|
|
|
|
// Base 基础模块
|
|
type Base struct {
|
|
DefaultModule
|
|
log *config.LogConfig
|
|
}
|
|
|
|
func (m *Base) Init() error {
|
|
// 日志
|
|
log.Init(m.log)
|
|
// 雪花
|
|
utils.InitSnowflake(int64(rand.Intn(1000)))
|
|
return nil
|
|
}
|
|
|
|
func (m *Base) Bind(data ...any) Module {
|
|
if data == nil || len(data) == 0 {
|
|
return m
|
|
}
|
|
if l, ok := data[0].(*config.LogConfig); ok {
|
|
m.log = l
|
|
}
|
|
return m
|
|
}
|