config.go 1.21 KB
package confapi

import (
	"apigame/configs/confbase"
	"apigame/service-common/svconst"
	"apigame/service-common/svmysql"
	"apigame/service-common/svredis"
	"fmt"
)

// ApiGameConfig api游戏配置
type ApiGameConfig struct {
	Raw *Raw
}

func (c *ApiGameConfig) ConfInfo(suffix string) *confbase.ConfInfo {
	tableName := "s_game_config"
	return &confbase.ConfInfo{
		DbMysql:   svconst.DbApi,
		TableName: tableName,
		KeyName:   "gameid",
		CacheKey:  fmt.Sprintf("%s:%s:%s", svconst.REDIS_CACHEP_REFIX, tableName, suffix),
		CacheTime: 300,
	}
}

func (c *ApiGameConfig) RedisInfo(suffix string) *svredis.RedisInfo {
	tableName := "s_game_config"
	return &svredis.RedisInfo{
		CacheKey:  fmt.Sprintf("%s:%s:%s", svconst.REDIS_CACHEP_REFIX, tableName, suffix),
		CacheTime: 300,
	}
}

func (c *ApiGameConfig) MysqlInfo(suffix string) *svmysql.MysqlInfo {
	tableName := "s_game_config"
	return &svmysql.MysqlInfo{
		DbMysql:   svconst.DbApi.Where("gameid = ?", suffix),
		TableName: tableName,
	}
}

// Raw 配置原始数据
type Raw struct {
	AppId  string `gorm:"column:appid"`
	GameId string `gorm:"column:gameid"`
	Secret string `gorm:"column:secret"`
	AppKey string `gorm:"column:appkey"`
	Name   string `gorm:"column:name"`
}