Compare commits
No commits in common. "cd0a7f84dafe2bcb25600b4333d752d1c4b65365" and "13a857cd391d35246ba0ac81533bcba295b82f15" have entirely different histories.
cd0a7f84da
...
13a857cd39
|
|
@ -109,4 +109,4 @@ build-job:
|
||||||
|
|
||||||
# 触发部署
|
# 触发部署
|
||||||
- echo "触发部署"
|
- echo "触发部署"
|
||||||
- "curl -X POST --fail -F token=$SERVER_CI_TOKEN -F ref=release -F variables[ServerName]=$ServerName https://git.mango-gm.com//api/v4/projects/31/trigger/pipeline"
|
- "curl -X POST --fail -F token=$SERVER_CI_TOKEN -F ref=release -F variables[ServerName]=$ServerName https://git.pogorockgames.com/api/v4/projects/31/trigger/pipeline"
|
||||||
|
|
@ -1,279 +0,0 @@
|
||||||
// --------------------------------------------------------------------------------------------
|
|
||||||
// The following code is automatically generated by the mongo-dao-generator tool.
|
|
||||||
// Please do not modify this code manually to avoid being overwritten in the next generation.
|
|
||||||
// For more tool details, please click the link to view https://github.com/dobyte/mongo-dao-generator
|
|
||||||
// --------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
package internal
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"errors"
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
|
||||||
modelpkg "mongo.games.com/game/model"
|
|
||||||
)
|
|
||||||
|
|
||||||
type JybCodeLogFilterFunc func(cols *JybCodeLogColumns) interface{}
|
|
||||||
type JybCodeLogUpdateFunc func(cols *JybCodeLogColumns) interface{}
|
|
||||||
type JybCodeLogPipelineFunc func(cols *JybCodeLogColumns) interface{}
|
|
||||||
type JybCodeLogCountOptionsFunc func(cols *JybCodeLogColumns) *options.CountOptions
|
|
||||||
type JybCodeLogAggregateOptionsFunc func(cols *JybCodeLogColumns) *options.AggregateOptions
|
|
||||||
type JybCodeLogFindOneOptionsFunc func(cols *JybCodeLogColumns) *options.FindOneOptions
|
|
||||||
type JybCodeLogFindManyOptionsFunc func(cols *JybCodeLogColumns) *options.FindOptions
|
|
||||||
type JybCodeLogUpdateOptionsFunc func(cols *JybCodeLogColumns) *options.UpdateOptions
|
|
||||||
type JybCodeLogDeleteOptionsFunc func(cols *JybCodeLogColumns) *options.DeleteOptions
|
|
||||||
type JybCodeLogInsertOneOptionsFunc func(cols *JybCodeLogColumns) *options.InsertOneOptions
|
|
||||||
type JybCodeLogInsertManyOptionsFunc func(cols *JybCodeLogColumns) *options.InsertManyOptions
|
|
||||||
|
|
||||||
type JybCodeLog struct {
|
|
||||||
Columns *JybCodeLogColumns
|
|
||||||
Database *mongo.Database
|
|
||||||
Collection *mongo.Collection
|
|
||||||
}
|
|
||||||
|
|
||||||
type JybCodeLogColumns struct {
|
|
||||||
Id string
|
|
||||||
JybId string // 礼包id
|
|
||||||
Ts string // 兑换时间
|
|
||||||
SnId string // 玩家id
|
|
||||||
Code string // 兑换码
|
|
||||||
}
|
|
||||||
|
|
||||||
var jybCodeLogColumns = &JybCodeLogColumns{
|
|
||||||
Id: "_id",
|
|
||||||
JybId: "JybId", // 礼包id
|
|
||||||
Ts: "Ts", // 兑换时间
|
|
||||||
SnId: "SnId", // 玩家id
|
|
||||||
Code: "Code", // 兑换码
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewJybCodeLog() *JybCodeLog {
|
|
||||||
return &JybCodeLog{
|
|
||||||
Columns: jybCodeLogColumns,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Count returns the number of documents in the collection.
|
|
||||||
func (dao *JybCodeLog) Count(ctx context.Context, filterFunc JybCodeLogFilterFunc, optionsFunc ...JybCodeLogCountOptionsFunc) (int64, error) {
|
|
||||||
var (
|
|
||||||
opts *options.CountOptions
|
|
||||||
filter = filterFunc(dao.Columns)
|
|
||||||
)
|
|
||||||
|
|
||||||
if len(optionsFunc) > 0 {
|
|
||||||
opts = optionsFunc[0](dao.Columns)
|
|
||||||
}
|
|
||||||
|
|
||||||
return dao.Collection.CountDocuments(ctx, filter, opts)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Aggregate executes an aggregate command against the collection and returns a cursor over the resulting documents.
|
|
||||||
func (dao *JybCodeLog) Aggregate(ctx context.Context, pipelineFunc JybCodeLogPipelineFunc, optionsFunc ...JybCodeLogAggregateOptionsFunc) (*mongo.Cursor, error) {
|
|
||||||
var (
|
|
||||||
opts *options.AggregateOptions
|
|
||||||
pipeline = pipelineFunc(dao.Columns)
|
|
||||||
)
|
|
||||||
|
|
||||||
if len(optionsFunc) > 0 {
|
|
||||||
opts = optionsFunc[0](dao.Columns)
|
|
||||||
}
|
|
||||||
|
|
||||||
return dao.Collection.Aggregate(ctx, pipeline, opts)
|
|
||||||
}
|
|
||||||
|
|
||||||
// InsertOne executes an insert command to insert a single document into the collection.
|
|
||||||
func (dao *JybCodeLog) InsertOne(ctx context.Context, model *modelpkg.JybCodeLog, optionsFunc ...JybCodeLogInsertOneOptionsFunc) (*mongo.InsertOneResult, error) {
|
|
||||||
if model == nil {
|
|
||||||
return nil, errors.New("model is nil")
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := dao.autofill(ctx, model); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var opts *options.InsertOneOptions
|
|
||||||
|
|
||||||
if len(optionsFunc) > 0 {
|
|
||||||
opts = optionsFunc[0](dao.Columns)
|
|
||||||
}
|
|
||||||
|
|
||||||
return dao.Collection.InsertOne(ctx, model, opts)
|
|
||||||
}
|
|
||||||
|
|
||||||
// InsertMany executes an insert command to insert multiple documents into the collection.
|
|
||||||
func (dao *JybCodeLog) InsertMany(ctx context.Context, models []*modelpkg.JybCodeLog, optionsFunc ...JybCodeLogInsertManyOptionsFunc) (*mongo.InsertManyResult, error) {
|
|
||||||
if len(models) == 0 {
|
|
||||||
return nil, errors.New("models is empty")
|
|
||||||
}
|
|
||||||
|
|
||||||
documents := make([]interface{}, 0, len(models))
|
|
||||||
for i := range models {
|
|
||||||
model := models[i]
|
|
||||||
if err := dao.autofill(ctx, model); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
documents = append(documents, model)
|
|
||||||
}
|
|
||||||
|
|
||||||
var opts *options.InsertManyOptions
|
|
||||||
|
|
||||||
if len(optionsFunc) > 0 {
|
|
||||||
opts = optionsFunc[0](dao.Columns)
|
|
||||||
}
|
|
||||||
|
|
||||||
return dao.Collection.InsertMany(ctx, documents, opts)
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateOne executes an update command to update at most one document in the collection.
|
|
||||||
func (dao *JybCodeLog) UpdateOne(ctx context.Context, filterFunc JybCodeLogFilterFunc, updateFunc JybCodeLogUpdateFunc, optionsFunc ...JybCodeLogUpdateOptionsFunc) (*mongo.UpdateResult, error) {
|
|
||||||
var (
|
|
||||||
opts *options.UpdateOptions
|
|
||||||
filter = filterFunc(dao.Columns)
|
|
||||||
update = updateFunc(dao.Columns)
|
|
||||||
)
|
|
||||||
|
|
||||||
if len(optionsFunc) > 0 {
|
|
||||||
opts = optionsFunc[0](dao.Columns)
|
|
||||||
}
|
|
||||||
|
|
||||||
return dao.Collection.UpdateOne(ctx, filter, update, opts)
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateOneByID executes an update command to update at most one document in the collection.
|
|
||||||
func (dao *JybCodeLog) UpdateOneByID(ctx context.Context, id string, updateFunc JybCodeLogUpdateFunc, optionsFunc ...JybCodeLogUpdateOptionsFunc) (*mongo.UpdateResult, error) {
|
|
||||||
objectID, err := primitive.ObjectIDFromHex(id)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return dao.UpdateOne(ctx, func(cols *JybCodeLogColumns) interface{} {
|
|
||||||
return bson.M{"_id": objectID}
|
|
||||||
}, updateFunc, optionsFunc...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateMany executes an update command to update documents in the collection.
|
|
||||||
func (dao *JybCodeLog) UpdateMany(ctx context.Context, filterFunc JybCodeLogFilterFunc, updateFunc JybCodeLogUpdateFunc, optionsFunc ...JybCodeLogUpdateOptionsFunc) (*mongo.UpdateResult, error) {
|
|
||||||
var (
|
|
||||||
opts *options.UpdateOptions
|
|
||||||
filter = filterFunc(dao.Columns)
|
|
||||||
update = updateFunc(dao.Columns)
|
|
||||||
)
|
|
||||||
|
|
||||||
if len(optionsFunc) > 0 {
|
|
||||||
opts = optionsFunc[0](dao.Columns)
|
|
||||||
}
|
|
||||||
|
|
||||||
return dao.Collection.UpdateMany(ctx, filter, update, opts)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FindOne executes a find command and returns a model for one document in the collection.
|
|
||||||
func (dao *JybCodeLog) FindOne(ctx context.Context, filterFunc JybCodeLogFilterFunc, optionsFunc ...JybCodeLogFindOneOptionsFunc) (*modelpkg.JybCodeLog, error) {
|
|
||||||
var (
|
|
||||||
opts *options.FindOneOptions
|
|
||||||
model = &modelpkg.JybCodeLog{}
|
|
||||||
filter = filterFunc(dao.Columns)
|
|
||||||
)
|
|
||||||
|
|
||||||
if len(optionsFunc) > 0 {
|
|
||||||
opts = optionsFunc[0](dao.Columns)
|
|
||||||
}
|
|
||||||
|
|
||||||
err := dao.Collection.FindOne(ctx, filter, opts).Decode(model)
|
|
||||||
if err != nil {
|
|
||||||
if err == mongo.ErrNoDocuments {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return model, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// FindOneByID executes a find command and returns a model for one document in the collection.
|
|
||||||
func (dao *JybCodeLog) FindOneByID(ctx context.Context, id string, optionsFunc ...JybCodeLogFindOneOptionsFunc) (*modelpkg.JybCodeLog, error) {
|
|
||||||
objectID, err := primitive.ObjectIDFromHex(id)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return dao.FindOne(ctx, func(cols *JybCodeLogColumns) interface{} {
|
|
||||||
return bson.M{"_id": objectID}
|
|
||||||
}, optionsFunc...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FindMany executes a find command and returns many models the matching documents in the collection.
|
|
||||||
func (dao *JybCodeLog) FindMany(ctx context.Context, filterFunc JybCodeLogFilterFunc, optionsFunc ...JybCodeLogFindManyOptionsFunc) ([]*modelpkg.JybCodeLog, error) {
|
|
||||||
var (
|
|
||||||
opts *options.FindOptions
|
|
||||||
filter = filterFunc(dao.Columns)
|
|
||||||
)
|
|
||||||
|
|
||||||
if len(optionsFunc) > 0 {
|
|
||||||
opts = optionsFunc[0](dao.Columns)
|
|
||||||
}
|
|
||||||
|
|
||||||
cur, err := dao.Collection.Find(ctx, filter, opts)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
models := make([]*modelpkg.JybCodeLog, 0)
|
|
||||||
|
|
||||||
if err = cur.All(ctx, &models); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return models, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteOne executes a delete command to delete at most one document from the collection.
|
|
||||||
func (dao *JybCodeLog) DeleteOne(ctx context.Context, filterFunc JybCodeLogFilterFunc, optionsFunc ...JybCodeLogDeleteOptionsFunc) (*mongo.DeleteResult, error) {
|
|
||||||
var (
|
|
||||||
opts *options.DeleteOptions
|
|
||||||
filter = filterFunc(dao.Columns)
|
|
||||||
)
|
|
||||||
|
|
||||||
if len(optionsFunc) > 0 {
|
|
||||||
opts = optionsFunc[0](dao.Columns)
|
|
||||||
}
|
|
||||||
|
|
||||||
return dao.Collection.DeleteOne(ctx, filter, opts)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteOneByID executes a delete command to delete at most one document from the collection.
|
|
||||||
func (dao *JybCodeLog) DeleteOneByID(ctx context.Context, id string, optionsFunc ...JybCodeLogDeleteOptionsFunc) (*mongo.DeleteResult, error) {
|
|
||||||
objectID, err := primitive.ObjectIDFromHex(id)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return dao.DeleteOne(ctx, func(cols *JybCodeLogColumns) interface{} {
|
|
||||||
return bson.M{"_id": objectID}
|
|
||||||
}, optionsFunc...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteMany executes a delete command to delete documents from the collection.
|
|
||||||
func (dao *JybCodeLog) DeleteMany(ctx context.Context, filterFunc JybCodeLogFilterFunc, optionsFunc ...JybCodeLogDeleteOptionsFunc) (*mongo.DeleteResult, error) {
|
|
||||||
var (
|
|
||||||
opts *options.DeleteOptions
|
|
||||||
filter = filterFunc(dao.Columns)
|
|
||||||
)
|
|
||||||
|
|
||||||
if len(optionsFunc) > 0 {
|
|
||||||
opts = optionsFunc[0](dao.Columns)
|
|
||||||
}
|
|
||||||
|
|
||||||
return dao.Collection.DeleteMany(ctx, filter, opts)
|
|
||||||
}
|
|
||||||
|
|
||||||
// autofill when inserting data
|
|
||||||
func (dao *JybCodeLog) autofill(ctx context.Context, model *modelpkg.JybCodeLog) error {
|
|
||||||
if model.Id.IsZero() {
|
|
||||||
model.Id = primitive.NewObjectID()
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
@ -1,69 +0,0 @@
|
||||||
package dao
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
|
||||||
"mongo.games.com/goserver/core/mongox"
|
|
||||||
|
|
||||||
"mongo.games.com/game/dao/internal"
|
|
||||||
modelpkg "mongo.games.com/game/model"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
_ = context.Background()
|
|
||||||
_ = logger.Logger
|
|
||||||
_ = bson.M{}
|
|
||||||
_ = mongo.Database{}
|
|
||||||
)
|
|
||||||
|
|
||||||
type JybCodeLogColumns = internal.JybCodeLogColumns
|
|
||||||
|
|
||||||
type JybCodeLog struct {
|
|
||||||
*internal.JybCodeLog
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetJybCodeLog(key string) (*JybCodeLog, error) {
|
|
||||||
return mongox.GetDao(key, NewJybCodeLog)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewJybCodeLog(db *mongo.Database, c *mongo.Collection) (*JybCodeLog, any) {
|
|
||||||
if db == nil || c == nil {
|
|
||||||
return &JybCodeLog{}, &modelpkg.JybCodeLog{}
|
|
||||||
}
|
|
||||||
|
|
||||||
v := internal.NewJybCodeLog()
|
|
||||||
v.Database = db
|
|
||||||
v.Collection = c
|
|
||||||
|
|
||||||
c.Indexes().CreateMany(
|
|
||||||
context.Background(),
|
|
||||||
[]mongo.IndexModel{
|
|
||||||
{
|
|
||||||
Keys: bson.D{{v.Columns.JybId, 1}}, // 1 表示升序,-1 表示降序
|
|
||||||
Options: options.Index().SetBackground(true).SetSparse(true), // 后台创建索引,稀疏索引
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Keys: bson.D{{v.Columns.Code, 1}}, // 1 表示升序,-1 表示降序
|
|
||||||
Options: options.Index().SetBackground(true).SetSparse(true), // 后台创建索引,稀疏索引
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Keys: bson.D{{v.Columns.SnId, 1}}, // 1 表示升序,-1 表示降序
|
|
||||||
Options: options.Index().SetBackground(true).SetSparse(true), // 后台创建索引,稀疏索引
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Keys: bson.D{{v.Columns.Ts, -1}}, // 1 表示升序,-1 表示降序
|
|
||||||
Options: options.Index().SetBackground(true).SetSparse(true), // 后台创建索引,稀疏索引
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
return &JybCodeLog{JybCodeLog: v}, &modelpkg.JybCodeLog{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *JybCodeLog) Save(data *modelpkg.JybCodeLog) error {
|
|
||||||
_, err := l.InsertOne(context.Background(), data)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
@ -2,7 +2,6 @@ package svc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"mongo.games.com/game/dao"
|
|
||||||
"net/rpc"
|
"net/rpc"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -175,25 +174,9 @@ func upJybUser(cjybuse, cjyb *mongo.Collection, snId, codeType int32, plt, useCo
|
||||||
ret.Receive++
|
ret.Receive++
|
||||||
err = cjyb.Update(bson.M{"_id": ret.JybId}, bson.D{{"$set", bson.D{{"code", ret.Code}, {"receive", ret.Receive}}}})
|
err = cjyb.Update(bson.M{"_id": ret.JybId}, bson.D{{"$set", bson.D{{"code", ret.Code}, {"receive", ret.Receive}}}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Logger.Errorf("UpgradeJyb error %v", err)
|
logger.Logger.Errorf("UpgradeJyb error ", err)
|
||||||
return err
|
|
||||||
}
|
|
||||||
c, err := dao.GetJybCodeLog(plt)
|
|
||||||
if err == nil {
|
|
||||||
err = c.Save(&model.JybCodeLog{
|
|
||||||
JybId: jybuseerid,
|
|
||||||
Ts: time.Now().Unix(),
|
|
||||||
SnId: snId,
|
|
||||||
Code: useCode,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
logger.Logger.Errorf("save JybCodeLog error %v", err)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
logger.Logger.Errorf("GetJybCodeLog error %v", err)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
19
model/jyb.go
19
model/jyb.go
|
|
@ -3,9 +3,7 @@ package model
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"mongo.games.com/goserver/core/mongox"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/globalsign/mgo/bson"
|
"github.com/globalsign/mgo/bson"
|
||||||
|
|
@ -296,20 +294,3 @@ type JybLog struct {
|
||||||
Name string `json:"name"` // 礼包名称
|
Name string `json:"name"` // 礼包名称
|
||||||
Award []*JybItem `json:"award"` // 礼包奖励
|
Award []*JybItem `json:"award"` // 礼包奖励
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:generate mongoctl -model-dir=. -model-names=JybCodeLog -dao-dir=../dao/
|
|
||||||
type JybCodeLog struct {
|
|
||||||
Id primitive.ObjectID `bson:"_id" gen:"autoFill"`
|
|
||||||
JybId string `bson:"jybid"` // 礼包id
|
|
||||||
Ts int64 `bson:"ts"` // 兑换时间
|
|
||||||
SnId int32 `bson:"snid"` // 玩家id
|
|
||||||
Code string `bson:"code"` // 兑换码
|
|
||||||
}
|
|
||||||
|
|
||||||
func (j *JybCodeLog) DatabaseName() string {
|
|
||||||
return string(mongox.DatabaseLog)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (j *JybCodeLog) CollectionName() string {
|
|
||||||
return "log_jybcode"
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue