diff --git a/lego/base/core.go b/lego/base/core.go index 067216238..5f2360c35 100644 --- a/lego/base/core.go +++ b/lego/base/core.go @@ -2,6 +2,7 @@ package base import ( "context" + "time" "go_dreamfactory/lego/core" @@ -74,6 +75,7 @@ type IRPCXServiceSession interface { type IRPCXService interface { IClusterServiceBase + GetOpentime() time.Time RegisterFunction(fn interface{}) (err error) RegisterFunctionName(name string, fn interface{}) (err error) RpcCall(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error) diff --git a/lego/base/rpcx/service.go b/lego/base/rpcx/service.go index c06cb5b2e..a31d4e4b0 100644 --- a/lego/base/rpcx/service.go +++ b/lego/base/rpcx/service.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "runtime" + "time" "go_dreamfactory/lego/base" "go_dreamfactory/lego/core" @@ -36,6 +37,15 @@ func (this *RPCXService) GetIp() string { func (this *RPCXService) GetPort() int { return this.opts.Setting.Port } + +func (this *RPCXService) GetOpentime() time.Time { + t, err := time.ParseInLocation("2006-01-02 15:04:05", this.GetSettings().Opentime, time.Local) + if nil == err && !t.IsZero() { + return t + } + return time.Time{} +} + func (this *RPCXService) GetCategory() core.S_Category { return this.opts.Setting.Category } diff --git a/lego/core/core.go b/lego/core/core.go index cf231e9b9..2c87aa39a 100644 --- a/lego/core/core.go +++ b/lego/core/core.go @@ -37,6 +37,7 @@ type ServiceSttings struct { Category S_Category //服务列表 (用于区分集群服务下相似业务功能的服务器 例如:游戏服务器) Ip string //服务所在Ip () Port int //服务rpcx监听端口 + Opentime string //开服时间 Comps map[string]map[string]interface{} //服务组件配置 Sys map[string]map[string]interface{} //服务系统配置 Modules map[string]map[string]interface{} //服务模块配置 diff --git a/modules/combat/api_in.go b/modules/combat/api_in.go index 267424ede..410428fe0 100644 --- a/modules/combat/api_in.go +++ b/modules/combat/api_in.go @@ -26,10 +26,10 @@ func (this *apiComp) In(session comm.IUserSession, req *pb.CombatInReq) (code pb code = pb.ErrorCode_DBError return } - if info.Currlevel != 0 { - code = pb.ErrorCode_ReqParameterError - return - } + // if info.Currlevel != 0 { + // code = pb.ErrorCode_ReqParameterError + // return + // } info.Currlevel = req.Id if err = this.module.modelCombat.updateInfo(info); err != nil { code = pb.ErrorCode_DBError diff --git a/modules/web/api_opentime.go b/modules/web/api_opentime.go new file mode 100644 index 000000000..25eec9a38 --- /dev/null +++ b/modules/web/api_opentime.go @@ -0,0 +1,17 @@ +package web + +import ( + "go_dreamfactory/lego/sys/gin/engine" + "net/http" +) + +//获取开服时间 +func (this *Api_Comp) Getopentime(c *engine.Context) { + + c.JSON(http.StatusOK, &Respond{ + Code: 0, + Message: "成功", + Data: this.module.service.GetOpentime(), + }) + +}