feat-api.go
1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package configs
import (
"apigame/common/svconst"
"apigame/common/svdto"
"apigame/common/svmysql"
"apigame/common/svredis"
"apigame/util/utdto"
"fmt"
)
// ApiGameConfig api游戏配置
type ApiGameConfig 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"`
}
func (c *ApiGameConfig) TableName() string { return utdto.MYSQL_TABLE_TEMPLATE }
func (c *ApiGameConfig) GetRule(gameId string) *svdto.DtoRule {
tableName := "s_game_config"
return &svdto.DtoRule{
DbMysql: svconst.DbApi.Where("gameid = ?", gameId),
TableName: tableName,
CacheKey: fmt.Sprintf("%s:%s:%s", svdto.REDIS_CACHEP_REFIX, tableName, gameId),
CacheTime: 300,
}
}
func (c *ApiGameConfig) RedisInfo(gameId string) *svredis.RedisInfo {
tableName := "s_game_config"
return &svredis.RedisInfo{
CacheKey: fmt.Sprintf("%s:%s:%s", svdto.REDIS_CACHEP_REFIX, tableName, gameId),
CacheTime: 300,
}
}
func (c *ApiGameConfig) MysqlInfo(gameId string) *svmysql.MysqlInfo {
tableName := "s_game_config"
return &svmysql.MysqlInfo{
DbMysql: svconst.DbApi.Where("gameid = ?", gameId),
TableName: tableName,
}
}