configs.go
1.56 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package ht_cardholder
import (
"apigame/api-util/umysql"
"apigame/lx-util/lxalilog"
"apigame/service/constd"
"fmt"
"github.com/astaxie/beego/logs"
)
// Init 初始化
func Init() {
NewConfigs()
TryUpdateConfigs()
//DumpConfigs()
}
// TryUpdateConfigs 尝试更新配置表
func TryUpdateConfigs() {
LoadConfigs()
}
// LoadConfigs 读取mysql配置
func LoadConfigs() {
configTableName := new(CardActivityConfig).TableName()
// 找到当前开放的活动
configOpen := CardActivityUpdateConfig{Id: 0}
{
conf := make([]CardActivityUpdateConfig, 0)
sql := fmt.Sprintf("select id,status,update_time from %s", configTableName)
err := umysql.FindSql(constd.MYSQL_MERGECONFIG, sql, &conf)
if err != nil {
lxalilog.Errors(err, sql, constd.GAME_ID_HT)
return
}
for _, config := range conf {
if config.Status != 0 {
configOpen = config
continue
}
}
fmt.Println(configOpen)
}
// 没有开放的活动
if configOpen.Id == 0 {
return
}
// 更新数据
if configOpen.Id != Config.Raw.Id || configOpen.UpdateTime != Config.Raw.UpdateTime {
logs.Debug("__________________尝试更新活动条目ID:", configOpen.Id)
confNew := CardActivityConfigRaw{}
sql := fmt.Sprintf("select * from %s where id=%d limit 1", configTableName, configOpen.Id)
err := umysql.FindOneSql(constd.MYSQL_MERGECONFIG, sql, &confNew)
if err != nil {
lxalilog.Errors(err, sql, constd.GAME_ID_HT, configOpen.Id)
return
}
logs.Debug("__________________更新活动条目ID:", confNew.Id)
ConfigRaws = confNew
ConfigDecode()
}
}
func DumpConfigs() {
}