|
|
// 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 newGameLink(db *gorm.DB, opts ...gen.DOOption) gameLink {
|
|
|
_gameLink := gameLink{}
|
|
|
|
|
|
_gameLink.gameLinkDo.UseDB(db, opts...)
|
|
|
_gameLink.gameLinkDo.UseModel(&model.GameLink{})
|
|
|
|
|
|
tableName := _gameLink.gameLinkDo.TableName()
|
|
|
_gameLink.ALL = field.NewAsterisk(tableName)
|
|
|
_gameLink.ID = field.NewInt64(tableName, "id")
|
|
|
_gameLink.HashID = field.NewString(tableName, "hash_id")
|
|
|
_gameLink.CreatedAt = field.NewInt64(tableName, "created_at")
|
|
|
_gameLink.UpdatedAt = field.NewInt64(tableName, "updated_at")
|
|
|
_gameLink.IsDel = field.NewInt8(tableName, "is_del")
|
|
|
_gameLink.ProjectID = field.NewInt64(tableName, "project_id")
|
|
|
_gameLink.GameID = field.NewInt64(tableName, "game_id")
|
|
|
_gameLink.Title = field.NewString(tableName, "title")
|
|
|
_gameLink.IsDefault = field.NewInt8(tableName, "is_default")
|
|
|
|
|
|
_gameLink.fillFieldMap()
|
|
|
|
|
|
return _gameLink
|
|
|
}
|
|
|
|
|
|
type gameLink struct {
|
|
|
gameLinkDo gameLinkDo
|
|
|
|
|
|
ALL field.Asterisk
|
|
|
ID field.Int64
|
|
|
HashID field.String
|
|
|
CreatedAt field.Int64
|
|
|
UpdatedAt field.Int64
|
|
|
IsDel field.Int8
|
|
|
ProjectID field.Int64 // 项目id
|
|
|
GameID field.Int64 // 游戏id
|
|
|
Title field.String // 标题
|
|
|
IsDefault field.Int8 // 是否默认(0-否,1-是)
|
|
|
|
|
|
fieldMap map[string]field.Expr
|
|
|
}
|
|
|
|
|
|
func (g gameLink) Table(newTableName string) *gameLink {
|
|
|
g.gameLinkDo.UseTable(newTableName)
|
|
|
return g.updateTableName(newTableName)
|
|
|
}
|
|
|
|
|
|
func (g gameLink) As(alias string) *gameLink {
|
|
|
g.gameLinkDo.DO = *(g.gameLinkDo.As(alias).(*gen.DO))
|
|
|
return g.updateTableName(alias)
|
|
|
}
|
|
|
|
|
|
func (g *gameLink) updateTableName(table string) *gameLink {
|
|
|
g.ALL = field.NewAsterisk(table)
|
|
|
g.ID = field.NewInt64(table, "id")
|
|
|
g.HashID = field.NewString(table, "hash_id")
|
|
|
g.CreatedAt = field.NewInt64(table, "created_at")
|
|
|
g.UpdatedAt = field.NewInt64(table, "updated_at")
|
|
|
g.IsDel = field.NewInt8(table, "is_del")
|
|
|
g.ProjectID = field.NewInt64(table, "project_id")
|
|
|
g.GameID = field.NewInt64(table, "game_id")
|
|
|
g.Title = field.NewString(table, "title")
|
|
|
g.IsDefault = field.NewInt8(table, "is_default")
|
|
|
|
|
|
g.fillFieldMap()
|
|
|
|
|
|
return g
|
|
|
}
|
|
|
|
|
|
func (g *gameLink) WithContext(ctx context.Context) *gameLinkDo { return g.gameLinkDo.WithContext(ctx) }
|
|
|
|
|
|
func (g gameLink) TableName() string { return g.gameLinkDo.TableName() }
|
|
|
|
|
|
func (g gameLink) Alias() string { return g.gameLinkDo.Alias() }
|
|
|
|
|
|
func (g *gameLink) 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 *gameLink) fillFieldMap() {
|
|
|
g.fieldMap = make(map[string]field.Expr, 9)
|
|
|
g.fieldMap["id"] = g.ID
|
|
|
g.fieldMap["hash_id"] = g.HashID
|
|
|
g.fieldMap["created_at"] = g.CreatedAt
|
|
|
g.fieldMap["updated_at"] = g.UpdatedAt
|
|
|
g.fieldMap["is_del"] = g.IsDel
|
|
|
g.fieldMap["project_id"] = g.ProjectID
|
|
|
g.fieldMap["game_id"] = g.GameID
|
|
|
g.fieldMap["title"] = g.Title
|
|
|
g.fieldMap["is_default"] = g.IsDefault
|
|
|
}
|
|
|
|
|
|
func (g gameLink) clone(db *gorm.DB) gameLink {
|
|
|
g.gameLinkDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
|
return g
|
|
|
}
|
|
|
|
|
|
func (g gameLink) replaceDB(db *gorm.DB) gameLink {
|
|
|
g.gameLinkDo.ReplaceDB(db)
|
|
|
return g
|
|
|
}
|
|
|
|
|
|
type gameLinkDo struct{ gen.DO }
|
|
|
|
|
|
func (g gameLinkDo) Debug() *gameLinkDo {
|
|
|
return g.withDO(g.DO.Debug())
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) WithContext(ctx context.Context) *gameLinkDo {
|
|
|
return g.withDO(g.DO.WithContext(ctx))
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) ReadDB() *gameLinkDo {
|
|
|
return g.Clauses(dbresolver.Read)
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) WriteDB() *gameLinkDo {
|
|
|
return g.Clauses(dbresolver.Write)
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Session(config *gorm.Session) *gameLinkDo {
|
|
|
return g.withDO(g.DO.Session(config))
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Clauses(conds ...clause.Expression) *gameLinkDo {
|
|
|
return g.withDO(g.DO.Clauses(conds...))
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Returning(value interface{}, columns ...string) *gameLinkDo {
|
|
|
return g.withDO(g.DO.Returning(value, columns...))
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Not(conds ...gen.Condition) *gameLinkDo {
|
|
|
return g.withDO(g.DO.Not(conds...))
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Or(conds ...gen.Condition) *gameLinkDo {
|
|
|
return g.withDO(g.DO.Or(conds...))
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Select(conds ...field.Expr) *gameLinkDo {
|
|
|
return g.withDO(g.DO.Select(conds...))
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Where(conds ...gen.Condition) *gameLinkDo {
|
|
|
return g.withDO(g.DO.Where(conds...))
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *gameLinkDo {
|
|
|
return g.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Order(conds ...field.Expr) *gameLinkDo {
|
|
|
return g.withDO(g.DO.Order(conds...))
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Distinct(cols ...field.Expr) *gameLinkDo {
|
|
|
return g.withDO(g.DO.Distinct(cols...))
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Omit(cols ...field.Expr) *gameLinkDo {
|
|
|
return g.withDO(g.DO.Omit(cols...))
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Join(table schema.Tabler, on ...field.Expr) *gameLinkDo {
|
|
|
return g.withDO(g.DO.Join(table, on...))
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) LeftJoin(table schema.Tabler, on ...field.Expr) *gameLinkDo {
|
|
|
return g.withDO(g.DO.LeftJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) RightJoin(table schema.Tabler, on ...field.Expr) *gameLinkDo {
|
|
|
return g.withDO(g.DO.RightJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Group(cols ...field.Expr) *gameLinkDo {
|
|
|
return g.withDO(g.DO.Group(cols...))
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Having(conds ...gen.Condition) *gameLinkDo {
|
|
|
return g.withDO(g.DO.Having(conds...))
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Limit(limit int) *gameLinkDo {
|
|
|
return g.withDO(g.DO.Limit(limit))
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Offset(offset int) *gameLinkDo {
|
|
|
return g.withDO(g.DO.Offset(offset))
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *gameLinkDo {
|
|
|
return g.withDO(g.DO.Scopes(funcs...))
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Unscoped() *gameLinkDo {
|
|
|
return g.withDO(g.DO.Unscoped())
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Create(values ...*model.GameLink) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return g.DO.Create(values)
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) CreateInBatches(values []*model.GameLink, 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 gameLinkDo) Save(values ...*model.GameLink) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return g.DO.Save(values)
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) First() (*model.GameLink, error) {
|
|
|
if result, err := g.DO.First(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.GameLink), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Take() (*model.GameLink, error) {
|
|
|
if result, err := g.DO.Take(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.GameLink), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Last() (*model.GameLink, error) {
|
|
|
if result, err := g.DO.Last(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.GameLink), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Find() ([]*model.GameLink, error) {
|
|
|
result, err := g.DO.Find()
|
|
|
return result.([]*model.GameLink), err
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.GameLink, err error) {
|
|
|
buf := make([]*model.GameLink, 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 gameLinkDo) FindInBatches(result *[]*model.GameLink, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
|
return g.DO.FindInBatches(result, batchSize, fc)
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Attrs(attrs ...field.AssignExpr) *gameLinkDo {
|
|
|
return g.withDO(g.DO.Attrs(attrs...))
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Assign(attrs ...field.AssignExpr) *gameLinkDo {
|
|
|
return g.withDO(g.DO.Assign(attrs...))
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Joins(fields ...field.RelationField) *gameLinkDo {
|
|
|
for _, _f := range fields {
|
|
|
g = *g.withDO(g.DO.Joins(_f))
|
|
|
}
|
|
|
return &g
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Preload(fields ...field.RelationField) *gameLinkDo {
|
|
|
for _, _f := range fields {
|
|
|
g = *g.withDO(g.DO.Preload(_f))
|
|
|
}
|
|
|
return &g
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) FirstOrInit() (*model.GameLink, error) {
|
|
|
if result, err := g.DO.FirstOrInit(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.GameLink), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) FirstOrCreate() (*model.GameLink, error) {
|
|
|
if result, err := g.DO.FirstOrCreate(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.GameLink), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) FindByPage(offset int, limit int) (result []*model.GameLink, 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 gameLinkDo) 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 gameLinkDo) Scan(result interface{}) (err error) {
|
|
|
return g.DO.Scan(result)
|
|
|
}
|
|
|
|
|
|
func (g gameLinkDo) Delete(models ...*model.GameLink) (result gen.ResultInfo, err error) {
|
|
|
return g.DO.Delete(models)
|
|
|
}
|
|
|
|
|
|
func (g *gameLinkDo) withDO(do gen.Dao) *gameLinkDo {
|
|
|
g.DO = *do.(*gen.DO)
|
|
|
return g
|
|
|
}
|