Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b51cc5f7c | ||
|
|
167f90b250 | ||
|
|
5e885af295 | ||
|
|
b219123ded | ||
|
|
d3062a0240 | ||
|
|
f9bdc0f707 | ||
|
|
9df7bd891e | ||
|
|
6b0d2359c5 |
29
act/act.go
Normal file
29
act/act.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package act
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
type act struct {
|
||||
}
|
||||
|
||||
type Sql struct {
|
||||
UID uint64 `gorm:"primaryKey;comment:玩家编号"`
|
||||
ActID int `gorm:"primaryKey;comment:活动编号"`
|
||||
Action string `gorm:"type:text;comment:活动配置"`
|
||||
UpdatedAt *gtime.Time `gorm:"index;comment:更新时间"`
|
||||
}
|
||||
|
||||
func New() *act {
|
||||
|
||||
return &act{}
|
||||
}
|
||||
|
||||
func (s *act) CreateTable(name string) {
|
||||
|
||||
//prefix := g.DB().GetPrefix()
|
||||
//
|
||||
//g.DB()
|
||||
//g.DB().Exec(gctx.New())
|
||||
|
||||
}
|
||||
13
act/act.sql
Normal file
13
act/act.sql
Normal file
@@ -0,0 +1,13 @@
|
||||
create table shiningu_game_act
|
||||
(
|
||||
uid bigint not null comment '玩家编号',
|
||||
act_id int not null comment '活动编号',
|
||||
action text null comment '活动配置',
|
||||
updated_at datetime null comment '更新时间',
|
||||
primary key (uid, act_id)
|
||||
)
|
||||
comment '玩家活动数据' charset = utf8mb4;
|
||||
|
||||
create index shiningu_game_act_uid_index
|
||||
on shiningu_game_act (uid);
|
||||
|
||||
19
act/save.go
Normal file
19
act/save.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package act
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
)
|
||||
|
||||
// 查询表格时候存在
|
||||
func (s *act) TableExists(name string) bool {
|
||||
Prefix := g.DB().GetPrefix()
|
||||
get, err := g.DB().TableFields(gctx.New(), Prefix+name)
|
||||
if err != nil {
|
||||
g.Log().Error(gctx.New(), err)
|
||||
}
|
||||
if get != nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -11,7 +11,7 @@ var adapterRedisCache = gcache.New()
|
||||
func NewAdapterRedis() gcache.Adapter {
|
||||
|
||||
if adapterRedisClient == nil {
|
||||
adapterRedisClient = gcache.NewAdapterRedis(g.Redis("cache"))
|
||||
adapterRedisClient = gcache.NewAdapterRedis(g.Redis("default"))
|
||||
adapterRedisCache.SetAdapter(adapterRedisClient)
|
||||
}
|
||||
return adapterRedisCache
|
||||
|
||||
86
cmd/make.go
Normal file
86
cmd/make.go
Normal file
@@ -0,0 +1,86 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"embed"
|
||||
"fmt"
|
||||
"github.com/gogf/gf/v2/os/gcmd"
|
||||
"github.com/gogf/gf/v2/os/gfile"
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"io/fs"
|
||||
)
|
||||
|
||||
//go:embed make/*
|
||||
var ConfigFiles embed.FS
|
||||
|
||||
var (
|
||||
Make = gcmd.Command{
|
||||
Name: "make",
|
||||
Usage: "make",
|
||||
Brief: "创建模块文件",
|
||||
Arguments: []gcmd.Argument{
|
||||
{Name: "model", Short: "m", Brief: "模块名"},
|
||||
{Name: "id", Short: "i", Brief: "活动id"},
|
||||
{Name: "name", Short: "n", Brief: "服务文件名"},
|
||||
},
|
||||
Examples: "make -m act -i 1: 创建活动1的接口与服务文件 \n" +
|
||||
"make -m logic -n test: 创建test的服务文件",
|
||||
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
|
||||
|
||||
//g.Dump(parser.GetOptAll(), parser.GetArgAll())
|
||||
//return
|
||||
var model = parser.GetOpt("model").String()
|
||||
//var name = parser.GetOpt("n").String()
|
||||
this := cMake{}
|
||||
switch model {
|
||||
case "act":
|
||||
var id = parser.GetOpt("id").Int()
|
||||
if id == 0 {
|
||||
return
|
||||
}
|
||||
err = this.Act(id)
|
||||
case "logic":
|
||||
var name = parser.GetOpt("name").String()
|
||||
if name == "" {
|
||||
return
|
||||
}
|
||||
err = this.Logic(name)
|
||||
}
|
||||
|
||||
return
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
type cMake struct{}
|
||||
|
||||
func (c *cMake) Api() {
|
||||
|
||||
}
|
||||
|
||||
func (c *cMake) Act(id int) (err error) {
|
||||
filePath := fmt.Sprintf("api/act/v1/act%v.go", id)
|
||||
err = gfile.PutContents(filePath, "package v1\n")
|
||||
|
||||
filePath = fmt.Sprintf("internal/game/act/act%d/act%d.go", id, id)
|
||||
//fileStr := gfile.GetContents(getFilePath)
|
||||
get, err := fs.ReadFile(ConfigFiles, "make/act")
|
||||
fileStr := string(get)
|
||||
fileStr = gstr.Replace(fileStr, "{id}", gconv.String(id))
|
||||
err = gfile.PutContents(filePath, fileStr)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (c *cMake) Logic(name string) (err error) {
|
||||
var filePath = fmt.Sprintf("internal/logic/%s/%s.go", name, name)
|
||||
//fileStr := gfile.GetContents("./make/logic")
|
||||
get, err := fs.ReadFile(ConfigFiles, "make/act")
|
||||
fileStr := string(get)
|
||||
fileStr = gstr.Replace(fileStr, "{package}", name)
|
||||
fileStr = gstr.Replace(fileStr, "{name}", gstr.CaseCamel(name))
|
||||
|
||||
err = gfile.PutContents(filePath, fileStr)
|
||||
return
|
||||
}
|
||||
39
cmd/make/act
Normal file
39
cmd/make/act
Normal file
@@ -0,0 +1,39 @@
|
||||
package act{id}
|
||||
|
||||
import (
|
||||
"game_server/internal/service"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
)
|
||||
|
||||
type sAct{id} struct {
|
||||
}
|
||||
|
||||
func New() *sAct{id} {
|
||||
return &sAct{id}{}
|
||||
}
|
||||
|
||||
var (
|
||||
ActId = {id}
|
||||
ctx = gctx.New()
|
||||
)
|
||||
|
||||
type Data struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
}
|
||||
|
||||
func (s *sAct{id}) GetData(uid int64) (data *Data) {
|
||||
get, _ := service.GameAct().Info(uid, ActId)
|
||||
get.Scan(&data)
|
||||
if get.IsEmpty() || get.IsNil() || data == nil {
|
||||
data = &Data{
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sAct{id}) SetData(uid int64, data interface{}) {
|
||||
service.GameAct().Set(uid, ActId, data)
|
||||
}
|
||||
25
cmd/make/logic
Normal file
25
cmd/make/logic
Normal file
@@ -0,0 +1,25 @@
|
||||
package {package}
|
||||
|
||||
import (
|
||||
"game_server/internal/service"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
)
|
||||
|
||||
type s{name} struct {
|
||||
}
|
||||
|
||||
var (
|
||||
ctx = gctx.New()
|
||||
)
|
||||
|
||||
func New() *s{name} {
|
||||
return &s{name}{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
service.Register{name}(New())
|
||||
}
|
||||
|
||||
func (s *s{name}) Info() {
|
||||
|
||||
}
|
||||
124
cmd/update.go
Normal file
124
cmd/update.go
Normal file
@@ -0,0 +1,124 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/ayflying/utility_go/s3"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"github.com/gogf/gf/v2/os/gcfg"
|
||||
"github.com/gogf/gf/v2/os/gcmd"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
type serverCfg struct {
|
||||
Name string `json:"name" dc:"服务名"`
|
||||
Address string `json:"address" dc:"服务地址"`
|
||||
Prod bool `json:"prod" dc:"是否生产环境"`
|
||||
S3 string `json:"s3" dc:"使用哪个对象储存中转"`
|
||||
}
|
||||
|
||||
type UpdateReq struct {
|
||||
File *ghttp.UploadFile `json:"file" binding:"required" dc:"文件"`
|
||||
FileUrl string `json:"file_url" dc:"文件地址"`
|
||||
}
|
||||
|
||||
var s3Mod *s3.Mod
|
||||
|
||||
var (
|
||||
Update = gcmd.Command{
|
||||
Name: "update",
|
||||
Usage: "update",
|
||||
Brief: "更新系统",
|
||||
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
|
||||
|
||||
g.Log().Info(ctx, "准备上传更新文件")
|
||||
//加载编辑配置文件
|
||||
g.Cfg("hack").GetAdapter().(*gcfg.AdapterFile).SetFileName("hack/config.yaml")
|
||||
getFileName, err := g.Cfg("hack").Get(ctx, "gfcli.build.name")
|
||||
Filename := getFileName.String()
|
||||
|
||||
var list []*serverCfg
|
||||
serverList := g.Cfg().MustGet(ctx, "server_list")
|
||||
serverList.Scan(&list)
|
||||
|
||||
//如果有p或者prod参数,则删除prod字段为true的服务
|
||||
if parser.GetOpt("a").IsNil() {
|
||||
var temp []*serverCfg
|
||||
for _, v := range list {
|
||||
if v.Prod == false {
|
||||
temp = append(temp, v)
|
||||
}
|
||||
}
|
||||
list = temp
|
||||
} else {
|
||||
g.Dump("升级", parser.GetOpt("a"))
|
||||
}
|
||||
|
||||
g.Dump("需要更新的服务器", list)
|
||||
//获取上传链接
|
||||
var url = make(map[string]string)
|
||||
filename := "linux_amd64/" + Filename
|
||||
|
||||
client := g.Client()
|
||||
client.SetTimeout(time.Minute)
|
||||
client.SetDiscovery(nil)
|
||||
|
||||
//循环服务器,推送更新
|
||||
for _, v := range list {
|
||||
address := v.Address
|
||||
if v.S3 == "" {
|
||||
v.S3 = "default"
|
||||
}
|
||||
|
||||
//查询当前上传地址是否存在
|
||||
if _, ok := url[v.S3]; !ok {
|
||||
url[v.S3], err = UploadS3(v.S3, filename)
|
||||
if err != nil {
|
||||
g.Log().Error(ctx, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
g.Log().Debugf(ctx, "准备同步服务器:%v,url=%v", v.Name, address+"/callback/update")
|
||||
get, err := client.Post(ctx, address+"/callback/update", &UpdateReq{
|
||||
FileUrl: url[v.S3],
|
||||
})
|
||||
if err != nil {
|
||||
g.Log().Debugf(ctx, "切换代理进行上传:err=%v", err)
|
||||
get, err = client.Proxy("http://192.168.50.114:10808").
|
||||
Post(ctx, address+"/callback/update", &UpdateReq{
|
||||
FileUrl: url[v.S3],
|
||||
})
|
||||
}
|
||||
if err != nil {
|
||||
g.Log().Error(ctx, err)
|
||||
}
|
||||
defer get.Close()
|
||||
g.Log().Debugf(ctx, "同步服务器:%v,完成=%v", v.Name, address)
|
||||
}
|
||||
|
||||
return
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func UploadS3(typ string, filename string) (res string, err error) {
|
||||
//updateServerS3Name, _ := g.Config().Get(ctx, "update_server_s3_name")
|
||||
|
||||
s3Mod = s3.New(typ)
|
||||
bucketName := s3Mod.GetCfg().BucketName
|
||||
obj, err := os.Open(filename)
|
||||
ff, err := obj.Stat()
|
||||
_, err = s3Mod.PutObject(obj, filename, bucketName, ff.Size())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
//上传当前文件
|
||||
get, err := s3Mod.GetFileUrl(filename, bucketName)
|
||||
g.Log().Debugf(gctx.New(), "下载地址:%s", get)
|
||||
|
||||
res = get.String()
|
||||
return
|
||||
}
|
||||
@@ -140,7 +140,7 @@ func (c *Cfg) GetApollo(name string, obj Load) (jsonObj *gjson.Json, err error)
|
||||
g.Cfg(name).SetAdapter(adapter)
|
||||
|
||||
//首次运行加入监听器
|
||||
if !gstr.InArray(ApolloListener, name) {
|
||||
if !gstr.InArray(ApolloListener, name+".json") {
|
||||
//放置监听器
|
||||
client, _ := agollo.StartWithConfig(func() (*apolloConfig.AppConfig, error) {
|
||||
return &apolloConfig.AppConfig{
|
||||
|
||||
101
elasticsearch/elasticsearch.go
Normal file
101
elasticsearch/elasticsearch.go
Normal file
@@ -0,0 +1,101 @@
|
||||
package elasticsearch
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/elastic/go-elasticsearch/v8"
|
||||
)
|
||||
|
||||
var (
|
||||
es *elasticsearch.TypedClient
|
||||
)
|
||||
|
||||
type elastic struct {
|
||||
client *elasticsearch.TypedClient
|
||||
}
|
||||
|
||||
func New(name ...string) *elastic {
|
||||
// ES 配置
|
||||
cfg := elasticsearch.Config{
|
||||
Addresses: []string{
|
||||
"http://ay.cname.com:9200",
|
||||
},
|
||||
}
|
||||
if es == nil {
|
||||
var err error
|
||||
es, err = elasticsearch.NewTypedClient(cfg)
|
||||
if err != nil {
|
||||
fmt.Printf("elasticsearch.NewTypedClient failed, err:%v\n", err)
|
||||
return &elastic{}
|
||||
}
|
||||
}
|
||||
return &elastic{
|
||||
client: es,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// createIndex 创建索引
|
||||
func (s *elastic) CreateIndex(name string) {
|
||||
resp, err := s.client.Indices.
|
||||
Create(name).
|
||||
Do(context.Background())
|
||||
if err != nil {
|
||||
fmt.Printf("create index failed, err:%v\n", err)
|
||||
return
|
||||
}
|
||||
fmt.Printf("index:%#v\n", resp.Index)
|
||||
}
|
||||
|
||||
// indexDocument 索引文档
|
||||
func (s *elastic) IndexDocument(name string, key string, data interface{}) {
|
||||
|
||||
// 添加文档
|
||||
resp, err := s.client.Index(name).
|
||||
Id(key).
|
||||
Document(data).
|
||||
Do(context.Background())
|
||||
if err != nil {
|
||||
fmt.Printf("indexing document failed, err:%v\n", err)
|
||||
return
|
||||
}
|
||||
fmt.Printf("result:%#v\n", resp.Result)
|
||||
}
|
||||
|
||||
// getDocument 获取文档
|
||||
func (s *elastic) GetDocument(name string, id string) (res json.RawMessage) {
|
||||
resp, err := s.client.Get(name, id).
|
||||
Do(context.Background())
|
||||
if err != nil {
|
||||
fmt.Printf("get document by id failed, err:%v\n", err)
|
||||
return
|
||||
}
|
||||
fmt.Printf("fileds:%s\n", resp.Source_)
|
||||
res = resp.Source_
|
||||
return
|
||||
}
|
||||
|
||||
// updateDocument 更新文档
|
||||
func (s *elastic) UpdateDocument(name string, key string, data interface{}) {
|
||||
|
||||
resp, err := s.client.Update(name, key).
|
||||
Doc(data). // 使用结构体变量更新
|
||||
Do(context.Background())
|
||||
if err != nil {
|
||||
fmt.Printf("update document failed, err:%v\n", err)
|
||||
return
|
||||
}
|
||||
fmt.Printf("result:%v\n", resp.Result)
|
||||
}
|
||||
|
||||
// deleteDocument 删除 document
|
||||
func (s *elastic) DeleteDocument(name string, key string) {
|
||||
resp, err := s.client.Delete(name, key).
|
||||
Do(context.Background())
|
||||
if err != nil {
|
||||
fmt.Printf("delete document failed, err:%v\n", err)
|
||||
return
|
||||
}
|
||||
fmt.Printf("result:%v\n", resp.Result)
|
||||
}
|
||||
@@ -27,20 +27,32 @@ func Excel2Slice(filePath string, _sheet ...string) [][]string {
|
||||
|
||||
// 字符串转道具类型
|
||||
func (s *Excel) Spilt2Item(str string) (result [][]int64) {
|
||||
var parts []string
|
||||
parts1 := strings.Split(str, "|") // 分割字符串
|
||||
if parts1 == nil {
|
||||
parts1 = []string{str}
|
||||
var shadiao = []string{","}
|
||||
for _, v := range shadiao {
|
||||
str = strings.ReplaceAll(str, v, "|")
|
||||
//parts = append(parts, strings.Split(str, v)...) // 分割字符串
|
||||
}
|
||||
for _, v := range parts1 {
|
||||
parts2 := strings.Split(v, ",") // 分割字符串
|
||||
if parts2 == nil {
|
||||
parts = append(parts, v)
|
||||
} else {
|
||||
parts = append(parts, parts2...)
|
||||
}
|
||||
|
||||
//var parts []string
|
||||
parts := strings.Split(str, "|") // 分割字符串
|
||||
if parts == nil {
|
||||
parts = []string{str}
|
||||
}
|
||||
|
||||
//var parts []string
|
||||
//for _, v := range parts1 {
|
||||
// parts = append(parts, strings.Split(v, ",")...) // 分割字符串
|
||||
//}
|
||||
|
||||
//for _, v := range parts1 {
|
||||
// parts2 := strings.Split(v, ",") // 分割字符串
|
||||
// if parts2 == nil {
|
||||
// parts = append(parts, v)
|
||||
// } else {
|
||||
// parts = append(parts, parts2...)
|
||||
// }
|
||||
//}
|
||||
|
||||
for i := 0; i < len(parts)-1; i += 2 {
|
||||
num1, _ := strconv.ParseInt(parts[i], 10, 64)
|
||||
num2, _ := strconv.ParseInt(parts[i+1], 10, 64)
|
||||
|
||||
18
go.mod
18
go.mod
@@ -5,9 +5,10 @@ go 1.23.0
|
||||
require (
|
||||
github.com/apolloconfig/agollo/v4 v4.4.0
|
||||
github.com/ayflying/excel2json v1.1.2
|
||||
github.com/elastic/go-elasticsearch/v8 v8.17.0
|
||||
github.com/gogf/gf/contrib/config/apollo/v2 v2.8.3
|
||||
github.com/gogf/gf/v2 v2.8.3
|
||||
github.com/minio/minio-go/v7 v7.0.82
|
||||
github.com/minio/minio-go/v7 v7.0.84
|
||||
github.com/xuri/excelize/v2 v2.9.0
|
||||
)
|
||||
|
||||
@@ -16,19 +17,20 @@ require (
|
||||
github.com/BurntSushi/toml v1.4.0 // indirect
|
||||
github.com/clbanning/mxj/v2 v2.7.0 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/elastic/elastic-transport-go/v8 v8.6.0 // indirect
|
||||
github.com/emirpasic/gods v1.18.1 // indirect
|
||||
github.com/fatih/color v1.18.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/go-ini/ini v1.67.0 // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/goccy/go-json v0.10.3 // indirect
|
||||
github.com/goccy/go-json v0.10.4 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/gorilla/websocket v1.5.3 // indirect
|
||||
github.com/grokify/html-strip-tags-go v0.1.0 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/klauspost/compress v1.17.11 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
|
||||
github.com/magiconair/properties v1.8.9 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
@@ -50,12 +52,12 @@ require (
|
||||
github.com/subosito/gotenv v1.2.0 // indirect
|
||||
github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d // indirect
|
||||
github.com/xuri/nfp v0.0.0-20240318013403-ab9948c2c4a7 // indirect
|
||||
go.opentelemetry.io/otel v1.24.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.24.0 // indirect
|
||||
go.opentelemetry.io/otel v1.28.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.28.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.24.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.24.0 // indirect
|
||||
golang.org/x/crypto v0.30.0 // indirect
|
||||
golang.org/x/net v0.32.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.28.0 // indirect
|
||||
golang.org/x/crypto v0.31.0 // indirect
|
||||
golang.org/x/net v0.33.0 // indirect
|
||||
golang.org/x/sys v0.28.0 // indirect
|
||||
golang.org/x/text v0.21.0 // indirect
|
||||
gopkg.in/ini.v1 v1.62.0 // indirect
|
||||
|
||||
27
go.sum
27
go.sum
@@ -72,6 +72,10 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||
github.com/elastic/elastic-transport-go/v8 v8.6.0 h1:Y2S/FBjx1LlCv5m6pWAF2kDJAHoSjSRSJCApolgfthA=
|
||||
github.com/elastic/elastic-transport-go/v8 v8.6.0/go.mod h1:YLHer5cj0csTzNFXoNQ8qhtGY1GTvSqPnKWKaqQE3Hk=
|
||||
github.com/elastic/go-elasticsearch/v8 v8.17.0 h1:e9cWksE/Fr7urDRmGPGp47Nsp4/mvNOrU8As1l2HQQ0=
|
||||
github.com/elastic/go-elasticsearch/v8 v8.17.0/go.mod h1:lGMlgKIbYoRvay3xWBeKahAiJOgmFDsjZC39nmO3H64=
|
||||
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
|
||||
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
@@ -100,7 +104,10 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
|
||||
github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/goccy/go-json v0.10.4 h1:JSwxQzIqKfmFX1swYPpUThQZp/Ka4wzJdK0LWVytLPM=
|
||||
github.com/goccy/go-json v0.10.4/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/gogf/gf/contrib/config/apollo/v2 v2.8.3 h1:KU51l3uaU7Mxq+FSoLjROyDERUGKCMo4qExxPEgA7KQ=
|
||||
github.com/gogf/gf/contrib/config/apollo/v2 v2.8.3/go.mod h1:Uo6f/Pr6zVHSbdP2Lj9iToEMuh/TzU/bE2E5SJlquEk=
|
||||
github.com/gogf/gf/v2 v2.8.3 h1:h9Px3lqJnnH6It0AqHRz4/1hx0JmvaSf1IvUir5x1rA=
|
||||
github.com/gogf/gf/v2 v2.8.3/go.mod h1:n++xPYGUUMadw6IygLEgGZqc6y6DRLrJKg5kqCrPLWY=
|
||||
@@ -212,6 +219,8 @@ github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90
|
||||
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM=
|
||||
github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||
github.com/klauspost/cpuid/v2 v2.2.9 h1:66ze0taIn2H33fBvCkXuv9BmCwDfafmiIVpKV9kKGuY=
|
||||
github.com/klauspost/cpuid/v2 v2.2.9/go.mod h1:rqkxqrZ1EhYM9G+hXH7YdowN5R5RGN6NK4QwQ3WMXF8=
|
||||
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
@@ -236,6 +245,8 @@ github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
||||
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
|
||||
github.com/minio/minio-go/v7 v7.0.82 h1:tWfICLhmp2aFPXL8Tli0XDTHj2VB/fNf0PC1f/i1gRo=
|
||||
github.com/minio/minio-go/v7 v7.0.82/go.mod h1:84gmIilaX4zcvAWWzJ5Z1WI5axN+hAbM5w25xf8xvC0=
|
||||
github.com/minio/minio-go/v7 v7.0.84 h1:D1HVmAF8JF8Bpi6IU4V9vIEj+8pc+xU88EWMs2yed0E=
|
||||
github.com/minio/minio-go/v7 v7.0.84/go.mod h1:57YXpvc5l3rjPdhqNrDsvVlY0qPI6UTk1bflAe+9doY=
|
||||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
|
||||
@@ -324,14 +335,14 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
|
||||
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
|
||||
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
|
||||
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
|
||||
go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI=
|
||||
go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco=
|
||||
go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo=
|
||||
go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4=
|
||||
go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q=
|
||||
go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s=
|
||||
go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw=
|
||||
go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg=
|
||||
go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=
|
||||
go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=
|
||||
go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g=
|
||||
go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
||||
go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
|
||||
@@ -344,6 +355,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY=
|
||||
golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
||||
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
|
||||
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
@@ -419,6 +432,8 @@ golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLd
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI=
|
||||
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=
|
||||
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
|
||||
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
|
||||
@@ -86,6 +86,15 @@ func (r *F64CountRank) IncrScore(id int64, score int64) (curScore float64, err e
|
||||
return
|
||||
}
|
||||
|
||||
// todo暂时未使用
|
||||
func (r *F64CountRank) GetCount() {
|
||||
count, _ := g.Redis().ZCard(ctx, r.name)
|
||||
if count > 9999 {
|
||||
//删除超过9999的数据
|
||||
g.Redis().ZRemRangeByRank(ctx, r.name, 0, -9999)
|
||||
}
|
||||
}
|
||||
|
||||
// 删除当前排行榜
|
||||
func (r *F64CountRank) Delete() {
|
||||
_, err := g.Redis().Del(ctx, r.name)
|
||||
|
||||
10
s3/s3.go
10
s3/s3.go
@@ -45,8 +45,6 @@ func New(_name ...string) *Mod {
|
||||
name = getName.String()
|
||||
}
|
||||
|
||||
get2, err := g.Cfg().Get(ctx, "s3")
|
||||
g.Dump(get2)
|
||||
get, err := g.Cfg().Get(ctx, "s3."+name)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
@@ -276,14 +274,14 @@ func (s *Mod) CopyObject(bucketName string, dstStr string, srcStr string) (err e
|
||||
|
||||
// 原始文件
|
||||
var dst = minio.CopyDestOptions{
|
||||
Bucket: dstStr,
|
||||
Object: bucketName,
|
||||
Bucket: bucketName,
|
||||
Object: dstStr,
|
||||
}
|
||||
|
||||
// 新文件
|
||||
var src = minio.CopySrcOptions{
|
||||
Bucket: srcStr,
|
||||
Object: bucketName,
|
||||
Bucket: bucketName,
|
||||
Object: srcStr,
|
||||
}
|
||||
|
||||
_, err = s.client.CopyObject(ctx, dst, src)
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
bagV1 "game_server/api/bag/v1"
|
||||
v1 "game_server/api/bag/v1"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"math"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -91,53 +88,6 @@ func (m *tools) Items2Map(items [][]int64) (list map[int64]int64) {
|
||||
return
|
||||
}
|
||||
|
||||
// 道具转Pb
|
||||
func (m *tools) Items2Pb(items [][]int64) (list map[int64]*v1.Item) {
|
||||
list = make(map[int64]*v1.Item)
|
||||
for _, v := range items {
|
||||
list[v[0]] = &v1.Item{
|
||||
Count: v[1],
|
||||
}
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
// UpdateItems 格式化到items输出
|
||||
func (m *tools) UpdateItems(items [][]int64, updateItems [][]int64, IsDeduct ...bool) (data *bagV1.ItemUpdate) {
|
||||
data = &bagV1.ItemUpdate{
|
||||
Items: make(map[int64]*bagV1.Item),
|
||||
UpdateItems: make(map[int64]*bagV1.Item),
|
||||
}
|
||||
|
||||
for _, v := range items {
|
||||
if _, ok := data.Items[v[0]]; ok {
|
||||
//如果存在,追加数据
|
||||
data.Items[v[0]].Count += v[1]
|
||||
} else {
|
||||
//如果不存在,创建数据
|
||||
data.Items[v[0]] = &bagV1.Item{
|
||||
Count: v[1],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, v := range updateItems {
|
||||
//UpdateItems 只保存最新的值
|
||||
data.UpdateItems[v[0]] = &bagV1.Item{
|
||||
Count: v[1],
|
||||
}
|
||||
}
|
||||
|
||||
//如果是强制转为负数
|
||||
if len(IsDeduct) > 0 && IsDeduct[0] {
|
||||
for k, v := range data.Items {
|
||||
data.Items[k].Count = -int64(math.Abs(float64(v.Count)))
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// RemoveSlice 从切片中移除指定的值。
|
||||
// 参数:
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user