get.go
1.1 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
package confroomrank
import (
"apigame/configs/confbase"
"apigame/util/util-lx/lxalilog"
"apigame/util/util-lx/lxtime"
)
// GetCurrent 获取 当前配置
func GetCurrent(gameId string, topType int) (conf *ActivityConfig, has bool) {
conf = new(ActivityConfig)
conf.Typ = topType
has = confbase.GetCurrent[*ActivityConfig, ActivityConfigRaw](gameId, conf)
return
}
// GetConfig 获取 配置根据Id
func GetConfig(gameId string, confId int64) (conf *ActivityConfig, has bool) {
conf = new(ActivityConfig)
has = confbase.GetConfig[*ActivityConfig, ActivityConfigRaw](gameId, confId, conf)
return
}
// GetCurrentConfigs 获取当前配置列表
func GetCurrentConfigs(gameId string) []*ActivityConfigRaw {
obj := new(ActivityConfig)
info := obj.ConfInfo(gameId)
db := info.DbMysql
timeNow := lxtime.NowUninx()
objs := make([]*ActivityConfigRaw, 0)
result := db.Table(info.TableName).Where(
"status = ? AND start_time <= ? AND end_time >= ?",
1, timeNow, timeNow).Find(&objs)
if result.Error != nil {
lxalilog.Errors(result.Error, "confroomrank.GetCurrentConfigs error", gameId)
}
return objs
}