Compare commits

..

3 Commits

Author SHA1 Message Date
ayflying
0628882533 缓存key删除失败不报错 2025-08-20 15:13:01 +08:00
ayflying
f68655eee6 修改持久化act的异常报错 2025-08-14 14:11:26 +08:00
ayflying
d8491f0aba 修复ip库无法显示的问题 2025-08-07 11:17:04 +08:00
3 changed files with 28 additions and 34 deletions

View File

@@ -3,6 +3,10 @@ package gameAct
import ( import (
"context" "context"
"fmt" "fmt"
"strconv"
"strings"
"time"
"github.com/ayflying/utility_go/internal/model/do" "github.com/ayflying/utility_go/internal/model/do"
"github.com/ayflying/utility_go/internal/model/entity" "github.com/ayflying/utility_go/internal/model/entity"
"github.com/ayflying/utility_go/pkg" "github.com/ayflying/utility_go/pkg"
@@ -13,9 +17,6 @@ import (
"github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/gctx"
"github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/gconv"
"strconv"
"strings"
"time"
) )
var ( var (
@@ -206,37 +207,29 @@ func (s *sGameAct) Save(ctx context.Context, actId int) (err error) {
g.Log().Error(ctx, err2) g.Log().Error(ctx, err2)
return return
} }
////获取多少个数据,删除不是当前修改的数据
//count, _ := g.Model(Name).Where(do.GameAct{
// Uid: v.Uid,
// ActId: v.ActId,
//}).Count()
//if count > 1 {
// g.Model(Name).Where(do.GameAct{
// Uid: v.Uid,
// ActId: v.ActId,
// }).WhereNot("updated_at", v.UpdatedAt).Delete()
//}
} }
//dbRes, err2 := g.Model(Name).Batch(50).Data(add).Update()
update = make([]*entity.GameAct, 0) update = make([]*entity.GameAct, 0)
dbRes, err2 := g.Model(Name).Batch(50).Data(add).Save() var count int64
add = make([]*entity.GameAct, 0)
if err2 != nil { if len(add) > 0 {
g.Log().Error(ctx, err2) dbRes, err2 := g.Model(Name).Batch(50).Data(add).Save()
return add = make([]*entity.GameAct, 0)
err = err2
if err != nil {
g.Log().Error(ctx, err2)
return
}
count, _ = dbRes.RowsAffected()
} }
for _, v := range delKey { for _, v := range delKey {
_, err2 = g.Redis().Del(ctx, v) _, err = g.Redis().Del(ctx, v)
if err2 != nil { if err != nil {
g.Log().Error(ctx, err2) g.Log().Error(ctx, err)
return
} }
} }
delKey = make([]string, 0) delKey = make([]string, 0)
count, _ := dbRes.RowsAffected()
g.Log().Debugf(ctx, "当前 %v 写入数据库: %v 条", actId, count) g.Log().Debugf(ctx, "当前 %v 写入数据库: %v 条", actId, count)
} }

View File

@@ -2,16 +2,17 @@ package gameKv
import ( import (
"fmt" "fmt"
"strconv"
"strings"
"sync"
"time"
"github.com/ayflying/utility_go/pkg" "github.com/ayflying/utility_go/pkg"
"github.com/ayflying/utility_go/service" "github.com/ayflying/utility_go/service"
"github.com/ayflying/utility_go/tools" "github.com/ayflying/utility_go/tools"
"github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/gctx"
"github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gtime"
"strconv"
"strings"
"sync"
"time"
) )
var ( var (
@@ -107,8 +108,7 @@ func (s *sGameKv) SavesV1() (err error) {
for _, v := range delKey { for _, v := range delKey {
_, err2 = g.Redis().Del(ctx, v) _, err2 = g.Redis().Del(ctx, v)
if err2 != nil { if err2 != nil {
g.Log().Errorf(ctx, "删除存档错误%v,err=%v", v, err2) g.Log().Errorf(ctx, "删除存档失败%v,err=%v", v, err2)
return
} }
} }

View File

@@ -1,13 +1,14 @@
package ip2region package ip2region
import ( import (
"net"
"strings"
"github.com/ayflying/utility_go/service" "github.com/ayflying/utility_go/service"
"github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/gctx"
"github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gfile"
"github.com/lionsoul2014/ip2region/binding/golang/xdb" "github.com/lionsoul2014/ip2region/binding/golang/xdb"
"net"
"strings"
) )
var ( var (
@@ -81,7 +82,7 @@ func (s *sIp2region) Load() {
func (s *sIp2region) GetIp(ip string) (res []string) { func (s *sIp2region) GetIp(ip string) (res []string) {
//初始化加载 //初始化加载
if s.searcher != nil { if s.searcher == nil {
s.Load() s.Load()
} }