api.go
5.74 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
package config
import (
"apigame/lx-util/lxalilog"
"apigame/lx-util/lxconv"
"apigame/lx-util/lxmysql"
"encoding/json"
"errors"
"fmt"
)
type MApiGameConfig struct {
AppID string `json:"appid"`
Secret string `json:"secret"`
Appkey string `json:"appkey"`
Name string `json:"name"`
}
// GetApiGameConfig 获取游戏配置文件
func GetApiGameConfig(gameid string) (data MApiGameConfig, err error) {
config := lxmysql.QueryCacheConfig{
SQL: fmt.Sprintf("select appid,secret,appkey,name from s_game_config where isdel=0 and status=1 and gameid='%s' order by id desc limit 1", gameid),
DBIndex: CONST_APIDBINDEX,
Exexpire: CONST_CACHETIME,
}
var datas []MApiGameConfig
err = lxmysql.QueryWithCache(config, &datas)
if err != nil {
lxalilog.Errors(err, lxconv.JsonEncode(config))
return
}
if len(datas) < 1 {
err = errors.New("no rows")
lxalilog.Errors(err)
return
}
data = datas[0]
return
}
type MApiServerConfig struct {
Egift MApiServerEgift `json:"egift"` //无尽轮换
Membership []Membership `json:"membership"` //周卡 月卡
Novicegift Novicegift `json:"novicegift"` // 新手礼包
PassCheck []PassCheck `json:"pass_check"` //通行证
Qixi QixiConfig `json:"qixi"` //七夕活动
Thinkingdata ThinkingdataConfig `json:"thinkingdata"` //数数配置
}
// --------------------------- 无尽轮换礼包配置表 ---------------------------
// MApiServerEgift 无尽轮换礼包配置表
type MApiServerEgift struct {
Config []MApiServerEgiftConfig `json:"config"`
ListLength string `json:"list_length"`
Days string `json:"days"`
Date string `json:"date"`
}
type MApiServerEgiftConfig struct {
ID string `json:"id"`
Award string `json:"award"`
Type string `json:"type"`
ShopID string `json:"shop_id"`
GroupID string `json:"group_id,omitempty"`
}
// --------------------------- 无尽轮换礼包配置表 ---------------------------
// --------------------------- 周卡 月卡 配置 ---------------------------
type Membership struct {
Name string `json:"name"` // 模式名称
Days string `json:"days"` // 第几天
Goodid string `json:"goodid"` // 商品ID
Award string `json:"award"` // 奖励
Naturalday string `json:"naturalday"` // 是否自然日
}
// --------------------------- 周卡 月卡 配置 ---------------------------
// --------------------------- 新手 配置 ---------------------------
type Novicegift struct {
Goodid string `json:"goodid"` // 商品ID
List []struct {
Days string `json:"days"` // 第几天
Award string `json:"award"` // 奖励
} `json:"list"`
}
// --------------------------- 新手礼包 配置 ---------------------------
type PassCheck struct {
ID string `json:"ID"`
Level string `json:"Level"`
GroupId string `json:"GroupId"`
GoodId string `json:"GoodId"`
Experience string `json:"Experience"`
AwardFree string `json:"AwardFree"`
AwardPay string `json:"AwardPay"`
DrawTime int64 `json:"DrawTime"`
}
// --------------------------- 七夕活动 ---------------------------
type QixiConfig struct {
ActivityId string `json:"activity_id"`
StartTime int64 `json:"start_time"`
EndTime int64 `json:"end_time"`
Awards []QixiConfigAwards `json:"awards"`
FalseProgress []QixiConfigFalseProgress `json:"false_progress"`
Mail QixiConfigMail `json:"mail"`
RankConfig QixiConfigRankConfig `json:"rank_config"`
AlilogName string `json:"alilog_name"`
AddMax int64 `json:"add_max"`
}
type QixiConfigFalseProgress struct {
Day string `json:"day"`
Time string `json:"time"`
ChangeLowest string `json:"change_lowest"`
ChangeHighest string `json:"change_highest"`
Must string `json:"must"`
}
type QixiConfigAwards struct {
Point string `json:"point"`
AwardType string `json:"award_type"`
AwardNumber string `json:"award_number"`
LowLimit string `json:"low_limit"`
HighLimit string `json:"high_limit"`
}
type QixiConfigMail struct {
Title string `json:"title"`
Sender string `json:"sender"`
Content string `json:"content"`
Ex int64 `json:"ex"`
}
type QixiConfigRankConfig struct {
MinPoint int64 `json:"min_point"`
}
// --------------------------- 七夕活动 ---------------------------
// --------------------------- 数数配置 ---------------------------
type ThinkingdataConfig struct {
Appid string `json:"appid"`
Id int `json:"id"`
Swich struct {
Engine int `json:"engine"`
Order int `json:"order"`
Pass int `json:"pass"`
Recharge int `json:"recharge"` // 累计充值 开启
} `json:"switch"`
}
// --------------------------- 数数配置 ---------------------------
// GetApiServerConfig 获取游服务端置文件
func GetApiServerConfig(gameid string, dbindex ...string) (data MApiServerConfig, content string, err error) {
var dindex = CONST_APIDBINDEX
if len(dbindex) > 0 {
dindex = dbindex[0]
}
config := lxmysql.QueryCacheConfig{
SQL: fmt.Sprintf("select * from s_server_config where gameid='%s' limit 1", gameid),
DBIndex: dindex,
Exexpire: CONST_CACHETIME,
}
var datas []struct {
Content string `json:"content"`
}
err = lxmysql.QueryWithCache(config, &datas)
if err != nil {
lxalilog.Errors(err, lxconv.JsonEncode(config))
return
}
if len(datas) < 1 {
err = errors.New("no rows")
lxalilog.Errors(err)
return
}
if datas[0].Content == "" {
err = errors.New("content nil")
lxalilog.Errors(err)
}
content = datas[0].Content
_ = json.Unmarshal([]byte(content), &data)
return
}