Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f68655eee6 | ||
|
|
d8491f0aba |
@@ -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,30 @@ 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)
|
||||||
|
var count int64
|
||||||
|
|
||||||
|
if len(add) > 0 {
|
||||||
dbRes, err2 := g.Model(Name).Batch(50).Data(add).Save()
|
dbRes, err2 := g.Model(Name).Batch(50).Data(add).Save()
|
||||||
add = make([]*entity.GameAct, 0)
|
add = make([]*entity.GameAct, 0)
|
||||||
if err2 != nil {
|
err = err2
|
||||||
|
if err != nil {
|
||||||
g.Log().Error(ctx, err2)
|
g.Log().Error(ctx, err2)
|
||||||
return
|
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
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user