123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413 |
- // 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"
- "wechat-api/database/dao/wechat/model"
- )
- func newTutorial(db *gorm.DB, opts ...gen.DOOption) tutorial {
- _tutorial := tutorial{}
- _tutorial.tutorialDo.UseDB(db, opts...)
- _tutorial.tutorialDo.UseModel(&model.Tutorial{})
- tableName := _tutorial.tutorialDo.TableName()
- _tutorial.ALL = field.NewAsterisk(tableName)
- _tutorial.ID = field.NewInt64(tableName, "id")
- _tutorial.EmployeeID = field.NewInt64(tableName, "employee_id")
- _tutorial.CreatedAt = field.NewTime(tableName, "created_at")
- _tutorial.UpdatedAt = field.NewTime(tableName, "updated_at")
- _tutorial.DeletedAt = field.NewField(tableName, "deleted_at")
- _tutorial.Index = field.NewInt64(tableName, "index")
- _tutorial.Title = field.NewString(tableName, "title")
- _tutorial.Content = field.NewString(tableName, "content")
- _tutorial.OrganizationID = field.NewInt64(tableName, "organization_id")
- _tutorial.fillFieldMap()
- return _tutorial
- }
- // tutorial 数字员工使用教程表
- type tutorial struct {
- tutorialDo
- ALL field.Asterisk
- ID field.Int64
- EmployeeID field.Int64 // 员工ID
- CreatedAt field.Time // Create Time | 创建日期
- UpdatedAt field.Time // Update Time | 修改日期
- DeletedAt field.Field // Delete Time | 删除日期
- Index field.Int64 // 序号
- Title field.String // 标题
- Content field.String // 内容
- OrganizationID field.Int64 // 机构ID
- fieldMap map[string]field.Expr
- }
- func (t tutorial) Table(newTableName string) *tutorial {
- t.tutorialDo.UseTable(newTableName)
- return t.updateTableName(newTableName)
- }
- func (t tutorial) As(alias string) *tutorial {
- t.tutorialDo.DO = *(t.tutorialDo.As(alias).(*gen.DO))
- return t.updateTableName(alias)
- }
- func (t *tutorial) updateTableName(table string) *tutorial {
- t.ALL = field.NewAsterisk(table)
- t.ID = field.NewInt64(table, "id")
- t.EmployeeID = field.NewInt64(table, "employee_id")
- t.CreatedAt = field.NewTime(table, "created_at")
- t.UpdatedAt = field.NewTime(table, "updated_at")
- t.DeletedAt = field.NewField(table, "deleted_at")
- t.Index = field.NewInt64(table, "index")
- t.Title = field.NewString(table, "title")
- t.Content = field.NewString(table, "content")
- t.OrganizationID = field.NewInt64(table, "organization_id")
- t.fillFieldMap()
- return t
- }
- func (t *tutorial) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
- _f, ok := t.fieldMap[fieldName]
- if !ok || _f == nil {
- return nil, false
- }
- _oe, ok := _f.(field.OrderExpr)
- return _oe, ok
- }
- func (t *tutorial) fillFieldMap() {
- t.fieldMap = make(map[string]field.Expr, 9)
- t.fieldMap["id"] = t.ID
- t.fieldMap["employee_id"] = t.EmployeeID
- t.fieldMap["created_at"] = t.CreatedAt
- t.fieldMap["updated_at"] = t.UpdatedAt
- t.fieldMap["deleted_at"] = t.DeletedAt
- t.fieldMap["index"] = t.Index
- t.fieldMap["title"] = t.Title
- t.fieldMap["content"] = t.Content
- t.fieldMap["organization_id"] = t.OrganizationID
- }
- func (t tutorial) clone(db *gorm.DB) tutorial {
- t.tutorialDo.ReplaceConnPool(db.Statement.ConnPool)
- return t
- }
- func (t tutorial) replaceDB(db *gorm.DB) tutorial {
- t.tutorialDo.ReplaceDB(db)
- return t
- }
- type tutorialDo struct{ gen.DO }
- type ITutorialDo interface {
- gen.SubQuery
- Debug() ITutorialDo
- WithContext(ctx context.Context) ITutorialDo
- WithResult(fc func(tx gen.Dao)) gen.ResultInfo
- ReplaceDB(db *gorm.DB)
- ReadDB() ITutorialDo
- WriteDB() ITutorialDo
- As(alias string) gen.Dao
- Session(config *gorm.Session) ITutorialDo
- Columns(cols ...field.Expr) gen.Columns
- Clauses(conds ...clause.Expression) ITutorialDo
- Not(conds ...gen.Condition) ITutorialDo
- Or(conds ...gen.Condition) ITutorialDo
- Select(conds ...field.Expr) ITutorialDo
- Where(conds ...gen.Condition) ITutorialDo
- Order(conds ...field.Expr) ITutorialDo
- Distinct(cols ...field.Expr) ITutorialDo
- Omit(cols ...field.Expr) ITutorialDo
- Join(table schema.Tabler, on ...field.Expr) ITutorialDo
- LeftJoin(table schema.Tabler, on ...field.Expr) ITutorialDo
- RightJoin(table schema.Tabler, on ...field.Expr) ITutorialDo
- Group(cols ...field.Expr) ITutorialDo
- Having(conds ...gen.Condition) ITutorialDo
- Limit(limit int) ITutorialDo
- Offset(offset int) ITutorialDo
- Count() (count int64, err error)
- Scopes(funcs ...func(gen.Dao) gen.Dao) ITutorialDo
- Unscoped() ITutorialDo
- Create(values ...*model.Tutorial) error
- CreateInBatches(values []*model.Tutorial, batchSize int) error
- Save(values ...*model.Tutorial) error
- First() (*model.Tutorial, error)
- Take() (*model.Tutorial, error)
- Last() (*model.Tutorial, error)
- Find() ([]*model.Tutorial, error)
- FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Tutorial, err error)
- FindInBatches(result *[]*model.Tutorial, batchSize int, fc func(tx gen.Dao, batch int) error) error
- Pluck(column field.Expr, dest interface{}) error
- Delete(...*model.Tutorial) (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) ITutorialDo
- Assign(attrs ...field.AssignExpr) ITutorialDo
- Joins(fields ...field.RelationField) ITutorialDo
- Preload(fields ...field.RelationField) ITutorialDo
- FirstOrInit() (*model.Tutorial, error)
- FirstOrCreate() (*model.Tutorial, error)
- FindByPage(offset int, limit int) (result []*model.Tutorial, 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) ITutorialDo
- UnderlyingDB() *gorm.DB
- schema.Tabler
- }
- func (t tutorialDo) Debug() ITutorialDo {
- return t.withDO(t.DO.Debug())
- }
- func (t tutorialDo) WithContext(ctx context.Context) ITutorialDo {
- return t.withDO(t.DO.WithContext(ctx))
- }
- func (t tutorialDo) ReadDB() ITutorialDo {
- return t.Clauses(dbresolver.Read)
- }
- func (t tutorialDo) WriteDB() ITutorialDo {
- return t.Clauses(dbresolver.Write)
- }
- func (t tutorialDo) Session(config *gorm.Session) ITutorialDo {
- return t.withDO(t.DO.Session(config))
- }
- func (t tutorialDo) Clauses(conds ...clause.Expression) ITutorialDo {
- return t.withDO(t.DO.Clauses(conds...))
- }
- func (t tutorialDo) Returning(value interface{}, columns ...string) ITutorialDo {
- return t.withDO(t.DO.Returning(value, columns...))
- }
- func (t tutorialDo) Not(conds ...gen.Condition) ITutorialDo {
- return t.withDO(t.DO.Not(conds...))
- }
- func (t tutorialDo) Or(conds ...gen.Condition) ITutorialDo {
- return t.withDO(t.DO.Or(conds...))
- }
- func (t tutorialDo) Select(conds ...field.Expr) ITutorialDo {
- return t.withDO(t.DO.Select(conds...))
- }
- func (t tutorialDo) Where(conds ...gen.Condition) ITutorialDo {
- return t.withDO(t.DO.Where(conds...))
- }
- func (t tutorialDo) Order(conds ...field.Expr) ITutorialDo {
- return t.withDO(t.DO.Order(conds...))
- }
- func (t tutorialDo) Distinct(cols ...field.Expr) ITutorialDo {
- return t.withDO(t.DO.Distinct(cols...))
- }
- func (t tutorialDo) Omit(cols ...field.Expr) ITutorialDo {
- return t.withDO(t.DO.Omit(cols...))
- }
- func (t tutorialDo) Join(table schema.Tabler, on ...field.Expr) ITutorialDo {
- return t.withDO(t.DO.Join(table, on...))
- }
- func (t tutorialDo) LeftJoin(table schema.Tabler, on ...field.Expr) ITutorialDo {
- return t.withDO(t.DO.LeftJoin(table, on...))
- }
- func (t tutorialDo) RightJoin(table schema.Tabler, on ...field.Expr) ITutorialDo {
- return t.withDO(t.DO.RightJoin(table, on...))
- }
- func (t tutorialDo) Group(cols ...field.Expr) ITutorialDo {
- return t.withDO(t.DO.Group(cols...))
- }
- func (t tutorialDo) Having(conds ...gen.Condition) ITutorialDo {
- return t.withDO(t.DO.Having(conds...))
- }
- func (t tutorialDo) Limit(limit int) ITutorialDo {
- return t.withDO(t.DO.Limit(limit))
- }
- func (t tutorialDo) Offset(offset int) ITutorialDo {
- return t.withDO(t.DO.Offset(offset))
- }
- func (t tutorialDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ITutorialDo {
- return t.withDO(t.DO.Scopes(funcs...))
- }
- func (t tutorialDo) Unscoped() ITutorialDo {
- return t.withDO(t.DO.Unscoped())
- }
- func (t tutorialDo) Create(values ...*model.Tutorial) error {
- if len(values) == 0 {
- return nil
- }
- return t.DO.Create(values)
- }
- func (t tutorialDo) CreateInBatches(values []*model.Tutorial, batchSize int) error {
- return t.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 (t tutorialDo) Save(values ...*model.Tutorial) error {
- if len(values) == 0 {
- return nil
- }
- return t.DO.Save(values)
- }
- func (t tutorialDo) First() (*model.Tutorial, error) {
- if result, err := t.DO.First(); err != nil {
- return nil, err
- } else {
- return result.(*model.Tutorial), nil
- }
- }
- func (t tutorialDo) Take() (*model.Tutorial, error) {
- if result, err := t.DO.Take(); err != nil {
- return nil, err
- } else {
- return result.(*model.Tutorial), nil
- }
- }
- func (t tutorialDo) Last() (*model.Tutorial, error) {
- if result, err := t.DO.Last(); err != nil {
- return nil, err
- } else {
- return result.(*model.Tutorial), nil
- }
- }
- func (t tutorialDo) Find() ([]*model.Tutorial, error) {
- result, err := t.DO.Find()
- return result.([]*model.Tutorial), err
- }
- func (t tutorialDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Tutorial, err error) {
- buf := make([]*model.Tutorial, 0, batchSize)
- err = t.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 (t tutorialDo) FindInBatches(result *[]*model.Tutorial, batchSize int, fc func(tx gen.Dao, batch int) error) error {
- return t.DO.FindInBatches(result, batchSize, fc)
- }
- func (t tutorialDo) Attrs(attrs ...field.AssignExpr) ITutorialDo {
- return t.withDO(t.DO.Attrs(attrs...))
- }
- func (t tutorialDo) Assign(attrs ...field.AssignExpr) ITutorialDo {
- return t.withDO(t.DO.Assign(attrs...))
- }
- func (t tutorialDo) Joins(fields ...field.RelationField) ITutorialDo {
- for _, _f := range fields {
- t = *t.withDO(t.DO.Joins(_f))
- }
- return &t
- }
- func (t tutorialDo) Preload(fields ...field.RelationField) ITutorialDo {
- for _, _f := range fields {
- t = *t.withDO(t.DO.Preload(_f))
- }
- return &t
- }
- func (t tutorialDo) FirstOrInit() (*model.Tutorial, error) {
- if result, err := t.DO.FirstOrInit(); err != nil {
- return nil, err
- } else {
- return result.(*model.Tutorial), nil
- }
- }
- func (t tutorialDo) FirstOrCreate() (*model.Tutorial, error) {
- if result, err := t.DO.FirstOrCreate(); err != nil {
- return nil, err
- } else {
- return result.(*model.Tutorial), nil
- }
- }
- func (t tutorialDo) FindByPage(offset int, limit int) (result []*model.Tutorial, count int64, err error) {
- result, err = t.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 = t.Offset(-1).Limit(-1).Count()
- return
- }
- func (t tutorialDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
- count, err = t.Count()
- if err != nil {
- return
- }
- err = t.Offset(offset).Limit(limit).Scan(result)
- return
- }
- func (t tutorialDo) Scan(result interface{}) (err error) {
- return t.DO.Scan(result)
- }
- func (t tutorialDo) Delete(models ...*model.Tutorial) (result gen.ResultInfo, err error) {
- return t.DO.Delete(models)
- }
- func (t *tutorialDo) withDO(do gen.Dao) *tutorialDo {
- t.DO = *do.(*gen.DO)
- return t
- }
|