You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

360 lines
9.5 KiB
Go

// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package dao
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"joybuywork/internal/repository/model"
)
func newGameAction(db *gorm.DB, opts ...gen.DOOption) gameAction {
_gameAction := gameAction{}
_gameAction.gameActionDo.UseDB(db, opts...)
_gameAction.gameActionDo.UseModel(&model.GameAction{})
tableName := _gameAction.gameActionDo.TableName()
_gameAction.ALL = field.NewAsterisk(tableName)
_gameAction.ID = field.NewInt64(tableName, "id")
_gameAction.ProjectID = field.NewInt64(tableName, "project_id")
_gameAction.GameID = field.NewInt64(tableName, "game_id")
_gameAction.UserID = field.NewInt64(tableName, "user_id")
_gameAction.LinkID = field.NewInt64(tableName, "link_id")
_gameAction.Type = field.NewInt32(tableName, "type")
_gameAction.ActionTime = field.NewInt64(tableName, "action_time")
_gameAction.Dimension = field.NewString(tableName, "dimension")
_gameAction.fillFieldMap()
return _gameAction
}
type gameAction struct {
gameActionDo gameActionDo
ALL field.Asterisk
ID field.Int64
ProjectID field.Int64 // 项目id
GameID field.Int64 // 游戏id
UserID field.Int64 // 用户id
LinkID field.Int64 // 链接id
Type field.Int32 // 用户行为类型
ActionTime field.Int64 // 用户行为时间
Dimension field.String // 维度数据
fieldMap map[string]field.Expr
}
func (g gameAction) Table(newTableName string) *gameAction {
g.gameActionDo.UseTable(newTableName)
return g.updateTableName(newTableName)
}
func (g gameAction) As(alias string) *gameAction {
g.gameActionDo.DO = *(g.gameActionDo.As(alias).(*gen.DO))
return g.updateTableName(alias)
}
func (g *gameAction) updateTableName(table string) *gameAction {
g.ALL = field.NewAsterisk(table)
g.ID = field.NewInt64(table, "id")
g.ProjectID = field.NewInt64(table, "project_id")
g.GameID = field.NewInt64(table, "game_id")
g.UserID = field.NewInt64(table, "user_id")
g.LinkID = field.NewInt64(table, "link_id")
g.Type = field.NewInt32(table, "type")
g.ActionTime = field.NewInt64(table, "action_time")
g.Dimension = field.NewString(table, "dimension")
g.fillFieldMap()
return g
}
func (g *gameAction) WithContext(ctx context.Context) *gameActionDo {
return g.gameActionDo.WithContext(ctx)
}
func (g gameAction) TableName() string { return g.gameActionDo.TableName() }
func (g gameAction) Alias() string { return g.gameActionDo.Alias() }
func (g *gameAction) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := g.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (g *gameAction) fillFieldMap() {
g.fieldMap = make(map[string]field.Expr, 8)
g.fieldMap["id"] = g.ID
g.fieldMap["project_id"] = g.ProjectID
g.fieldMap["game_id"] = g.GameID
g.fieldMap["user_id"] = g.UserID
g.fieldMap["link_id"] = g.LinkID
g.fieldMap["type"] = g.Type
g.fieldMap["action_time"] = g.ActionTime
g.fieldMap["dimension"] = g.Dimension
}
func (g gameAction) clone(db *gorm.DB) gameAction {
g.gameActionDo.ReplaceConnPool(db.Statement.ConnPool)
return g
}
func (g gameAction) replaceDB(db *gorm.DB) gameAction {
g.gameActionDo.ReplaceDB(db)
return g
}
type gameActionDo struct{ gen.DO }
func (g gameActionDo) Debug() *gameActionDo {
return g.withDO(g.DO.Debug())
}
func (g gameActionDo) WithContext(ctx context.Context) *gameActionDo {
return g.withDO(g.DO.WithContext(ctx))
}
func (g gameActionDo) ReadDB() *gameActionDo {
return g.Clauses(dbresolver.Read)
}
func (g gameActionDo) WriteDB() *gameActionDo {
return g.Clauses(dbresolver.Write)
}
func (g gameActionDo) Session(config *gorm.Session) *gameActionDo {
return g.withDO(g.DO.Session(config))
}
func (g gameActionDo) Clauses(conds ...clause.Expression) *gameActionDo {
return g.withDO(g.DO.Clauses(conds...))
}
func (g gameActionDo) Returning(value interface{}, columns ...string) *gameActionDo {
return g.withDO(g.DO.Returning(value, columns...))
}
func (g gameActionDo) Not(conds ...gen.Condition) *gameActionDo {
return g.withDO(g.DO.Not(conds...))
}
func (g gameActionDo) Or(conds ...gen.Condition) *gameActionDo {
return g.withDO(g.DO.Or(conds...))
}
func (g gameActionDo) Select(conds ...field.Expr) *gameActionDo {
return g.withDO(g.DO.Select(conds...))
}
func (g gameActionDo) Where(conds ...gen.Condition) *gameActionDo {
return g.withDO(g.DO.Where(conds...))
}
func (g gameActionDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *gameActionDo {
return g.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
}
func (g gameActionDo) Order(conds ...field.Expr) *gameActionDo {
return g.withDO(g.DO.Order(conds...))
}
func (g gameActionDo) Distinct(cols ...field.Expr) *gameActionDo {
return g.withDO(g.DO.Distinct(cols...))
}
func (g gameActionDo) Omit(cols ...field.Expr) *gameActionDo {
return g.withDO(g.DO.Omit(cols...))
}
func (g gameActionDo) Join(table schema.Tabler, on ...field.Expr) *gameActionDo {
return g.withDO(g.DO.Join(table, on...))
}
func (g gameActionDo) LeftJoin(table schema.Tabler, on ...field.Expr) *gameActionDo {
return g.withDO(g.DO.LeftJoin(table, on...))
}
func (g gameActionDo) RightJoin(table schema.Tabler, on ...field.Expr) *gameActionDo {
return g.withDO(g.DO.RightJoin(table, on...))
}
func (g gameActionDo) Group(cols ...field.Expr) *gameActionDo {
return g.withDO(g.DO.Group(cols...))
}
func (g gameActionDo) Having(conds ...gen.Condition) *gameActionDo {
return g.withDO(g.DO.Having(conds...))
}
func (g gameActionDo) Limit(limit int) *gameActionDo {
return g.withDO(g.DO.Limit(limit))
}
func (g gameActionDo) Offset(offset int) *gameActionDo {
return g.withDO(g.DO.Offset(offset))
}
func (g gameActionDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *gameActionDo {
return g.withDO(g.DO.Scopes(funcs...))
}
func (g gameActionDo) Unscoped() *gameActionDo {
return g.withDO(g.DO.Unscoped())
}
func (g gameActionDo) Create(values ...*model.GameAction) error {
if len(values) == 0 {
return nil
}
return g.DO.Create(values)
}
func (g gameActionDo) CreateInBatches(values []*model.GameAction, batchSize int) error {
return g.DO.CreateInBatches(values, batchSize)
}
// Save : !!! underlying implementation is different with GORM
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
func (g gameActionDo) Save(values ...*model.GameAction) error {
if len(values) == 0 {
return nil
}
return g.DO.Save(values)
}
func (g gameActionDo) First() (*model.GameAction, error) {
if result, err := g.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.GameAction), nil
}
}
func (g gameActionDo) Take() (*model.GameAction, error) {
if result, err := g.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.GameAction), nil
}
}
func (g gameActionDo) Last() (*model.GameAction, error) {
if result, err := g.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.GameAction), nil
}
}
func (g gameActionDo) Find() ([]*model.GameAction, error) {
result, err := g.DO.Find()
return result.([]*model.GameAction), err
}
func (g gameActionDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.GameAction, err error) {
buf := make([]*model.GameAction, 0, batchSize)
err = g.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
defer func() { results = append(results, buf...) }()
return fc(tx, batch)
})
return results, err
}
func (g gameActionDo) FindInBatches(result *[]*model.GameAction, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return g.DO.FindInBatches(result, batchSize, fc)
}
func (g gameActionDo) Attrs(attrs ...field.AssignExpr) *gameActionDo {
return g.withDO(g.DO.Attrs(attrs...))
}
func (g gameActionDo) Assign(attrs ...field.AssignExpr) *gameActionDo {
return g.withDO(g.DO.Assign(attrs...))
}
func (g gameActionDo) Joins(fields ...field.RelationField) *gameActionDo {
for _, _f := range fields {
g = *g.withDO(g.DO.Joins(_f))
}
return &g
}
func (g gameActionDo) Preload(fields ...field.RelationField) *gameActionDo {
for _, _f := range fields {
g = *g.withDO(g.DO.Preload(_f))
}
return &g
}
func (g gameActionDo) FirstOrInit() (*model.GameAction, error) {
if result, err := g.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.GameAction), nil
}
}
func (g gameActionDo) FirstOrCreate() (*model.GameAction, error) {
if result, err := g.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.GameAction), nil
}
}
func (g gameActionDo) FindByPage(offset int, limit int) (result []*model.GameAction, count int64, err error) {
result, err = g.Offset(offset).Limit(limit).Find()
if err != nil {
return
}
if size := len(result); 0 < limit && 0 < size && size < limit {
count = int64(size + offset)
return
}
count, err = g.Offset(-1).Limit(-1).Count()
return
}
func (g gameActionDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = g.Count()
if err != nil {
return
}
err = g.Offset(offset).Limit(limit).Scan(result)
return
}
func (g gameActionDo) Scan(result interface{}) (err error) {
return g.DO.Scan(result)
}
func (g gameActionDo) Delete(models ...*model.GameAction) (result gen.ResultInfo, err error) {
return g.DO.Delete(models)
}
func (g *gameActionDo) withDO(do gen.Dao) *gameActionDo {
g.DO = *do.(*gen.DO)
return g
}