上传联盟学院代码注册
This commit is contained in:
parent
e6ed62a330
commit
8ae9c6842f
@ -70,7 +70,7 @@ const (
|
||||
//ModuleFetter core.M_Modules = "herofetter" //好友模块
|
||||
ModuleSociaty core.M_Modules = "sociaty" //公会
|
||||
ModulePay core.M_Modules = "pay" //支付
|
||||
ModuleAlliance core.M_Modules = "alliance" //联盟学院
|
||||
ModuleAcademy core.M_Modules = "academy" //联盟学院
|
||||
ModulePrivilege core.M_Modules = "privilege" //特权
|
||||
ModuleGrowtask core.M_Modules = "growtask" //成长任务
|
||||
ModuleWorldtask core.M_Modules = "worldtask" //世界任务
|
||||
|
@ -6,6 +6,21 @@ func Atoi(b []byte) (int, error) {
|
||||
return strconv.Atoi(BytesToString(b))
|
||||
}
|
||||
|
||||
func StringToInt64(b string) int64 {
|
||||
if i, err := strconv.ParseInt(b, 10, 64); err != nil {
|
||||
return 0
|
||||
} else {
|
||||
return i
|
||||
}
|
||||
}
|
||||
func StringToFloat64(b string) float64 {
|
||||
if i, err := strconv.ParseFloat(b, 64); err != nil {
|
||||
return 0
|
||||
} else {
|
||||
return i
|
||||
}
|
||||
}
|
||||
|
||||
func ParseInt(b []byte, base int, bitSize int) (int64, error) {
|
||||
return strconv.ParseInt(BytesToString(b), base, bitSize)
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ type Academy struct {
|
||||
|
||||
//模块名
|
||||
func (this *Academy) GetType() core.M_Modules {
|
||||
return comm.ModuleForum
|
||||
return comm.ModuleAcademy
|
||||
}
|
||||
|
||||
//模块初始化接口 注册用户创建角色事件
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/modules/academy"
|
||||
"go_dreamfactory/modules/arena"
|
||||
"go_dreamfactory/modules/battle"
|
||||
"go_dreamfactory/modules/chat"
|
||||
@ -103,6 +104,7 @@ func main() {
|
||||
//privilege.NewModule(),
|
||||
growtask.NewModule(),
|
||||
worldtask.NewModule(),
|
||||
academy.NewModule(),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"go_dreamfactory/lego"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/lego/utils/codec"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
@ -43,6 +44,7 @@ type Configure struct {
|
||||
clock sync.RWMutex
|
||||
configure map[string]interface{}
|
||||
fileinfos map[string]*FileInfo
|
||||
offsettime time.Duration //偏移时间
|
||||
}
|
||||
|
||||
func (this *Configure) Start() (err error) {
|
||||
@ -59,7 +61,7 @@ func (this *Configure) Start() (err error) {
|
||||
}
|
||||
timer.Stop()
|
||||
}()
|
||||
|
||||
this.readoffsettime()
|
||||
return
|
||||
}
|
||||
func (this *Configure) Stop() (err error) {
|
||||
@ -67,6 +69,11 @@ func (this *Configure) Stop() (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
//服务当前时间
|
||||
func (this *Configure) Now() time.Time {
|
||||
return time.Now().Add(this.offsettime)
|
||||
}
|
||||
|
||||
//加载配置文件
|
||||
func (this *Configure) RegisterConfigure(name string, fn interface{}, callback func()) (err error) {
|
||||
this.hlock.RLock()
|
||||
@ -209,4 +216,25 @@ func (this *Configure) checkConfigure() {
|
||||
}
|
||||
}
|
||||
}
|
||||
this.readoffsettime()
|
||||
}
|
||||
|
||||
//读取偏移时间
|
||||
func (this *Configure) readoffsettime() {
|
||||
var (
|
||||
fliepath string
|
||||
file *os.File
|
||||
data []byte
|
||||
offtimeStr string
|
||||
err error
|
||||
)
|
||||
if file, err = os.Open(fliepath); err != nil {
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
if data, err = ioutil.ReadAll(file); err != nil {
|
||||
return
|
||||
}
|
||||
offtimeStr = codec.BytesToString(data)
|
||||
this.offsettime = time.Second * time.Duration(codec.StringToInt64(offtimeStr))
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ type (
|
||||
Stop() (err error)
|
||||
RegisterConfigure(name string, fn interface{}, callback func()) (err error) //注册配置
|
||||
GetConfigure(name string) (v interface{}, err error) //获取配置
|
||||
Now() time.Time //服务器当前时间
|
||||
}
|
||||
)
|
||||
|
||||
@ -57,5 +58,5 @@ func GetConfigure(name string) (v interface{}, err error) {
|
||||
|
||||
//当前时间
|
||||
func Now() time.Time {
|
||||
return time.Now()
|
||||
return defsys.Now()
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package configure
|
||||
|
||||
import (
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/lego/utils/mapstructure"
|
||||
)
|
||||
|
||||
@ -9,6 +10,8 @@ type Options struct {
|
||||
ConfigurePath string //配置中心路径
|
||||
TimestampFile string //时间戳配置文件路径
|
||||
CheckInterval int //配置文件更新检查间隔时间 单位秒
|
||||
Debug bool //日志是否开启
|
||||
Log log.ILogger
|
||||
}
|
||||
|
||||
func SetConfigurePath(v string) Option {
|
||||
@ -27,6 +30,18 @@ func SetCheckInterval(v int) Option {
|
||||
}
|
||||
}
|
||||
|
||||
func SetDebug(v bool) Option {
|
||||
return func(o *Options) {
|
||||
o.Debug = v
|
||||
}
|
||||
}
|
||||
|
||||
func SetLog(v log.ILogger) Option {
|
||||
return func(o *Options) {
|
||||
o.Log = v
|
||||
}
|
||||
}
|
||||
|
||||
func newOptions(config map[string]interface{}, opts ...Option) (Options, error) {
|
||||
options := Options{
|
||||
CheckInterval: 60,
|
||||
@ -37,6 +52,9 @@ func newOptions(config map[string]interface{}, opts ...Option) (Options, error)
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
}
|
||||
if options.Log == nil {
|
||||
options.Log = log.NewTurnlog(options.Debug, log.Clone("sys.rpc", 3))
|
||||
}
|
||||
return options, nil
|
||||
}
|
||||
|
||||
@ -47,6 +65,9 @@ func newOptionsByOption(opts ...Option) (Options, error) {
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
}
|
||||
if options.Log == nil {
|
||||
options.Log = log.NewTurnlog(options.Debug, log.Clone("sys.configure", 3))
|
||||
}
|
||||
return options, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user