1
This commit is contained in:
parent
dce1028661
commit
027c7c4af6
@ -39,6 +39,10 @@ func (this *app) Init() {
|
|||||||
this.registerDataSources()
|
this.registerDataSources()
|
||||||
this.sessionHash = make(map[string]string)
|
this.sessionHash = make(map[string]string)
|
||||||
this.accountIdHash = make(map[string]string)
|
this.accountIdHash = make(map[string]string)
|
||||||
|
//seasonMt := mt.Table.RankSeason.GetCurrentSeason()
|
||||||
|
//fmt.Println("SeasonMeta =====", seasonMt)
|
||||||
|
|
||||||
|
//
|
||||||
this.initCb()
|
this.initCb()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,3 +3,6 @@ package common
|
|||||||
type App interface {
|
type App interface {
|
||||||
Run(func(), func())
|
Run(func(), func())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Task interface {
|
||||||
|
}
|
||||||
|
@ -12,6 +12,7 @@ const (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
APP_MODULE_IDX = iota
|
APP_MODULE_IDX = iota
|
||||||
|
TASK_MODULE_IDX
|
||||||
MAX_MODULE_IDX
|
MAX_MODULE_IDX
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -8,13 +8,19 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var modules [constant.MAX_MODULE_IDX]q5.Module
|
var modules [constant.MAX_MODULE_IDX]q5.Module
|
||||||
var initOrders = []int32{}
|
var initOrders = []int32{
|
||||||
|
constant.TASK_MODULE_IDX,
|
||||||
|
}
|
||||||
|
|
||||||
var app common.App
|
var app common.App
|
||||||
|
var task common.Task
|
||||||
|
|
||||||
func GetApp() common.App {
|
func GetApp() common.App {
|
||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
func GetTask() common.Task {
|
||||||
|
return task
|
||||||
|
}
|
||||||
|
|
||||||
func RegModule(idx int32, m q5.Module) {
|
func RegModule(idx int32, m q5.Module) {
|
||||||
fmt.Printf("RegModule module %d\n", idx)
|
fmt.Printf("RegModule module %d\n", idx)
|
||||||
@ -24,6 +30,10 @@ func RegModule(idx int32, m q5.Module) {
|
|||||||
{
|
{
|
||||||
app = m.(common.App)
|
app = m.(common.App)
|
||||||
}
|
}
|
||||||
|
case constant.TASK_MODULE_IDX:
|
||||||
|
{
|
||||||
|
task = m.(common.Task)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
panic("unknow module")
|
panic("unknow module")
|
||||||
|
@ -3,6 +3,7 @@ package initialize
|
|||||||
import (
|
import (
|
||||||
_ "main/app"
|
_ "main/app"
|
||||||
. "main/global"
|
. "main/global"
|
||||||
|
_ "main/task"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init() {
|
func Init() {
|
||||||
|
58
server/gameservice/mt/RankSeason.go
Normal file
58
server/gameservice/mt/RankSeason.go
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
package mt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"f5"
|
||||||
|
"mtb"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type RankSeason struct {
|
||||||
|
mtb.RankSeason
|
||||||
|
_start_time int64
|
||||||
|
_end_time int64
|
||||||
|
}
|
||||||
|
|
||||||
|
type RankSeasonTable struct {
|
||||||
|
f5.IdMetaTable[RankSeason]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *RankSeason) Init1() {
|
||||||
|
dt1, _ := time.Parse("2006-1-02 15:04:05", this.GetStartTime())
|
||||||
|
this._start_time = dt1.Unix()
|
||||||
|
dt2, _ := time.Parse("2006-1-02 15:04:05", this.GetEndTime())
|
||||||
|
this._end_time = dt2.Unix()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *RankSeasonTable) PostInit1() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *RankSeasonTable) GetCurrentSeason() *RankSeason {
|
||||||
|
var result *RankSeason
|
||||||
|
this.Traverse(
|
||||||
|
func(meta *RankSeason) bool {
|
||||||
|
if f5.GetApp().GetNowSeconds() >= meta._start_time &&
|
||||||
|
f5.GetApp().GetNowSeconds() <= meta._end_time {
|
||||||
|
result = meta
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *RankSeasonTable) GetLastSeason() *RankSeason {
|
||||||
|
var leastSeason *RankSeason
|
||||||
|
this.Traverse(
|
||||||
|
func(meta *RankSeason) bool {
|
||||||
|
if f5.GetApp().GetNowSeconds() >= meta._start_time {
|
||||||
|
if leastSeason == nil {
|
||||||
|
leastSeason = meta
|
||||||
|
} else if leastSeason._end_time < meta._end_time {
|
||||||
|
leastSeason = meta
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
return leastSeason
|
||||||
|
}
|
@ -1,34 +1,40 @@
|
|||||||
package mt
|
package mt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"f5"
|
"f5"
|
||||||
)
|
)
|
||||||
|
|
||||||
type table struct {
|
type table struct {
|
||||||
AdminCluster *AdminClusterTable
|
AdminCluster *AdminClusterTable
|
||||||
GameDb *GameDbTable
|
GameDb *GameDbTable
|
||||||
FriendDb *FriendDbTable
|
FriendDb *FriendDbTable
|
||||||
Config *ConfigTable
|
Config *ConfigTable
|
||||||
}
|
RankSeason *RankSeasonTable
|
||||||
|
}
|
||||||
var Table = f5.New(func (this* table) {
|
|
||||||
this.AdminCluster = f5.New(func (this *AdminClusterTable) {
|
var Table = f5.New(func(this *table) {
|
||||||
this.FileName = "../config/adminserver.cluster.json"
|
this.AdminCluster = f5.New(func(this *AdminClusterTable) {
|
||||||
this.PrimKey = "instance_id"
|
this.FileName = "../config/adminserver.cluster.json"
|
||||||
});
|
this.PrimKey = "instance_id"
|
||||||
|
})
|
||||||
this.GameDb = f5.New(func (this *GameDbTable) {
|
|
||||||
this.FileName = "../config/gamedb.mysql.json"
|
this.GameDb = f5.New(func(this *GameDbTable) {
|
||||||
this.PrimKey = ""
|
this.FileName = "../config/gamedb.mysql.json"
|
||||||
});
|
this.PrimKey = ""
|
||||||
|
})
|
||||||
this.FriendDb = f5.New(func (this *FriendDbTable) {
|
|
||||||
this.FileName = "../config/frienddb.mysql.json"
|
this.FriendDb = f5.New(func(this *FriendDbTable) {
|
||||||
this.PrimKey = ""
|
this.FileName = "../config/frienddb.mysql.json"
|
||||||
});
|
this.PrimKey = ""
|
||||||
|
})
|
||||||
this.Config = f5.New(func (this *ConfigTable) {
|
|
||||||
this.FileName = "../config/config.json"
|
this.Config = f5.New(func(this *ConfigTable) {
|
||||||
this.PrimKey = ""
|
this.FileName = "../config/config.json"
|
||||||
});
|
this.PrimKey = ""
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.RankSeason = f5.New(func(this *RankSeasonTable) {
|
||||||
|
this.FileName = "../res/rankSeason@rankSeason.json"
|
||||||
|
this.PrimKey = "id"
|
||||||
|
})
|
||||||
|
})
|
||||||
|
@ -1,221 +1,290 @@
|
|||||||
package mtb
|
package mtb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"f5"
|
"f5"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AdminCluster struct {
|
type AdminCluster struct {
|
||||||
instance_id int32
|
instance_id int32
|
||||||
listen_port int32
|
listen_port int32
|
||||||
http_listen_port int32
|
http_listen_port int32
|
||||||
|
|
||||||
_flags1_ uint64
|
_flags1_ uint64
|
||||||
_flags2_ uint64
|
_flags2_ uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
type MasterCluster struct {
|
type GameDb struct {
|
||||||
instance_id int32
|
host string
|
||||||
ip string
|
port int32
|
||||||
listen_port int32
|
user string
|
||||||
|
passwd string
|
||||||
_flags1_ uint64
|
database string
|
||||||
_flags2_ uint64
|
|
||||||
}
|
_flags1_ uint64
|
||||||
|
_flags2_ uint64
|
||||||
type GameDb struct {
|
}
|
||||||
host string
|
|
||||||
port int32
|
type FriendDb struct {
|
||||||
user string
|
host string
|
||||||
passwd string
|
port int32
|
||||||
database string
|
user string
|
||||||
|
passwd string
|
||||||
_flags1_ uint64
|
database string
|
||||||
_flags2_ uint64
|
|
||||||
}
|
_flags1_ uint64
|
||||||
|
_flags2_ uint64
|
||||||
type FriendDb struct {
|
}
|
||||||
host string
|
|
||||||
port int32
|
type AdminDb struct {
|
||||||
user string
|
host string
|
||||||
passwd string
|
port int32
|
||||||
database string
|
user string
|
||||||
|
passwd string
|
||||||
_flags1_ uint64
|
database string
|
||||||
_flags2_ uint64
|
|
||||||
}
|
_flags1_ uint64
|
||||||
|
_flags2_ uint64
|
||||||
type Config struct {
|
}
|
||||||
gameapi_url string
|
|
||||||
|
type Config struct {
|
||||||
_flags1_ uint64
|
gameapi_url string
|
||||||
_flags2_ uint64
|
|
||||||
}
|
_flags1_ uint64
|
||||||
|
_flags2_ uint64
|
||||||
func (this *AdminCluster) GetInstanceId() int32 {
|
}
|
||||||
return this.instance_id
|
|
||||||
}
|
type RankSeason struct {
|
||||||
|
id int32
|
||||||
func (this *AdminCluster) HasInstanceId() bool {
|
name string
|
||||||
return (this._flags1_ & (uint64(1) << 1)) > 0
|
start_time string
|
||||||
}
|
end_time string
|
||||||
|
|
||||||
func (this *AdminCluster) GetListenPort() int32 {
|
_flags1_ uint64
|
||||||
return this.listen_port
|
_flags2_ uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *AdminCluster) HasListenPort() bool {
|
func (this *AdminCluster) GetInstanceId() int32 {
|
||||||
return (this._flags1_ & (uint64(1) << 2)) > 0
|
return this.instance_id
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *AdminCluster) GetHttpListenPort() int32 {
|
func (this *AdminCluster) HasInstanceId() bool {
|
||||||
return this.http_listen_port
|
return (this._flags1_ & (uint64(1) << 1)) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *AdminCluster) HasHttpListenPort() bool {
|
func (this *AdminCluster) GetListenPort() int32 {
|
||||||
return (this._flags1_ & (uint64(1) << 3)) > 0
|
return this.listen_port
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *MasterCluster) GetInstanceId() int32 {
|
func (this *AdminCluster) HasListenPort() bool {
|
||||||
return this.instance_id
|
return (this._flags1_ & (uint64(1) << 2)) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *MasterCluster) HasInstanceId() bool {
|
func (this *AdminCluster) GetHttpListenPort() int32 {
|
||||||
return (this._flags1_ & (uint64(1) << 1)) > 0
|
return this.http_listen_port
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *MasterCluster) GetIp() string {
|
func (this *AdminCluster) HasHttpListenPort() bool {
|
||||||
return this.ip
|
return (this._flags1_ & (uint64(1) << 3)) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *MasterCluster) HasIp() bool {
|
func (this *GameDb) GetHost() string {
|
||||||
return (this._flags1_ & (uint64(1) << 2)) > 0
|
return this.host
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *MasterCluster) GetListenPort() int32 {
|
func (this *GameDb) HasHost() bool {
|
||||||
return this.listen_port
|
return (this._flags1_ & (uint64(1) << 1)) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *MasterCluster) HasListenPort() bool {
|
func (this *GameDb) GetPort() int32 {
|
||||||
return (this._flags1_ & (uint64(1) << 3)) > 0
|
return this.port
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *GameDb) GetHost() string {
|
func (this *GameDb) HasPort() bool {
|
||||||
return this.host
|
return (this._flags1_ & (uint64(1) << 2)) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *GameDb) HasHost() bool {
|
func (this *GameDb) GetUser() string {
|
||||||
return (this._flags1_ & (uint64(1) << 1)) > 0
|
return this.user
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *GameDb) GetPort() int32 {
|
func (this *GameDb) HasUser() bool {
|
||||||
return this.port
|
return (this._flags1_ & (uint64(1) << 3)) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *GameDb) HasPort() bool {
|
func (this *GameDb) GetPasswd() string {
|
||||||
return (this._flags1_ & (uint64(1) << 2)) > 0
|
return this.passwd
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *GameDb) GetUser() string {
|
func (this *GameDb) HasPasswd() bool {
|
||||||
return this.user
|
return (this._flags1_ & (uint64(1) << 4)) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *GameDb) HasUser() bool {
|
func (this *GameDb) GetDatabase() string {
|
||||||
return (this._flags1_ & (uint64(1) << 3)) > 0
|
return this.database
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *GameDb) GetPasswd() string {
|
func (this *GameDb) HasDatabase() bool {
|
||||||
return this.passwd
|
return (this._flags1_ & (uint64(1) << 5)) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *GameDb) HasPasswd() bool {
|
func (this *FriendDb) GetHost() string {
|
||||||
return (this._flags1_ & (uint64(1) << 4)) > 0
|
return this.host
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *GameDb) GetDatabase() string {
|
func (this *FriendDb) HasHost() bool {
|
||||||
return this.database
|
return (this._flags1_ & (uint64(1) << 1)) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *GameDb) HasDatabase() bool {
|
func (this *FriendDb) GetPort() int32 {
|
||||||
return (this._flags1_ & (uint64(1) << 5)) > 0
|
return this.port
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *FriendDb) GetHost() string {
|
func (this *FriendDb) HasPort() bool {
|
||||||
return this.host
|
return (this._flags1_ & (uint64(1) << 2)) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *FriendDb) HasHost() bool {
|
func (this *FriendDb) GetUser() string {
|
||||||
return (this._flags1_ & (uint64(1) << 1)) > 0
|
return this.user
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *FriendDb) GetPort() int32 {
|
func (this *FriendDb) HasUser() bool {
|
||||||
return this.port
|
return (this._flags1_ & (uint64(1) << 3)) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *FriendDb) HasPort() bool {
|
func (this *FriendDb) GetPasswd() string {
|
||||||
return (this._flags1_ & (uint64(1) << 2)) > 0
|
return this.passwd
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *FriendDb) GetUser() string {
|
func (this *FriendDb) HasPasswd() bool {
|
||||||
return this.user
|
return (this._flags1_ & (uint64(1) << 4)) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *FriendDb) HasUser() bool {
|
func (this *FriendDb) GetDatabase() string {
|
||||||
return (this._flags1_ & (uint64(1) << 3)) > 0
|
return this.database
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *FriendDb) GetPasswd() string {
|
func (this *FriendDb) HasDatabase() bool {
|
||||||
return this.passwd
|
return (this._flags1_ & (uint64(1) << 5)) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *FriendDb) HasPasswd() bool {
|
func (this *AdminDb) GetHost() string {
|
||||||
return (this._flags1_ & (uint64(1) << 4)) > 0
|
return this.host
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *FriendDb) GetDatabase() string {
|
func (this *AdminDb) HasHost() bool {
|
||||||
return this.database
|
return (this._flags1_ & (uint64(1) << 1)) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *FriendDb) HasDatabase() bool {
|
func (this *AdminDb) GetPort() int32 {
|
||||||
return (this._flags1_ & (uint64(1) << 5)) > 0
|
return this.port
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Config) GetGameapiUrl() string {
|
func (this *AdminDb) HasPort() bool {
|
||||||
return this.gameapi_url
|
return (this._flags1_ & (uint64(1) << 2)) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Config) HasGameapiUrl() bool {
|
func (this *AdminDb) GetUser() string {
|
||||||
return (this._flags1_ & (uint64(1) << 1)) > 0
|
return this.user
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *AdminDb) HasUser() bool {
|
||||||
func (this *AdminCluster) LoadFromKv(kv map[string]interface{}) {
|
return (this._flags1_ & (uint64(1) << 3)) > 0
|
||||||
f5.ReadMetaTableField(&this.instance_id, "instance_id", &this._flags1_, 1, kv)
|
}
|
||||||
f5.ReadMetaTableField(&this.listen_port, "listen_port", &this._flags1_, 2, kv)
|
|
||||||
f5.ReadMetaTableField(&this.http_listen_port, "http_listen_port", &this._flags1_, 3, kv)
|
func (this *AdminDb) GetPasswd() string {
|
||||||
}
|
return this.passwd
|
||||||
|
}
|
||||||
func (this *MasterCluster) LoadFromKv(kv map[string]interface{}) {
|
|
||||||
f5.ReadMetaTableField(&this.instance_id, "instance_id", &this._flags1_, 1, kv)
|
func (this *AdminDb) HasPasswd() bool {
|
||||||
f5.ReadMetaTableField(&this.ip, "ip", &this._flags1_, 2, kv)
|
return (this._flags1_ & (uint64(1) << 4)) > 0
|
||||||
f5.ReadMetaTableField(&this.listen_port, "listen_port", &this._flags1_, 3, kv)
|
}
|
||||||
}
|
|
||||||
|
func (this *AdminDb) GetDatabase() string {
|
||||||
func (this *GameDb) LoadFromKv(kv map[string]interface{}) {
|
return this.database
|
||||||
f5.ReadMetaTableField(&this.host, "host", &this._flags1_, 1, kv)
|
}
|
||||||
f5.ReadMetaTableField(&this.port, "port", &this._flags1_, 2, kv)
|
|
||||||
f5.ReadMetaTableField(&this.user, "user", &this._flags1_, 3, kv)
|
func (this *AdminDb) HasDatabase() bool {
|
||||||
f5.ReadMetaTableField(&this.passwd, "passwd", &this._flags1_, 4, kv)
|
return (this._flags1_ & (uint64(1) << 5)) > 0
|
||||||
f5.ReadMetaTableField(&this.database, "database", &this._flags1_, 5, kv)
|
}
|
||||||
}
|
|
||||||
|
func (this *Config) GetGameapiUrl() string {
|
||||||
func (this *FriendDb) LoadFromKv(kv map[string]interface{}) {
|
return this.gameapi_url
|
||||||
f5.ReadMetaTableField(&this.host, "host", &this._flags1_, 1, kv)
|
}
|
||||||
f5.ReadMetaTableField(&this.port, "port", &this._flags1_, 2, kv)
|
|
||||||
f5.ReadMetaTableField(&this.user, "user", &this._flags1_, 3, kv)
|
func (this *Config) HasGameapiUrl() bool {
|
||||||
f5.ReadMetaTableField(&this.passwd, "passwd", &this._flags1_, 4, kv)
|
return (this._flags1_ & (uint64(1) << 1)) > 0
|
||||||
f5.ReadMetaTableField(&this.database, "database", &this._flags1_, 5, kv)
|
}
|
||||||
}
|
|
||||||
|
func (this *RankSeason) GetId() int32 {
|
||||||
func (this *Config) LoadFromKv(kv map[string]interface{}) {
|
return this.id
|
||||||
f5.ReadMetaTableField(&this.gameapi_url, "gameapi_url", &this._flags1_, 1, kv)
|
}
|
||||||
}
|
|
||||||
|
func (this *RankSeason) HasId() bool {
|
||||||
|
return (this._flags1_ & (uint64(1) << 1)) > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *RankSeason) GetName() string {
|
||||||
|
return this.name
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *RankSeason) HasName() bool {
|
||||||
|
return (this._flags1_ & (uint64(1) << 2)) > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *RankSeason) GetStartTime() string {
|
||||||
|
return this.start_time
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *RankSeason) HasStartTime() bool {
|
||||||
|
return (this._flags1_ & (uint64(1) << 3)) > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *RankSeason) GetEndTime() string {
|
||||||
|
return this.end_time
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *RankSeason) HasEndTime() bool {
|
||||||
|
return (this._flags1_ & (uint64(1) << 4)) > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (this *AdminCluster) LoadFromKv(kv map[string]interface{}) {
|
||||||
|
f5.ReadMetaTableField(&this.instance_id, "instance_id", &this._flags1_, 1, kv)
|
||||||
|
f5.ReadMetaTableField(&this.listen_port, "listen_port", &this._flags1_, 2, kv)
|
||||||
|
f5.ReadMetaTableField(&this.http_listen_port, "http_listen_port", &this._flags1_, 3, kv)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *GameDb) LoadFromKv(kv map[string]interface{}) {
|
||||||
|
f5.ReadMetaTableField(&this.host, "host", &this._flags1_, 1, kv)
|
||||||
|
f5.ReadMetaTableField(&this.port, "port", &this._flags1_, 2, kv)
|
||||||
|
f5.ReadMetaTableField(&this.user, "user", &this._flags1_, 3, kv)
|
||||||
|
f5.ReadMetaTableField(&this.passwd, "passwd", &this._flags1_, 4, kv)
|
||||||
|
f5.ReadMetaTableField(&this.database, "database", &this._flags1_, 5, kv)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *FriendDb) LoadFromKv(kv map[string]interface{}) {
|
||||||
|
f5.ReadMetaTableField(&this.host, "host", &this._flags1_, 1, kv)
|
||||||
|
f5.ReadMetaTableField(&this.port, "port", &this._flags1_, 2, kv)
|
||||||
|
f5.ReadMetaTableField(&this.user, "user", &this._flags1_, 3, kv)
|
||||||
|
f5.ReadMetaTableField(&this.passwd, "passwd", &this._flags1_, 4, kv)
|
||||||
|
f5.ReadMetaTableField(&this.database, "database", &this._flags1_, 5, kv)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *AdminDb) LoadFromKv(kv map[string]interface{}) {
|
||||||
|
f5.ReadMetaTableField(&this.host, "host", &this._flags1_, 1, kv)
|
||||||
|
f5.ReadMetaTableField(&this.port, "port", &this._flags1_, 2, kv)
|
||||||
|
f5.ReadMetaTableField(&this.user, "user", &this._flags1_, 3, kv)
|
||||||
|
f5.ReadMetaTableField(&this.passwd, "passwd", &this._flags1_, 4, kv)
|
||||||
|
f5.ReadMetaTableField(&this.database, "database", &this._flags1_, 5, kv)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Config) LoadFromKv(kv map[string]interface{}) {
|
||||||
|
f5.ReadMetaTableField(&this.gameapi_url, "gameapi_url", &this._flags1_, 1, kv)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *RankSeason) LoadFromKv(kv map[string]interface{}) {
|
||||||
|
f5.ReadMetaTableField(&this.id, "id", &this._flags1_, 1, kv)
|
||||||
|
f5.ReadMetaTableField(&this.name, "name", &this._flags1_, 2, kv)
|
||||||
|
f5.ReadMetaTableField(&this.start_time, "start_time", &this._flags1_, 3, kv)
|
||||||
|
f5.ReadMetaTableField(&this.end_time, "end_time", &this._flags1_, 4, kv)
|
||||||
|
}
|
||||||
|
@ -40,3 +40,11 @@ message Config
|
|||||||
{
|
{
|
||||||
optional string gameapi_url = 1;
|
optional string gameapi_url = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message RankSeason
|
||||||
|
{
|
||||||
|
optional int32 id = 1;
|
||||||
|
optional string name = 2;
|
||||||
|
optional string start_time = 3;
|
||||||
|
optional string end_time = 4;
|
||||||
|
}
|
||||||
|
12
server/gameservice/task/export.go
Normal file
12
server/gameservice/task/export.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package task
|
||||||
|
|
||||||
|
import (
|
||||||
|
"main/constant"
|
||||||
|
"main/global"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _task = new(taskMgr)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
global.RegModule(constant.TASK_MODULE_IDX, _task)
|
||||||
|
}
|
119
server/gameservice/task/seasonRanking.go
Normal file
119
server/gameservice/task/seasonRanking.go
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
package task
|
||||||
|
|
||||||
|
import (
|
||||||
|
"f5"
|
||||||
|
"fmt"
|
||||||
|
"main/constant"
|
||||||
|
"q5"
|
||||||
|
)
|
||||||
|
|
||||||
|
type RankingList struct {
|
||||||
|
idx int64
|
||||||
|
account_id string
|
||||||
|
address string
|
||||||
|
channel int32
|
||||||
|
rank int32
|
||||||
|
score int32
|
||||||
|
ranking int32
|
||||||
|
ranking_point int32
|
||||||
|
season int32
|
||||||
|
createtime int32
|
||||||
|
modifytime int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type userDb struct {
|
||||||
|
idx int64
|
||||||
|
account_id string
|
||||||
|
address string
|
||||||
|
channel int32
|
||||||
|
rank int32
|
||||||
|
score int32
|
||||||
|
score_modifytime int64
|
||||||
|
}
|
||||||
|
|
||||||
|
type SeasonRankMgr struct {
|
||||||
|
userData map[int64]*userDb
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *SeasonRankMgr) Init() {
|
||||||
|
this.userData = make(map[int64]*userDb)
|
||||||
|
this.CalcRanking()
|
||||||
|
fmt.Println("Task init success")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *SeasonRankMgr) UnInit() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// var lastIdx int64 = 0
|
||||||
|
var done bool = false
|
||||||
|
var baseScore int32 = 4000
|
||||||
|
|
||||||
|
func (this *SeasonRankMgr) CalcRanking() {
|
||||||
|
lastIdx := int64(0)
|
||||||
|
this.getUsersRecords(lastIdx, 100)
|
||||||
|
//for !done {
|
||||||
|
// this.getUsersRecords(lastIdx, 10)
|
||||||
|
//}
|
||||||
|
this.pushRankingResult()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *SeasonRankMgr) getUsersRecords(lastIdx int64, limit int64) {
|
||||||
|
sql := fmt.Sprintf("SELECT idx,account_id,channel,`rank`,score,score_modifytime,`address` FROM t_user WHERE score > %d and idx > %d limit %d",
|
||||||
|
baseScore, lastIdx, limit)
|
||||||
|
f5.GetJsStyleDb().SelectCustomQuery(
|
||||||
|
constant.GAME_DB,
|
||||||
|
sql,
|
||||||
|
func(err error, rows *f5.DataSet) {
|
||||||
|
if err != nil {
|
||||||
|
f5.GetSysLog().Info("getUsersRecords Error:%v \n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
empty := true
|
||||||
|
for rows.Next() {
|
||||||
|
empty = false
|
||||||
|
user := userDb{}
|
||||||
|
user.idx = q5.ToInt64(*rows.GetByName("idx"))
|
||||||
|
user.account_id = q5.ToString(*rows.GetByName("account_id"))
|
||||||
|
user.address = q5.ToString(*rows.GetByName("address"))
|
||||||
|
user.channel = q5.ToInt32(*rows.GetByName("channel"))
|
||||||
|
user.rank = q5.ToInt32(*rows.GetByName("rank"))
|
||||||
|
user.score = q5.ToInt32(*rows.GetByName("score"))
|
||||||
|
user.score_modifytime = q5.ToInt64(*rows.GetByName("score_modifytime"))
|
||||||
|
this.userData[user.idx] = &user
|
||||||
|
lastIdx = q5.ToInt64(*rows.GetByName("idx"))
|
||||||
|
}
|
||||||
|
if empty {
|
||||||
|
done = true
|
||||||
|
}
|
||||||
|
fmt.Println(this.userData)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
//return userDbs
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *SeasonRankMgr) pushRankingResult() {
|
||||||
|
for _, v := range this.userData {
|
||||||
|
fields := [][]string{
|
||||||
|
{"account_id", v.account_id},
|
||||||
|
{"address", v.address},
|
||||||
|
{"channel", q5.ToString(v.channel)},
|
||||||
|
{"rank", q5.ToString(v.rank)},
|
||||||
|
{"score", q5.ToString(v.score)},
|
||||||
|
{"season", q5.ToString(2)},
|
||||||
|
{"createtime", q5.ToString(f5.GetApp().GetNowSeconds())},
|
||||||
|
{"modifytime", q5.ToString(f5.GetApp().GetNowSeconds())},
|
||||||
|
}
|
||||||
|
f5.GetJsStyleDb().Insert(
|
||||||
|
constant.GAME_DB,
|
||||||
|
"t_season_ranking",
|
||||||
|
fields,
|
||||||
|
func(err error, id int64, affectedRows int64) {
|
||||||
|
if err != nil || affectedRows != 1 {
|
||||||
|
// 插入失败,处理错误逻辑
|
||||||
|
fmt.Printf("Failed to insert guild: %v", err)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
14
server/gameservice/task/taskMgr.go
Normal file
14
server/gameservice/task/taskMgr.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package task
|
||||||
|
|
||||||
|
type taskMgr struct {
|
||||||
|
SeasonRankMgr
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *taskMgr) Init() {
|
||||||
|
t.SeasonRankMgr.Init()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *taskMgr) UnInit() {
|
||||||
|
t.SeasonRankMgr.UnInit()
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user