123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408 |
- // 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 query
- import (
- "context"
- "gorm.io/gorm"
- "gorm.io/gorm/clause"
- "gorm.io/gorm/schema"
- "gorm.io/gen"
- "gorm.io/gen/field"
- "gorm.io/plugin/dbresolver"
- "pji_desktop_http/biz/model"
- )
- func newWorld(db *gorm.DB, opts ...gen.DOOption) world {
- _world := world{}
- _world.worldDo.UseDB(db, opts...)
- _world.worldDo.UseModel(&model.World{})
- tableName := _world.worldDo.TableName()
- _world.ALL = field.NewAsterisk(tableName)
- _world.ID = field.NewString(tableName, "id")
- _world.SceneID = field.NewString(tableName, "scene_id")
- _world.WorldURL = field.NewString(tableName, "world_url")
- _world.CreatedAt = field.NewTime(tableName, "created_at")
- _world.UpdatedAt = field.NewTime(tableName, "updated_at")
- _world.DeletedAt = field.NewField(tableName, "deleted_at")
- _world.fillFieldMap()
- return _world
- }
- type world struct {
- worldDo worldDo
- ALL field.Asterisk
- ID field.String
- SceneID field.String
- WorldURL field.String
- CreatedAt field.Time
- UpdatedAt field.Time
- DeletedAt field.Field
- fieldMap map[string]field.Expr
- }
- func (w world) Table(newTableName string) *world {
- w.worldDo.UseTable(newTableName)
- return w.updateTableName(newTableName)
- }
- func (w world) As(alias string) *world {
- w.worldDo.DO = *(w.worldDo.As(alias).(*gen.DO))
- return w.updateTableName(alias)
- }
- func (w *world) updateTableName(table string) *world {
- w.ALL = field.NewAsterisk(table)
- w.ID = field.NewString(table, "id")
- w.SceneID = field.NewString(table, "scene_id")
- w.WorldURL = field.NewString(table, "world_url")
- w.CreatedAt = field.NewTime(table, "created_at")
- w.UpdatedAt = field.NewTime(table, "updated_at")
- w.DeletedAt = field.NewField(table, "deleted_at")
- w.fillFieldMap()
- return w
- }
- func (w *world) WithContext(ctx context.Context) IWorldDo { return w.worldDo.WithContext(ctx) }
- func (w world) TableName() string { return w.worldDo.TableName() }
- func (w world) Alias() string { return w.worldDo.Alias() }
- func (w world) Columns(cols ...field.Expr) gen.Columns { return w.worldDo.Columns(cols...) }
- func (w *world) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
- _f, ok := w.fieldMap[fieldName]
- if !ok || _f == nil {
- return nil, false
- }
- _oe, ok := _f.(field.OrderExpr)
- return _oe, ok
- }
- func (w *world) fillFieldMap() {
- w.fieldMap = make(map[string]field.Expr, 6)
- w.fieldMap["id"] = w.ID
- w.fieldMap["scene_id"] = w.SceneID
- w.fieldMap["world_url"] = w.WorldURL
- w.fieldMap["created_at"] = w.CreatedAt
- w.fieldMap["updated_at"] = w.UpdatedAt
- w.fieldMap["deleted_at"] = w.DeletedAt
- }
- func (w world) clone(db *gorm.DB) world {
- w.worldDo.ReplaceConnPool(db.Statement.ConnPool)
- return w
- }
- func (w world) replaceDB(db *gorm.DB) world {
- w.worldDo.ReplaceDB(db)
- return w
- }
- type worldDo struct{ gen.DO }
- type IWorldDo interface {
- gen.SubQuery
- Debug() IWorldDo
- WithContext(ctx context.Context) IWorldDo
- WithResult(fc func(tx gen.Dao)) gen.ResultInfo
- ReplaceDB(db *gorm.DB)
- ReadDB() IWorldDo
- WriteDB() IWorldDo
- As(alias string) gen.Dao
- Session(config *gorm.Session) IWorldDo
- Columns(cols ...field.Expr) gen.Columns
- Clauses(conds ...clause.Expression) IWorldDo
- Not(conds ...gen.Condition) IWorldDo
- Or(conds ...gen.Condition) IWorldDo
- Select(conds ...field.Expr) IWorldDo
- Where(conds ...gen.Condition) IWorldDo
- Order(conds ...field.Expr) IWorldDo
- Distinct(cols ...field.Expr) IWorldDo
- Omit(cols ...field.Expr) IWorldDo
- Join(table schema.Tabler, on ...field.Expr) IWorldDo
- LeftJoin(table schema.Tabler, on ...field.Expr) IWorldDo
- RightJoin(table schema.Tabler, on ...field.Expr) IWorldDo
- Group(cols ...field.Expr) IWorldDo
- Having(conds ...gen.Condition) IWorldDo
- Limit(limit int) IWorldDo
- Offset(offset int) IWorldDo
- Count() (count int64, err error)
- Scopes(funcs ...func(gen.Dao) gen.Dao) IWorldDo
- Unscoped() IWorldDo
- Create(values ...*model.World) error
- CreateInBatches(values []*model.World, batchSize int) error
- Save(values ...*model.World) error
- First() (*model.World, error)
- Take() (*model.World, error)
- Last() (*model.World, error)
- Find() ([]*model.World, error)
- FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.World, err error)
- FindInBatches(result *[]*model.World, batchSize int, fc func(tx gen.Dao, batch int) error) error
- Pluck(column field.Expr, dest interface{}) error
- Delete(...*model.World) (info gen.ResultInfo, err error)
- Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
- UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
- Updates(value interface{}) (info gen.ResultInfo, err error)
- UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
- UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
- UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
- UpdateFrom(q gen.SubQuery) gen.Dao
- Attrs(attrs ...field.AssignExpr) IWorldDo
- Assign(attrs ...field.AssignExpr) IWorldDo
- Joins(fields ...field.RelationField) IWorldDo
- Preload(fields ...field.RelationField) IWorldDo
- FirstOrInit() (*model.World, error)
- FirstOrCreate() (*model.World, error)
- FindByPage(offset int, limit int) (result []*model.World, count int64, err error)
- ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
- Scan(result interface{}) (err error)
- Returning(value interface{}, columns ...string) IWorldDo
- UnderlyingDB() *gorm.DB
- schema.Tabler
- }
- func (w worldDo) Debug() IWorldDo {
- return w.withDO(w.DO.Debug())
- }
- func (w worldDo) WithContext(ctx context.Context) IWorldDo {
- return w.withDO(w.DO.WithContext(ctx))
- }
- func (w worldDo) ReadDB() IWorldDo {
- return w.Clauses(dbresolver.Read)
- }
- func (w worldDo) WriteDB() IWorldDo {
- return w.Clauses(dbresolver.Write)
- }
- func (w worldDo) Session(config *gorm.Session) IWorldDo {
- return w.withDO(w.DO.Session(config))
- }
- func (w worldDo) Clauses(conds ...clause.Expression) IWorldDo {
- return w.withDO(w.DO.Clauses(conds...))
- }
- func (w worldDo) Returning(value interface{}, columns ...string) IWorldDo {
- return w.withDO(w.DO.Returning(value, columns...))
- }
- func (w worldDo) Not(conds ...gen.Condition) IWorldDo {
- return w.withDO(w.DO.Not(conds...))
- }
- func (w worldDo) Or(conds ...gen.Condition) IWorldDo {
- return w.withDO(w.DO.Or(conds...))
- }
- func (w worldDo) Select(conds ...field.Expr) IWorldDo {
- return w.withDO(w.DO.Select(conds...))
- }
- func (w worldDo) Where(conds ...gen.Condition) IWorldDo {
- return w.withDO(w.DO.Where(conds...))
- }
- func (w worldDo) Order(conds ...field.Expr) IWorldDo {
- return w.withDO(w.DO.Order(conds...))
- }
- func (w worldDo) Distinct(cols ...field.Expr) IWorldDo {
- return w.withDO(w.DO.Distinct(cols...))
- }
- func (w worldDo) Omit(cols ...field.Expr) IWorldDo {
- return w.withDO(w.DO.Omit(cols...))
- }
- func (w worldDo) Join(table schema.Tabler, on ...field.Expr) IWorldDo {
- return w.withDO(w.DO.Join(table, on...))
- }
- func (w worldDo) LeftJoin(table schema.Tabler, on ...field.Expr) IWorldDo {
- return w.withDO(w.DO.LeftJoin(table, on...))
- }
- func (w worldDo) RightJoin(table schema.Tabler, on ...field.Expr) IWorldDo {
- return w.withDO(w.DO.RightJoin(table, on...))
- }
- func (w worldDo) Group(cols ...field.Expr) IWorldDo {
- return w.withDO(w.DO.Group(cols...))
- }
- func (w worldDo) Having(conds ...gen.Condition) IWorldDo {
- return w.withDO(w.DO.Having(conds...))
- }
- func (w worldDo) Limit(limit int) IWorldDo {
- return w.withDO(w.DO.Limit(limit))
- }
- func (w worldDo) Offset(offset int) IWorldDo {
- return w.withDO(w.DO.Offset(offset))
- }
- func (w worldDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IWorldDo {
- return w.withDO(w.DO.Scopes(funcs...))
- }
- func (w worldDo) Unscoped() IWorldDo {
- return w.withDO(w.DO.Unscoped())
- }
- func (w worldDo) Create(values ...*model.World) error {
- if len(values) == 0 {
- return nil
- }
- return w.DO.Create(values)
- }
- func (w worldDo) CreateInBatches(values []*model.World, batchSize int) error {
- return w.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 (w worldDo) Save(values ...*model.World) error {
- if len(values) == 0 {
- return nil
- }
- return w.DO.Save(values)
- }
- func (w worldDo) First() (*model.World, error) {
- if result, err := w.DO.First(); err != nil {
- return nil, err
- } else {
- return result.(*model.World), nil
- }
- }
- func (w worldDo) Take() (*model.World, error) {
- if result, err := w.DO.Take(); err != nil {
- return nil, err
- } else {
- return result.(*model.World), nil
- }
- }
- func (w worldDo) Last() (*model.World, error) {
- if result, err := w.DO.Last(); err != nil {
- return nil, err
- } else {
- return result.(*model.World), nil
- }
- }
- func (w worldDo) Find() ([]*model.World, error) {
- result, err := w.DO.Find()
- return result.([]*model.World), err
- }
- func (w worldDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.World, err error) {
- buf := make([]*model.World, 0, batchSize)
- err = w.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 (w worldDo) FindInBatches(result *[]*model.World, batchSize int, fc func(tx gen.Dao, batch int) error) error {
- return w.DO.FindInBatches(result, batchSize, fc)
- }
- func (w worldDo) Attrs(attrs ...field.AssignExpr) IWorldDo {
- return w.withDO(w.DO.Attrs(attrs...))
- }
- func (w worldDo) Assign(attrs ...field.AssignExpr) IWorldDo {
- return w.withDO(w.DO.Assign(attrs...))
- }
- func (w worldDo) Joins(fields ...field.RelationField) IWorldDo {
- for _, _f := range fields {
- w = *w.withDO(w.DO.Joins(_f))
- }
- return &w
- }
- func (w worldDo) Preload(fields ...field.RelationField) IWorldDo {
- for _, _f := range fields {
- w = *w.withDO(w.DO.Preload(_f))
- }
- return &w
- }
- func (w worldDo) FirstOrInit() (*model.World, error) {
- if result, err := w.DO.FirstOrInit(); err != nil {
- return nil, err
- } else {
- return result.(*model.World), nil
- }
- }
- func (w worldDo) FirstOrCreate() (*model.World, error) {
- if result, err := w.DO.FirstOrCreate(); err != nil {
- return nil, err
- } else {
- return result.(*model.World), nil
- }
- }
- func (w worldDo) FindByPage(offset int, limit int) (result []*model.World, count int64, err error) {
- result, err = w.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 = w.Offset(-1).Limit(-1).Count()
- return
- }
- func (w worldDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
- count, err = w.Count()
- if err != nil {
- return
- }
- err = w.Offset(offset).Limit(limit).Scan(result)
- return
- }
- func (w worldDo) Scan(result interface{}) (err error) {
- return w.DO.Scan(result)
- }
- func (w worldDo) Delete(models ...*model.World) (result gen.ResultInfo, err error) {
- return w.DO.Delete(models)
- }
- func (w *worldDo) withDO(do gen.Dao) *worldDo {
- w.DO = *do.(*gen.DO)
- return w
- }
|