Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0628882533 | ||
|
|
f68655eee6 |
@@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user