123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- // 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"
- "gadmin/internal/gorm/model"
- )
- func newRetrofit(db *gorm.DB, opts ...gen.DOOption) retrofit {
- _retrofit := retrofit{}
- _retrofit.retrofitDo.UseDB(db, opts...)
- _retrofit.retrofitDo.UseModel(&model.Retrofit{})
- tableName := _retrofit.retrofitDo.TableName()
- _retrofit.ALL = field.NewAsterisk(tableName)
- _retrofit.ID = field.NewInt64(tableName, "id")
- _retrofit.GroupID = field.NewInt64(tableName, "group_id")
- _retrofit.Name = field.NewString(tableName, "name")
- _retrofit.Type = field.NewInt64(tableName, "type")
- _retrofit.Mid = field.NewInt64(tableName, "mid")
- _retrofit.Nums = field.NewInt64(tableName, "nums")
- _retrofit.Status = field.NewInt32(tableName, "status")
- _retrofit.CreatedAt = field.NewTime(tableName, "created_at")
- _retrofit.UpdatedAt = field.NewTime(tableName, "updated_at")
- _retrofit.DeletedAt = field.NewField(tableName, "deleted_at")
- _retrofit.fillFieldMap()
- return _retrofit
- }
- type retrofit struct {
- retrofitDo
- ALL field.Asterisk
- ID field.Int64
- GroupID field.Int64 // 模板ID
- Name field.String // 别名
- Type field.Int64 // 加装类型
- Mid field.Int64 // 关联ID
- Nums field.Int64 // 数量
- Status field.Int32 // 状态
- CreatedAt field.Time // 创建时间
- UpdatedAt field.Time // 更新时间
- DeletedAt field.Field // 删除时间
- fieldMap map[string]field.Expr
- }
- func (r retrofit) Table(newTableName string) *retrofit {
- r.retrofitDo.UseTable(newTableName)
- return r.updateTableName(newTableName)
- }
- func (r retrofit) As(alias string) *retrofit {
- r.retrofitDo.DO = *(r.retrofitDo.As(alias).(*gen.DO))
- return r.updateTableName(alias)
- }
- func (r *retrofit) updateTableName(table string) *retrofit {
- r.ALL = field.NewAsterisk(table)
- r.ID = field.NewInt64(table, "id")
- r.GroupID = field.NewInt64(table, "group_id")
- r.Name = field.NewString(table, "name")
- r.Type = field.NewInt64(table, "type")
- r.Mid = field.NewInt64(table, "mid")
- r.Nums = field.NewInt64(table, "nums")
- r.Status = field.NewInt32(table, "status")
- r.CreatedAt = field.NewTime(table, "created_at")
- r.UpdatedAt = field.NewTime(table, "updated_at")
- r.DeletedAt = field.NewField(table, "deleted_at")
- r.fillFieldMap()
- return r
- }
- func (r *retrofit) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
- _f, ok := r.fieldMap[fieldName]
- if !ok || _f == nil {
- return nil, false
- }
- _oe, ok := _f.(field.OrderExpr)
- return _oe, ok
- }
- func (r *retrofit) fillFieldMap() {
- r.fieldMap = make(map[string]field.Expr, 10)
- r.fieldMap["id"] = r.ID
- r.fieldMap["group_id"] = r.GroupID
- r.fieldMap["name"] = r.Name
- r.fieldMap["type"] = r.Type
- r.fieldMap["mid"] = r.Mid
- r.fieldMap["nums"] = r.Nums
- r.fieldMap["status"] = r.Status
- r.fieldMap["created_at"] = r.CreatedAt
- r.fieldMap["updated_at"] = r.UpdatedAt
- r.fieldMap["deleted_at"] = r.DeletedAt
- }
- func (r retrofit) clone(db *gorm.DB) retrofit {
- r.retrofitDo.ReplaceConnPool(db.Statement.ConnPool)
- return r
- }
- func (r retrofit) replaceDB(db *gorm.DB) retrofit {
- r.retrofitDo.ReplaceDB(db)
- return r
- }
- type retrofitDo struct{ gen.DO }
- func (r retrofitDo) Debug() *retrofitDo {
- return r.withDO(r.DO.Debug())
- }
- func (r retrofitDo) WithContext(ctx context.Context) *retrofitDo {
- return r.withDO(r.DO.WithContext(ctx))
- }
- func (r retrofitDo) ReadDB() *retrofitDo {
- return r.Clauses(dbresolver.Read)
- }
- func (r retrofitDo) WriteDB() *retrofitDo {
- return r.Clauses(dbresolver.Write)
- }
- func (r retrofitDo) Session(config *gorm.Session) *retrofitDo {
- return r.withDO(r.DO.Session(config))
- }
- func (r retrofitDo) Clauses(conds ...clause.Expression) *retrofitDo {
- return r.withDO(r.DO.Clauses(conds...))
- }
- func (r retrofitDo) Returning(value interface{}, columns ...string) *retrofitDo {
- return r.withDO(r.DO.Returning(value, columns...))
- }
- func (r retrofitDo) Not(conds ...gen.Condition) *retrofitDo {
- return r.withDO(r.DO.Not(conds...))
- }
- func (r retrofitDo) Or(conds ...gen.Condition) *retrofitDo {
- return r.withDO(r.DO.Or(conds...))
- }
- func (r retrofitDo) Select(conds ...field.Expr) *retrofitDo {
- return r.withDO(r.DO.Select(conds...))
- }
- func (r retrofitDo) Where(conds ...gen.Condition) *retrofitDo {
- return r.withDO(r.DO.Where(conds...))
- }
- func (r retrofitDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *retrofitDo {
- return r.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
- }
- func (r retrofitDo) Order(conds ...field.Expr) *retrofitDo {
- return r.withDO(r.DO.Order(conds...))
- }
- func (r retrofitDo) Distinct(cols ...field.Expr) *retrofitDo {
- return r.withDO(r.DO.Distinct(cols...))
- }
- func (r retrofitDo) Omit(cols ...field.Expr) *retrofitDo {
- return r.withDO(r.DO.Omit(cols...))
- }
- func (r retrofitDo) Join(table schema.Tabler, on ...field.Expr) *retrofitDo {
- return r.withDO(r.DO.Join(table, on...))
- }
- func (r retrofitDo) LeftJoin(table schema.Tabler, on ...field.Expr) *retrofitDo {
- return r.withDO(r.DO.LeftJoin(table, on...))
- }
- func (r retrofitDo) RightJoin(table schema.Tabler, on ...field.Expr) *retrofitDo {
- return r.withDO(r.DO.RightJoin(table, on...))
- }
- func (r retrofitDo) Group(cols ...field.Expr) *retrofitDo {
- return r.withDO(r.DO.Group(cols...))
- }
- func (r retrofitDo) Having(conds ...gen.Condition) *retrofitDo {
- return r.withDO(r.DO.Having(conds...))
- }
- func (r retrofitDo) Limit(limit int) *retrofitDo {
- return r.withDO(r.DO.Limit(limit))
- }
- func (r retrofitDo) Offset(offset int) *retrofitDo {
- return r.withDO(r.DO.Offset(offset))
- }
- func (r retrofitDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *retrofitDo {
- return r.withDO(r.DO.Scopes(funcs...))
- }
- func (r retrofitDo) Unscoped() *retrofitDo {
- return r.withDO(r.DO.Unscoped())
- }
- func (r retrofitDo) Create(values ...*model.Retrofit) error {
- if len(values) == 0 {
- return nil
- }
- return r.DO.Create(values)
- }
- func (r retrofitDo) CreateInBatches(values []*model.Retrofit, batchSize int) error {
- return r.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 (r retrofitDo) Save(values ...*model.Retrofit) error {
- if len(values) == 0 {
- return nil
- }
- return r.DO.Save(values)
- }
- func (r retrofitDo) First() (*model.Retrofit, error) {
- if result, err := r.DO.First(); err != nil {
- return nil, err
- } else {
- return result.(*model.Retrofit), nil
- }
- }
- func (r retrofitDo) Take() (*model.Retrofit, error) {
- if result, err := r.DO.Take(); err != nil {
- return nil, err
- } else {
- return result.(*model.Retrofit), nil
- }
- }
- func (r retrofitDo) Last() (*model.Retrofit, error) {
- if result, err := r.DO.Last(); err != nil {
- return nil, err
- } else {
- return result.(*model.Retrofit), nil
- }
- }
- func (r retrofitDo) Find() ([]*model.Retrofit, error) {
- result, err := r.DO.Find()
- return result.([]*model.Retrofit), err
- }
- func (r retrofitDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Retrofit, err error) {
- buf := make([]*model.Retrofit, 0, batchSize)
- err = r.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 (r retrofitDo) FindInBatches(result *[]*model.Retrofit, batchSize int, fc func(tx gen.Dao, batch int) error) error {
- return r.DO.FindInBatches(result, batchSize, fc)
- }
- func (r retrofitDo) Attrs(attrs ...field.AssignExpr) *retrofitDo {
- return r.withDO(r.DO.Attrs(attrs...))
- }
- func (r retrofitDo) Assign(attrs ...field.AssignExpr) *retrofitDo {
- return r.withDO(r.DO.Assign(attrs...))
- }
- func (r retrofitDo) Joins(fields ...field.RelationField) *retrofitDo {
- for _, _f := range fields {
- r = *r.withDO(r.DO.Joins(_f))
- }
- return &r
- }
- func (r retrofitDo) Preload(fields ...field.RelationField) *retrofitDo {
- for _, _f := range fields {
- r = *r.withDO(r.DO.Preload(_f))
- }
- return &r
- }
- func (r retrofitDo) FirstOrInit() (*model.Retrofit, error) {
- if result, err := r.DO.FirstOrInit(); err != nil {
- return nil, err
- } else {
- return result.(*model.Retrofit), nil
- }
- }
- func (r retrofitDo) FirstOrCreate() (*model.Retrofit, error) {
- if result, err := r.DO.FirstOrCreate(); err != nil {
- return nil, err
- } else {
- return result.(*model.Retrofit), nil
- }
- }
- func (r retrofitDo) FindByPage(offset int, limit int) (result []*model.Retrofit, count int64, err error) {
- result, err = r.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 = r.Offset(-1).Limit(-1).Count()
- return
- }
- func (r retrofitDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
- count, err = r.Count()
- if err != nil {
- return
- }
- err = r.Offset(offset).Limit(limit).Scan(result)
- return
- }
- func (r retrofitDo) Scan(result interface{}) (err error) {
- return r.DO.Scan(result)
- }
- func (r retrofitDo) Delete(models ...*model.Retrofit) (result gen.ResultInfo, err error) {
- return r.DO.Delete(models)
- }
- func (r *retrofitDo) withDO(do gen.Dao) *retrofitDo {
- r.DO = *do.(*gen.DO)
- return r
- }
|