123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351 |
- // 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 newRetrofitGroup(db *gorm.DB, opts ...gen.DOOption) retrofitGroup {
- _retrofitGroup := retrofitGroup{}
- _retrofitGroup.retrofitGroupDo.UseDB(db, opts...)
- _retrofitGroup.retrofitGroupDo.UseModel(&model.RetrofitGroup{})
- tableName := _retrofitGroup.retrofitGroupDo.TableName()
- _retrofitGroup.ALL = field.NewAsterisk(tableName)
- _retrofitGroup.ID = field.NewInt64(tableName, "id")
- _retrofitGroup.Name = field.NewString(tableName, "name")
- _retrofitGroup.Remark = field.NewString(tableName, "remark")
- _retrofitGroup.Sort = field.NewInt64(tableName, "sort")
- _retrofitGroup.Status = field.NewInt32(tableName, "status")
- _retrofitGroup.CreatedAt = field.NewTime(tableName, "created_at")
- _retrofitGroup.UpdatedAt = field.NewTime(tableName, "updated_at")
- _retrofitGroup.DeletedAt = field.NewField(tableName, "deleted_at")
- _retrofitGroup.fillFieldMap()
- return _retrofitGroup
- }
- type retrofitGroup struct {
- retrofitGroupDo
- ALL field.Asterisk
- ID field.Int64
- Name field.String // 模板名称
- Remark field.String // 备注
- Sort field.Int64 // 排序
- Status field.Int32 // 状态
- CreatedAt field.Time // 创建时间
- UpdatedAt field.Time // 更新时间
- DeletedAt field.Field // 删除时间
- fieldMap map[string]field.Expr
- }
- func (r retrofitGroup) Table(newTableName string) *retrofitGroup {
- r.retrofitGroupDo.UseTable(newTableName)
- return r.updateTableName(newTableName)
- }
- func (r retrofitGroup) As(alias string) *retrofitGroup {
- r.retrofitGroupDo.DO = *(r.retrofitGroupDo.As(alias).(*gen.DO))
- return r.updateTableName(alias)
- }
- func (r *retrofitGroup) updateTableName(table string) *retrofitGroup {
- r.ALL = field.NewAsterisk(table)
- r.ID = field.NewInt64(table, "id")
- r.Name = field.NewString(table, "name")
- r.Remark = field.NewString(table, "remark")
- r.Sort = field.NewInt64(table, "sort")
- 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 *retrofitGroup) 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 *retrofitGroup) fillFieldMap() {
- r.fieldMap = make(map[string]field.Expr, 8)
- r.fieldMap["id"] = r.ID
- r.fieldMap["name"] = r.Name
- r.fieldMap["remark"] = r.Remark
- r.fieldMap["sort"] = r.Sort
- 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 retrofitGroup) clone(db *gorm.DB) retrofitGroup {
- r.retrofitGroupDo.ReplaceConnPool(db.Statement.ConnPool)
- return r
- }
- func (r retrofitGroup) replaceDB(db *gorm.DB) retrofitGroup {
- r.retrofitGroupDo.ReplaceDB(db)
- return r
- }
- type retrofitGroupDo struct{ gen.DO }
- func (r retrofitGroupDo) Debug() *retrofitGroupDo {
- return r.withDO(r.DO.Debug())
- }
- func (r retrofitGroupDo) WithContext(ctx context.Context) *retrofitGroupDo {
- return r.withDO(r.DO.WithContext(ctx))
- }
- func (r retrofitGroupDo) ReadDB() *retrofitGroupDo {
- return r.Clauses(dbresolver.Read)
- }
- func (r retrofitGroupDo) WriteDB() *retrofitGroupDo {
- return r.Clauses(dbresolver.Write)
- }
- func (r retrofitGroupDo) Session(config *gorm.Session) *retrofitGroupDo {
- return r.withDO(r.DO.Session(config))
- }
- func (r retrofitGroupDo) Clauses(conds ...clause.Expression) *retrofitGroupDo {
- return r.withDO(r.DO.Clauses(conds...))
- }
- func (r retrofitGroupDo) Returning(value interface{}, columns ...string) *retrofitGroupDo {
- return r.withDO(r.DO.Returning(value, columns...))
- }
- func (r retrofitGroupDo) Not(conds ...gen.Condition) *retrofitGroupDo {
- return r.withDO(r.DO.Not(conds...))
- }
- func (r retrofitGroupDo) Or(conds ...gen.Condition) *retrofitGroupDo {
- return r.withDO(r.DO.Or(conds...))
- }
- func (r retrofitGroupDo) Select(conds ...field.Expr) *retrofitGroupDo {
- return r.withDO(r.DO.Select(conds...))
- }
- func (r retrofitGroupDo) Where(conds ...gen.Condition) *retrofitGroupDo {
- return r.withDO(r.DO.Where(conds...))
- }
- func (r retrofitGroupDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *retrofitGroupDo {
- return r.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
- }
- func (r retrofitGroupDo) Order(conds ...field.Expr) *retrofitGroupDo {
- return r.withDO(r.DO.Order(conds...))
- }
- func (r retrofitGroupDo) Distinct(cols ...field.Expr) *retrofitGroupDo {
- return r.withDO(r.DO.Distinct(cols...))
- }
- func (r retrofitGroupDo) Omit(cols ...field.Expr) *retrofitGroupDo {
- return r.withDO(r.DO.Omit(cols...))
- }
- func (r retrofitGroupDo) Join(table schema.Tabler, on ...field.Expr) *retrofitGroupDo {
- return r.withDO(r.DO.Join(table, on...))
- }
- func (r retrofitGroupDo) LeftJoin(table schema.Tabler, on ...field.Expr) *retrofitGroupDo {
- return r.withDO(r.DO.LeftJoin(table, on...))
- }
- func (r retrofitGroupDo) RightJoin(table schema.Tabler, on ...field.Expr) *retrofitGroupDo {
- return r.withDO(r.DO.RightJoin(table, on...))
- }
- func (r retrofitGroupDo) Group(cols ...field.Expr) *retrofitGroupDo {
- return r.withDO(r.DO.Group(cols...))
- }
- func (r retrofitGroupDo) Having(conds ...gen.Condition) *retrofitGroupDo {
- return r.withDO(r.DO.Having(conds...))
- }
- func (r retrofitGroupDo) Limit(limit int) *retrofitGroupDo {
- return r.withDO(r.DO.Limit(limit))
- }
- func (r retrofitGroupDo) Offset(offset int) *retrofitGroupDo {
- return r.withDO(r.DO.Offset(offset))
- }
- func (r retrofitGroupDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *retrofitGroupDo {
- return r.withDO(r.DO.Scopes(funcs...))
- }
- func (r retrofitGroupDo) Unscoped() *retrofitGroupDo {
- return r.withDO(r.DO.Unscoped())
- }
- func (r retrofitGroupDo) Create(values ...*model.RetrofitGroup) error {
- if len(values) == 0 {
- return nil
- }
- return r.DO.Create(values)
- }
- func (r retrofitGroupDo) CreateInBatches(values []*model.RetrofitGroup, 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 retrofitGroupDo) Save(values ...*model.RetrofitGroup) error {
- if len(values) == 0 {
- return nil
- }
- return r.DO.Save(values)
- }
- func (r retrofitGroupDo) First() (*model.RetrofitGroup, error) {
- if result, err := r.DO.First(); err != nil {
- return nil, err
- } else {
- return result.(*model.RetrofitGroup), nil
- }
- }
- func (r retrofitGroupDo) Take() (*model.RetrofitGroup, error) {
- if result, err := r.DO.Take(); err != nil {
- return nil, err
- } else {
- return result.(*model.RetrofitGroup), nil
- }
- }
- func (r retrofitGroupDo) Last() (*model.RetrofitGroup, error) {
- if result, err := r.DO.Last(); err != nil {
- return nil, err
- } else {
- return result.(*model.RetrofitGroup), nil
- }
- }
- func (r retrofitGroupDo) Find() ([]*model.RetrofitGroup, error) {
- result, err := r.DO.Find()
- return result.([]*model.RetrofitGroup), err
- }
- func (r retrofitGroupDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.RetrofitGroup, err error) {
- buf := make([]*model.RetrofitGroup, 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 retrofitGroupDo) FindInBatches(result *[]*model.RetrofitGroup, batchSize int, fc func(tx gen.Dao, batch int) error) error {
- return r.DO.FindInBatches(result, batchSize, fc)
- }
- func (r retrofitGroupDo) Attrs(attrs ...field.AssignExpr) *retrofitGroupDo {
- return r.withDO(r.DO.Attrs(attrs...))
- }
- func (r retrofitGroupDo) Assign(attrs ...field.AssignExpr) *retrofitGroupDo {
- return r.withDO(r.DO.Assign(attrs...))
- }
- func (r retrofitGroupDo) Joins(fields ...field.RelationField) *retrofitGroupDo {
- for _, _f := range fields {
- r = *r.withDO(r.DO.Joins(_f))
- }
- return &r
- }
- func (r retrofitGroupDo) Preload(fields ...field.RelationField) *retrofitGroupDo {
- for _, _f := range fields {
- r = *r.withDO(r.DO.Preload(_f))
- }
- return &r
- }
- func (r retrofitGroupDo) FirstOrInit() (*model.RetrofitGroup, error) {
- if result, err := r.DO.FirstOrInit(); err != nil {
- return nil, err
- } else {
- return result.(*model.RetrofitGroup), nil
- }
- }
- func (r retrofitGroupDo) FirstOrCreate() (*model.RetrofitGroup, error) {
- if result, err := r.DO.FirstOrCreate(); err != nil {
- return nil, err
- } else {
- return result.(*model.RetrofitGroup), nil
- }
- }
- func (r retrofitGroupDo) FindByPage(offset int, limit int) (result []*model.RetrofitGroup, 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 retrofitGroupDo) 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 retrofitGroupDo) Scan(result interface{}) (err error) {
- return r.DO.Scan(result)
- }
- func (r retrofitGroupDo) Delete(models ...*model.RetrofitGroup) (result gen.ResultInfo, err error) {
- return r.DO.Delete(models)
- }
- func (r *retrofitGroupDo) withDO(do gen.Dao) *retrofitGroupDo {
- r.DO = *do.(*gen.DO)
- return r
- }
|