123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432 |
- // 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 model
- import (
- "context"
- "gorm.io/gorm"
- "gorm.io/gorm/clause"
- "gorm.io/gorm/schema"
- "gorm.io/gen"
- "gorm.io/gen/field"
- "gorm.io/plugin/dbresolver"
- "icloudapp.cn/tools/service/entity"
- )
- func newMaterial(db *gorm.DB, opts ...gen.DOOption) MMaterial {
- _MMaterial := MMaterial{}
- _MMaterial.MMaterialDo.UseDB(db, opts...)
- _MMaterial.MMaterialDo.UseModel(&entity.Material{})
- tableName := _MMaterial.MMaterialDo.TableName()
- _MMaterial.ALL = field.NewAsterisk(tableName)
- _MMaterial.ID = field.NewInt64(tableName, "id")
- _MMaterial.Name = field.NewString(tableName, "name")
- _MMaterial.File = field.NewString(tableName, "file")
- _MMaterial.Size = field.NewString(tableName, "size")
- _MMaterial.FileSize = field.NewInt64(tableName, "file_size")
- _MMaterial.Hash = field.NewString(tableName, "hash")
- _MMaterial.Type = field.NewString(tableName, "type")
- _MMaterial.UID = field.NewInt64(tableName, "uid")
- _MMaterial.Status = field.NewInt64(tableName, "status")
- _MMaterial.CreateAt = field.NewTime(tableName, "create_at")
- _MMaterial.UpdateAt = field.NewTime(tableName, "update_at")
- _MMaterial.fillFieldMap()
- return _MMaterial
- }
- type MMaterial struct {
- MMaterialDo MMaterialDo
- ALL field.Asterisk
- ID field.Int64 // 素材ID
- Name field.String // 素材名称
- File field.String // 素材地址
- Size field.String // 素材尺寸
- FileSize field.Int64 // 素材大小
- Hash field.String // 素材文件hash
- Type field.String // 素材类型
- UID field.Int64 // 上传用户
- Status field.Int64 // 素材状态
- CreateAt field.Time // 创建时间
- UpdateAt field.Time // 更新时间
- fieldMap map[string]field.Expr
- }
- func (m MMaterial) Table(newTableName string) *MMaterial {
- m.MMaterialDo.UseTable(newTableName)
- return m.updateTableName(newTableName)
- }
- func (m MMaterial) As(alias string) *MMaterial {
- m.MMaterialDo.DO = *(m.MMaterialDo.As(alias).(*gen.DO))
- return m.updateTableName(alias)
- }
- func (m *MMaterial) updateTableName(table string) *MMaterial {
- m.ALL = field.NewAsterisk(table)
- m.ID = field.NewInt64(table, "id")
- m.Name = field.NewString(table, "name")
- m.File = field.NewString(table, "file")
- m.Size = field.NewString(table, "size")
- m.FileSize = field.NewInt64(table, "file_size")
- m.Hash = field.NewString(table, "hash")
- m.Type = field.NewString(table, "type")
- m.UID = field.NewInt64(table, "uid")
- m.Status = field.NewInt64(table, "status")
- m.CreateAt = field.NewTime(table, "create_at")
- m.UpdateAt = field.NewTime(table, "update_at")
- m.fillFieldMap()
- return m
- }
- func (m *MMaterial) WithContext(ctx context.Context) IMaterialDo {
- return m.MMaterialDo.WithContext(ctx)
- }
- func (m MMaterial) TableName() string { return m.MMaterialDo.TableName() }
- func (m MMaterial) Alias() string { return m.MMaterialDo.Alias() }
- func (m *MMaterial) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
- _f, ok := m.fieldMap[fieldName]
- if !ok || _f == nil {
- return nil, false
- }
- _oe, ok := _f.(field.OrderExpr)
- return _oe, ok
- }
- func (m *MMaterial) fillFieldMap() {
- m.fieldMap = make(map[string]field.Expr, 11)
- m.fieldMap["id"] = m.ID
- m.fieldMap["name"] = m.Name
- m.fieldMap["file"] = m.File
- m.fieldMap["size"] = m.Size
- m.fieldMap["file_size"] = m.FileSize
- m.fieldMap["hash"] = m.Hash
- m.fieldMap["type"] = m.Type
- m.fieldMap["uid"] = m.UID
- m.fieldMap["status"] = m.Status
- m.fieldMap["create_at"] = m.CreateAt
- m.fieldMap["update_at"] = m.UpdateAt
- }
- func (m MMaterial) clone(db *gorm.DB) MMaterial {
- m.MMaterialDo.ReplaceConnPool(db.Statement.ConnPool)
- return m
- }
- func (m MMaterial) replaceDB(db *gorm.DB) MMaterial {
- m.MMaterialDo.ReplaceDB(db)
- return m
- }
- type MMaterialDo struct{ gen.DO }
- type IMaterialDo interface {
- gen.SubQuery
- Debug() IMaterialDo
- WithContext(ctx context.Context) IMaterialDo
- WithResult(fc func(tx gen.Dao)) gen.ResultInfo
- ReplaceDB(db *gorm.DB)
- ReadDB() IMaterialDo
- WriteDB() IMaterialDo
- As(alias string) gen.Dao
- Session(config *gorm.Session) IMaterialDo
- Columns(cols ...field.Expr) gen.Columns
- Clauses(conds ...clause.Expression) IMaterialDo
- Not(conds ...gen.Condition) IMaterialDo
- Or(conds ...gen.Condition) IMaterialDo
- Select(conds ...field.Expr) IMaterialDo
- Where(conds ...gen.Condition) IMaterialDo
- Order(conds ...field.Expr) IMaterialDo
- Distinct(cols ...field.Expr) IMaterialDo
- Omit(cols ...field.Expr) IMaterialDo
- Join(table schema.Tabler, on ...field.Expr) IMaterialDo
- LeftJoin(table schema.Tabler, on ...field.Expr) IMaterialDo
- RightJoin(table schema.Tabler, on ...field.Expr) IMaterialDo
- Group(cols ...field.Expr) IMaterialDo
- Having(conds ...gen.Condition) IMaterialDo
- Limit(limit int) IMaterialDo
- Offset(offset int) IMaterialDo
- Count() (count int64, err error)
- Scopes(funcs ...func(gen.Dao) gen.Dao) IMaterialDo
- Unscoped() IMaterialDo
- Create(values ...*entity.Material) error
- CreateInBatches(values []*entity.Material, batchSize int) error
- Save(values ...*entity.Material) error
- First() (*entity.Material, error)
- Take() (*entity.Material, error)
- Last() (*entity.Material, error)
- Find() ([]*entity.Material, error)
- FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*entity.Material, err error)
- FindInBatches(result *[]*entity.Material, batchSize int, fc func(tx gen.Dao, batch int) error) error
- Pluck(column field.Expr, dest interface{}) error
- Delete(...*entity.Material) (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) IMaterialDo
- Assign(attrs ...field.AssignExpr) IMaterialDo
- Joins(fields ...field.RelationField) IMaterialDo
- Preload(fields ...field.RelationField) IMaterialDo
- FirstOrInit() (*entity.Material, error)
- FirstOrCreate() (*entity.Material, error)
- FindByPage(offset int, limit int) (result []*entity.Material, 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) IMaterialDo
- UnderlyingDB() *gorm.DB
- schema.Tabler
- }
- func (m MMaterialDo) Debug() IMaterialDo {
- return m.withDO(m.DO.Debug())
- }
- func (m MMaterialDo) WithContext(ctx context.Context) IMaterialDo {
- return m.withDO(m.DO.WithContext(ctx))
- }
- func (m MMaterialDo) ReadDB() IMaterialDo {
- return m.Clauses(dbresolver.Read)
- }
- func (m MMaterialDo) WriteDB() IMaterialDo {
- return m.Clauses(dbresolver.Write)
- }
- func (m MMaterialDo) Session(config *gorm.Session) IMaterialDo {
- return m.withDO(m.DO.Session(config))
- }
- func (m MMaterialDo) Clauses(conds ...clause.Expression) IMaterialDo {
- return m.withDO(m.DO.Clauses(conds...))
- }
- func (m MMaterialDo) Returning(value interface{}, columns ...string) IMaterialDo {
- return m.withDO(m.DO.Returning(value, columns...))
- }
- func (m MMaterialDo) Not(conds ...gen.Condition) IMaterialDo {
- return m.withDO(m.DO.Not(conds...))
- }
- func (m MMaterialDo) Or(conds ...gen.Condition) IMaterialDo {
- return m.withDO(m.DO.Or(conds...))
- }
- func (m MMaterialDo) Select(conds ...field.Expr) IMaterialDo {
- return m.withDO(m.DO.Select(conds...))
- }
- func (m MMaterialDo) Where(conds ...gen.Condition) IMaterialDo {
- return m.withDO(m.DO.Where(conds...))
- }
- func (m MMaterialDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) IMaterialDo {
- return m.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
- }
- func (m MMaterialDo) Order(conds ...field.Expr) IMaterialDo {
- return m.withDO(m.DO.Order(conds...))
- }
- func (m MMaterialDo) Distinct(cols ...field.Expr) IMaterialDo {
- return m.withDO(m.DO.Distinct(cols...))
- }
- func (m MMaterialDo) Omit(cols ...field.Expr) IMaterialDo {
- return m.withDO(m.DO.Omit(cols...))
- }
- func (m MMaterialDo) Join(table schema.Tabler, on ...field.Expr) IMaterialDo {
- return m.withDO(m.DO.Join(table, on...))
- }
- func (m MMaterialDo) LeftJoin(table schema.Tabler, on ...field.Expr) IMaterialDo {
- return m.withDO(m.DO.LeftJoin(table, on...))
- }
- func (m MMaterialDo) RightJoin(table schema.Tabler, on ...field.Expr) IMaterialDo {
- return m.withDO(m.DO.RightJoin(table, on...))
- }
- func (m MMaterialDo) Group(cols ...field.Expr) IMaterialDo {
- return m.withDO(m.DO.Group(cols...))
- }
- func (m MMaterialDo) Having(conds ...gen.Condition) IMaterialDo {
- return m.withDO(m.DO.Having(conds...))
- }
- func (m MMaterialDo) Limit(limit int) IMaterialDo {
- return m.withDO(m.DO.Limit(limit))
- }
- func (m MMaterialDo) Offset(offset int) IMaterialDo {
- return m.withDO(m.DO.Offset(offset))
- }
- func (m MMaterialDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IMaterialDo {
- return m.withDO(m.DO.Scopes(funcs...))
- }
- func (m MMaterialDo) Unscoped() IMaterialDo {
- return m.withDO(m.DO.Unscoped())
- }
- func (m MMaterialDo) Create(values ...*entity.Material) error {
- if len(values) == 0 {
- return nil
- }
- return m.DO.Create(values)
- }
- func (m MMaterialDo) CreateInBatches(values []*entity.Material, batchSize int) error {
- return m.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 (m MMaterialDo) Save(values ...*entity.Material) error {
- if len(values) == 0 {
- return nil
- }
- return m.DO.Save(values)
- }
- func (m MMaterialDo) First() (*entity.Material, error) {
- if result, err := m.DO.First(); err != nil {
- return nil, err
- } else {
- return result.(*entity.Material), nil
- }
- }
- func (m MMaterialDo) Take() (*entity.Material, error) {
- if result, err := m.DO.Take(); err != nil {
- return nil, err
- } else {
- return result.(*entity.Material), nil
- }
- }
- func (m MMaterialDo) Last() (*entity.Material, error) {
- if result, err := m.DO.Last(); err != nil {
- return nil, err
- } else {
- return result.(*entity.Material), nil
- }
- }
- func (m MMaterialDo) Find() ([]*entity.Material, error) {
- result, err := m.DO.Find()
- return result.([]*entity.Material), err
- }
- func (m MMaterialDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*entity.Material, err error) {
- buf := make([]*entity.Material, 0, batchSize)
- err = m.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 (m MMaterialDo) FindInBatches(result *[]*entity.Material, batchSize int, fc func(tx gen.Dao, batch int) error) error {
- return m.DO.FindInBatches(result, batchSize, fc)
- }
- func (m MMaterialDo) Attrs(attrs ...field.AssignExpr) IMaterialDo {
- return m.withDO(m.DO.Attrs(attrs...))
- }
- func (m MMaterialDo) Assign(attrs ...field.AssignExpr) IMaterialDo {
- return m.withDO(m.DO.Assign(attrs...))
- }
- func (m MMaterialDo) Joins(fields ...field.RelationField) IMaterialDo {
- for _, _f := range fields {
- m = *m.withDO(m.DO.Joins(_f))
- }
- return &m
- }
- func (m MMaterialDo) Preload(fields ...field.RelationField) IMaterialDo {
- for _, _f := range fields {
- m = *m.withDO(m.DO.Preload(_f))
- }
- return &m
- }
- func (m MMaterialDo) FirstOrInit() (*entity.Material, error) {
- if result, err := m.DO.FirstOrInit(); err != nil {
- return nil, err
- } else {
- return result.(*entity.Material), nil
- }
- }
- func (m MMaterialDo) FirstOrCreate() (*entity.Material, error) {
- if result, err := m.DO.FirstOrCreate(); err != nil {
- return nil, err
- } else {
- return result.(*entity.Material), nil
- }
- }
- func (m MMaterialDo) FindByPage(offset int, limit int) (result []*entity.Material, count int64, err error) {
- result, err = m.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 = m.Offset(-1).Limit(-1).Count()
- return
- }
- func (m MMaterialDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
- count, err = m.Count()
- if err != nil {
- return
- }
- err = m.Offset(offset).Limit(limit).Scan(result)
- return
- }
- func (m MMaterialDo) Scan(result interface{}) (err error) {
- return m.DO.Scan(result)
- }
- func (m MMaterialDo) Delete(models ...*entity.Material) (result gen.ResultInfo, err error) {
- return m.DO.Delete(models)
- }
- func (m *MMaterialDo) withDO(do gen.Dao) *MMaterialDo {
- m.DO = *do.(*gen.DO)
- return m
- }
|