版本更新
This commit is contained in:
parent
44c1192ae0
commit
2176a9dd4b
@ -151,18 +151,10 @@ func GetMaxFileVersion(version int, nextToken string) int {
|
||||
UnionId: tea.String(UNIONID),
|
||||
}
|
||||
resp, _err := client.ListDentryVersionsWithOptions(tea.String("28057154815"), tea.String("206700372014"), listDentryVersionsRequest, listDentryVersionsHeaders, &util.RuntimeOptions{})
|
||||
if resp.Body.NextToken != nil {
|
||||
fmt.Println("nextToken:", *resp.Body.NextToken)
|
||||
maxVersion := 0
|
||||
for _, v := range resp.Body.Dentries {
|
||||
if int(*v.Version) > maxVersion {
|
||||
maxVersion = int(*v.Version)
|
||||
}
|
||||
}
|
||||
return GetMaxFileVersion(maxVersion, *resp.Body.NextToken)
|
||||
} else {
|
||||
return version
|
||||
if resp.Body.Dentries != nil {
|
||||
return int(*resp.Body.Dentries[0].Version)
|
||||
}
|
||||
return version
|
||||
}
|
||||
|
||||
func GetFileInfo() error {
|
||||
|
||||
@ -55,6 +55,7 @@ func AdminLogList(c *gin.Context) {
|
||||
}
|
||||
List := []*model.AdminLog{}
|
||||
db := util.MPool.GetGameDB()
|
||||
defer db.Close()
|
||||
if db == nil {
|
||||
failed(c, "Failed to get database connection")
|
||||
return
|
||||
|
||||
@ -64,8 +64,8 @@ func CopywritingStep1(c *gin.Context) {
|
||||
func CopywritingStep2(c *gin.Context) {
|
||||
time.Sleep(time.Second)
|
||||
code := 0
|
||||
repoDir := `D:\Github\docs`
|
||||
file := `config\DialogueData.xlsx`
|
||||
repoDir := `/data/docs`
|
||||
file := `config/DialogueData.xlsx`
|
||||
// git pull
|
||||
if out, err := exec.Command("git", "-C", repoDir, "pull").CombinedOutput(); err != nil {
|
||||
scritp_fail(c, "git pull 失败: "+err.Error()+": "+string(out))
|
||||
@ -152,11 +152,12 @@ func CopywritingStep3(c *gin.Context) {
|
||||
}
|
||||
var dbDatas []db_data
|
||||
db := util.MPool.GetGameDB()
|
||||
defer db.Close()
|
||||
if db == nil {
|
||||
scritp_fail(c, "获取数据库连接失败")
|
||||
return
|
||||
}
|
||||
err = db.Select(&dbDatas, "SELECT `key`, `en_us` FROM `language`")
|
||||
err = db.Select(&dbDatas, "SELECT `Id`, `key`, `en_us` FROM `language`")
|
||||
if err != nil {
|
||||
scritp_fail(c, "查询语言表失败: "+err.Error())
|
||||
return
|
||||
@ -210,10 +211,8 @@ func CopywritingStep3(c *gin.Context) {
|
||||
success(c, map[string]interface{}{
|
||||
"step": -1,
|
||||
"label": "脚本执行成功",
|
||||
"tips": []string{
|
||||
fmt.Sprintf("增加%d个key,更新%d个key", len(dialogueMap), len(updateData)),
|
||||
},
|
||||
"code": 0,
|
||||
"tips": tips,
|
||||
"code": 0,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -78,7 +78,7 @@ func UserGM(AppId, ServerId, Uid int, Command string) (interface{}, error) {
|
||||
App, err := util.GetAppConfig(AppId)
|
||||
|
||||
db := util.MPool.GetMysqlDB(App, 1)
|
||||
|
||||
defer db.Close()
|
||||
AppId, ServerId = util.ParseUid(Uid)
|
||||
node := 0
|
||||
err = db.Get(&node, "SELECT `node` FROM t_player_baseinfo WHERE dwUin = ? ", Uid)
|
||||
|
||||
@ -36,6 +36,7 @@ func (a *Admin) List() (*Result, error) {
|
||||
// 假设我们从数据库中查询到数据并返回
|
||||
var admins []Admin
|
||||
db := util.MPool.GetGameDB() // 假设使用默认的AppConfig和ServerId为0
|
||||
defer db.Close()
|
||||
if db == nil {
|
||||
return nil, fmt.Errorf("failed to get database connection")
|
||||
}
|
||||
@ -55,6 +56,7 @@ func (a *Admin) Add() (*Result, error) {
|
||||
// 这里可以添加逻辑来保存管理员信息到数据库
|
||||
// 假设我们将管理员信息插入到数据库中
|
||||
db := util.MPool.GetGameDB() // 假设使用默认的AppConfig和ServerId为0
|
||||
defer db.Close()
|
||||
if db == nil {
|
||||
return nil, fmt.Errorf("failed to get database connection")
|
||||
}
|
||||
@ -78,6 +80,7 @@ func (a *Admin) Login() (*Admin, error) {
|
||||
// 这里可以添加逻辑来验证用户名和密码
|
||||
// 假设我们从数据库中查询到管理员信息并返回
|
||||
db := util.MPool.GetGameDB() // 假设使用默认的AppConfig和ServerId为0
|
||||
defer db.Close()
|
||||
if db == nil {
|
||||
return nil, fmt.Errorf("failed to get database connection")
|
||||
}
|
||||
@ -102,6 +105,7 @@ func (a *Admin) Login() (*Admin, error) {
|
||||
|
||||
func (a *Admin) LoginByCode(phone, code string) (*Admin, error) {
|
||||
db := util.MPool.GetGameDB() // 假设使用默认的AppConfig和ServerId为0
|
||||
defer db.Close()
|
||||
if db == nil {
|
||||
return nil, fmt.Errorf("failed to get database connection")
|
||||
}
|
||||
@ -132,6 +136,7 @@ func (a *Admin) CreateToken() error {
|
||||
// 假设我们生成一个新的令牌并更新到数据库中
|
||||
a.Token = util.GenerateToken() // 假设有一个生成令牌的函数
|
||||
db := util.MPool.GetGameDB() // 假设使用默认的AppConfig和ServerId为0
|
||||
defer db.Close()
|
||||
if db == nil {
|
||||
return fmt.Errorf("failed to get database connection")
|
||||
}
|
||||
@ -146,6 +151,7 @@ func (a *Admin) CreateToken() error {
|
||||
|
||||
func (a *Admin) GetAdmin(username string) error {
|
||||
db := util.MPool.GetGameDB() // 假设使用默认的AppConfig和ServerId为0
|
||||
defer db.Close()
|
||||
if db == nil {
|
||||
return fmt.Errorf("failed to get database connection")
|
||||
}
|
||||
@ -155,6 +161,7 @@ func (a *Admin) GetAdmin(username string) error {
|
||||
func InitToken() {
|
||||
// 初始化TokenList,可以从数据库中加载现有的令牌
|
||||
db := util.MPool.GetGameDB() // 假设使用默认的AppConfig和ServerId为0
|
||||
defer db.Close()
|
||||
if db == nil {
|
||||
return
|
||||
}
|
||||
|
||||
@ -47,9 +47,14 @@ func (l *LanguageMod) LanguageList(account string) (map[string]interface{}, erro
|
||||
defer Db.Close()
|
||||
var languages []*Language
|
||||
SearchSQL := ""
|
||||
if l.SearchField != "" && l.SearchValue != "" {
|
||||
escaped := strings.ReplaceAll(l.SearchValue, "'", "''")
|
||||
SearchSQL = " `" + l.SearchField + "` like '%" + escaped + "%' "
|
||||
if l.SearchField != "" {
|
||||
if l.SearchValue != "" {
|
||||
escaped := strings.ReplaceAll(l.SearchValue, "'", "''")
|
||||
SearchSQL = " `" + l.SearchField + "` like '%" + escaped + "%' "
|
||||
} else {
|
||||
SearchSQL = " `" + l.SearchField + "` = '' "
|
||||
}
|
||||
|
||||
}
|
||||
AccountConfig := common.GetTranlaterConfig(account)
|
||||
if AccountConfig != nil {
|
||||
|
||||
@ -56,7 +56,10 @@ func (m *Mail) MailList() (*Result, error) {
|
||||
return nil, fmt.Errorf("failed to scan rows: %v", err)
|
||||
}
|
||||
var total int
|
||||
Db.Get(&total, "SELECT COUNT(*) FROM system_mail_info")
|
||||
err = Db.Get(&total, "SELECT COUNT(*) FROM system_mail_info")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get total count: %v", err)
|
||||
}
|
||||
for _, v := range mail {
|
||||
v.AppId = m.AppId
|
||||
v.ServerId = m.ServerId
|
||||
|
||||
@ -13,6 +13,7 @@ import (
|
||||
func UserAliveMonitor(AppId int) {
|
||||
AppConfig, _ := util.GetAppConfig(AppId)
|
||||
Db := util.MPool.GetTopicDB(AppConfig.Topic)
|
||||
defer Db.Close()
|
||||
for {
|
||||
//now := time.Now()
|
||||
//next := now.Truncate(time.Hour).Add(time.Hour)
|
||||
@ -83,9 +84,11 @@ func monitorServerInfo() {
|
||||
continue
|
||||
}
|
||||
go func(v *Type.ServerInfo) {
|
||||
tmpDb := util.MPool.GetGameDB()
|
||||
defer tmpDb.Close()
|
||||
res, err := model.GetServerInfo(v.AppId, v.ServerId)
|
||||
if err != nil {
|
||||
Db.Exec("update server set Status=0 where AppId=? and ServerId=?", v.AppId, v.ServerId)
|
||||
// tmpDb.Exec("update server set Status=0 where AppId=? and ServerId=?", v.AppId, v.ServerId)
|
||||
return
|
||||
}
|
||||
serverInfo := res.(map[string]interface{})
|
||||
@ -125,7 +128,7 @@ func monitorServerInfo() {
|
||||
// optionally store/update weight
|
||||
serverInfo["Weight"] = weight
|
||||
// Process serverInfo as needed
|
||||
Db.Exec("update server set Status=1, Online=?,free_mem=?,cpu=?,weight=? where AppId=? and ServerId=?", util.Int(serverInfo["PlayerNum"]), usage_mem, cpu, weight, v.AppId, v.ServerId)
|
||||
tmpDb.Exec("update server set Status=1, Online=?,free_mem=?,cpu=?,weight=? where AppId=? and ServerId=?", util.Int(serverInfo["PlayerNum"]), usage_mem, cpu, weight, v.AppId, v.ServerId)
|
||||
}(v)
|
||||
}
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ func (p *Param) ChangeOrderStatus(Platform string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
Db := util.MPool.GetMysqlDB(AppConf, p.ServerId)
|
||||
Db := util.MPool.GetMysqlDB(AppConf, 1)
|
||||
defer Db.Close()
|
||||
_, err = Db.Exec("UPDATE `t_player_charge` SET `PayStatus`=1, `PayTime`=?, `PayChannelOrderId` = ? , `PayPlatform` =? WHERE `OrderId`=? AND `PayStatus`=0", time.Now().Unix(), p.ChannelOrderId, Platform, p.OrderId)
|
||||
return err
|
||||
|
||||
@ -91,7 +91,7 @@ func TestEncrypt(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDecrypt(t *testing.T) {
|
||||
str := "`NS?VGg@7]~F3}p"
|
||||
str := "Z4rf7eZZe500dxa"
|
||||
enc, _ := util.Encrypt(str)
|
||||
dec, _ := util.Decrypt("pUf9tft9GOPjV1z855Jf2DpB5NUpGEc_")
|
||||
fmt.Printf("enc:%s\ndec:%s\n", enc, dec)
|
||||
|
||||
@ -65,17 +65,22 @@ func (m *MysqlPool) getDb(key string) *Db {
|
||||
|
||||
func (m *MysqlPool) putDb(key string, db *Db) {
|
||||
m.lock.Lock()
|
||||
defer m.lock.Unlock()
|
||||
pool := m.poolList[key]
|
||||
if pool == nil {
|
||||
pool = &poolInfo{Addr: key}
|
||||
m.poolList[key] = pool
|
||||
}
|
||||
if len(pool.DbList) > 10 {
|
||||
db.Close()
|
||||
if len(pool.DbList) >= 5 {
|
||||
// 池已满,释放锁后再关闭连接,避免递归调用 putDb 导致死锁
|
||||
m.lock.Unlock()
|
||||
if db.ssh != nil {
|
||||
db.ssh.Close()
|
||||
}
|
||||
db.DB.Close()
|
||||
return
|
||||
}
|
||||
pool.DbList = append(pool.DbList, db)
|
||||
m.lock.Unlock()
|
||||
}
|
||||
|
||||
func (m *MysqlPool) GetMysqlDB(AppCnf *Type.App, ServerId int) *Db {
|
||||
|
||||
@ -28,9 +28,6 @@ func LoginResponse(c *gin.Context, AppId, AreaCode int, Version string) {
|
||||
func GetUserInfo(AppId, AreaCode int, Uid, Version string) (int, string, int) {
|
||||
lockUid(Uid)
|
||||
defer unlockUid(Uid)
|
||||
if AppId == 0 {
|
||||
return 3562, "ga-bp10efkfr8mgzei6d9obf.aliyunga0019.com", 1
|
||||
}
|
||||
Db := MPool.GetGameDB()
|
||||
defer Db.Close()
|
||||
var ServerId int
|
||||
@ -41,15 +38,14 @@ func GetUserInfo(AppId, AreaCode int, Uid, Version string) (int, string, int) {
|
||||
if len(ServerList) == 0 || Uid == "" || Version == "" {
|
||||
return 0, "", 0
|
||||
}
|
||||
// TODO
|
||||
if AppId == 5 {
|
||||
return 3601, "192.168.6.195", 1
|
||||
}
|
||||
|
||||
appConf, _ := GetAppConfig(AppId)
|
||||
PlayerDb := MPool.GetMysqlDB(appConf, 1)
|
||||
defer PlayerDb.Close()
|
||||
var node int
|
||||
err := PlayerDb.QueryRow("SELECT node FROM t_player_baseinfo WHERE user_name = ?", Uid).Scan(&node)
|
||||
if err != nil {
|
||||
fmt.Printf("GetUserInfo query node error: %v\n", err)
|
||||
}
|
||||
if node > 0 {
|
||||
for _, server := range ServerList {
|
||||
if server.ServerId == node && server.Status == 1 {
|
||||
@ -66,7 +62,7 @@ func GetUserInfo(AppId, AreaCode int, Uid, Version string) (int, string, int) {
|
||||
if server.Status != 1 {
|
||||
continue
|
||||
}
|
||||
if server.Version == Version || Version != "" {
|
||||
if Version != "" && server.Version == Version {
|
||||
new_server_list = append(new_server_list, server)
|
||||
}
|
||||
}
|
||||
@ -108,7 +104,7 @@ func GetUserInfo(AppId, AreaCode int, Uid, Version string) (int, string, int) {
|
||||
}
|
||||
}
|
||||
|
||||
if ServerId == 0 && Version == "" {
|
||||
if ServerId == 0 {
|
||||
ServerId = ServerList[0].ServerId
|
||||
Host = ServerList[0].Host
|
||||
Port = ServerList[0].Port
|
||||
|
||||
@ -74,6 +74,7 @@ func remain(Day int, LogDb *Db, AppConfig *Type.App) {
|
||||
Recharge := Recharge(now, LogDb) // 计算充值
|
||||
|
||||
Db := MPool.GetTopicDB(AppConfig.Topic)
|
||||
defer Db.Close()
|
||||
if Db == nil {
|
||||
log.Printf("failed to get mysql database")
|
||||
return
|
||||
|
||||
@ -442,6 +442,7 @@ func AddAdminLog(c *gin.Context, action string, params interface{}) {
|
||||
admin := c.GetString("admin")
|
||||
ip := c.ClientIP()
|
||||
db := MPool.GetGameDB()
|
||||
defer db.Close()
|
||||
_, err := db.Exec("INSERT INTO admin_log (admin, action, params, ip, createTime) VALUES (?, ?, ?, ?, ?)",
|
||||
admin, action, ToJson(params), ip, Now())
|
||||
if err != nil {
|
||||
|
||||
@ -18,12 +18,12 @@ func GetWebsocket(AppId, ServerId int) (*websocket.Conn, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ServerConfig, _ := GetServerConfig(AppId, ServerId)
|
||||
origin := "http://localhost/"
|
||||
if AppId == 0 {
|
||||
Server.Host = "google.bywaystudios.com"
|
||||
}
|
||||
url := fmt.Sprintf("ws://%s:%d/", Server.Host, App.WsPort+ServerId)
|
||||
url := fmt.Sprintf("ws://%s:%d/", ServerConfig.Host, ServerConfig.WsPort)
|
||||
|
||||
config, err := websocket.NewConfig(url, origin)
|
||||
if err != nil {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user