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 newUserPoster(db *gorm.DB, opts ...gen.DOOption) MUserPoster {
- _MUserPoster := MUserPoster{}
- _MUserPoster.MUserPosterDo.UseDB(db, opts...)
- _MUserPoster.MUserPosterDo.UseModel(&entity.UserPoster{})
- tableName := _MUserPoster.MUserPosterDo.TableName()
- _MUserPoster.ALL = field.NewAsterisk(tableName)
- _MUserPoster.PosterID = field.NewInt64(tableName, "poster_id")
- _MUserPoster.PosterName = field.NewString(tableName, "poster_name")
- _MUserPoster.UUID = field.NewString(tableName, "uuid")
- _MUserPoster.UID = field.NewInt64(tableName, "uid")
- _MUserPoster.PosterKeywords = field.NewString(tableName, "poster_keywords")
- _MUserPoster.PosterJSON = field.NewString(tableName, "poster_json")
- _MUserPoster.Preview = field.NewString(tableName, "preview")
- _MUserPoster.Visits = field.NewInt64(tableName, "visits")
- _MUserPoster.Status = field.NewInt64(tableName, "status")
- _MUserPoster.CreateAt = field.NewTime(tableName, "create_at")
- _MUserPoster.UpdateAt = field.NewTime(tableName, "update_at")
- _MUserPoster.fillFieldMap()
- return _MUserPoster
- }
- type MUserPoster struct {
- MUserPosterDo MUserPosterDo
- ALL field.Asterisk
- PosterID field.Int64 // 海报ID
- PosterName field.String // 海报名称
- UUID field.String // 海报唯一标识
- UID field.Int64 // 用户ID
- PosterKeywords field.String // 海报关键字
- PosterJSON field.String // 海报数据
- Preview field.String // 海报预览地址
- Visits field.Int64 // 访问次数
- Status field.Int64
- CreateAt field.Time // 创建时间
- UpdateAt field.Time // 更新时间
- fieldMap map[string]field.Expr
- }
- func (u MUserPoster) Table(newTableName string) *MUserPoster {
- u.MUserPosterDo.UseTable(newTableName)
- return u.updateTableName(newTableName)
- }
- func (u MUserPoster) As(alias string) *MUserPoster {
- u.MUserPosterDo.DO = *(u.MUserPosterDo.As(alias).(*gen.DO))
- return u.updateTableName(alias)
- }
- func (u *MUserPoster) updateTableName(table string) *MUserPoster {
- u.ALL = field.NewAsterisk(table)
- u.PosterID = field.NewInt64(table, "poster_id")
- u.PosterName = field.NewString(table, "poster_name")
- u.UUID = field.NewString(table, "uuid")
- u.UID = field.NewInt64(table, "uid")
- u.PosterKeywords = field.NewString(table, "poster_keywords")
- u.PosterJSON = field.NewString(table, "poster_json")
- u.Preview = field.NewString(table, "preview")
- u.Visits = field.NewInt64(table, "visits")
- u.Status = field.NewInt64(table, "status")
- u.CreateAt = field.NewTime(table, "create_at")
- u.UpdateAt = field.NewTime(table, "update_at")
- u.fillFieldMap()
- return u
- }
- func (u *MUserPoster) WithContext(ctx context.Context) IUserPosterDo {
- return u.MUserPosterDo.WithContext(ctx)
- }
- func (u MUserPoster) TableName() string { return u.MUserPosterDo.TableName() }
- func (u MUserPoster) Alias() string { return u.MUserPosterDo.Alias() }
- func (u *MUserPoster) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
- _f, ok := u.fieldMap[fieldName]
- if !ok || _f == nil {
- return nil, false
- }
- _oe, ok := _f.(field.OrderExpr)
- return _oe, ok
- }
- func (u *MUserPoster) fillFieldMap() {
- u.fieldMap = make(map[string]field.Expr, 11)
- u.fieldMap["poster_id"] = u.PosterID
- u.fieldMap["poster_name"] = u.PosterName
- u.fieldMap["uuid"] = u.UUID
- u.fieldMap["uid"] = u.UID
- u.fieldMap["poster_keywords"] = u.PosterKeywords
- u.fieldMap["poster_json"] = u.PosterJSON
- u.fieldMap["preview"] = u.Preview
- u.fieldMap["visits"] = u.Visits
- u.fieldMap["status"] = u.Status
- u.fieldMap["create_at"] = u.CreateAt
- u.fieldMap["update_at"] = u.UpdateAt
- }
- func (u MUserPoster) clone(db *gorm.DB) MUserPoster {
- u.MUserPosterDo.ReplaceConnPool(db.Statement.ConnPool)
- return u
- }
- func (u MUserPoster) replaceDB(db *gorm.DB) MUserPoster {
- u.MUserPosterDo.ReplaceDB(db)
- return u
- }
- type MUserPosterDo struct{ gen.DO }
- type IUserPosterDo interface {
- gen.SubQuery
- Debug() IUserPosterDo
- WithContext(ctx context.Context) IUserPosterDo
- WithResult(fc func(tx gen.Dao)) gen.ResultInfo
- ReplaceDB(db *gorm.DB)
- ReadDB() IUserPosterDo
- WriteDB() IUserPosterDo
- As(alias string) gen.Dao
- Session(config *gorm.Session) IUserPosterDo
- Columns(cols ...field.Expr) gen.Columns
- Clauses(conds ...clause.Expression) IUserPosterDo
- Not(conds ...gen.Condition) IUserPosterDo
- Or(conds ...gen.Condition) IUserPosterDo
- Select(conds ...field.Expr) IUserPosterDo
- Where(conds ...gen.Condition) IUserPosterDo
- Order(conds ...field.Expr) IUserPosterDo
- Distinct(cols ...field.Expr) IUserPosterDo
- Omit(cols ...field.Expr) IUserPosterDo
- Join(table schema.Tabler, on ...field.Expr) IUserPosterDo
- LeftJoin(table schema.Tabler, on ...field.Expr) IUserPosterDo
- RightJoin(table schema.Tabler, on ...field.Expr) IUserPosterDo
- Group(cols ...field.Expr) IUserPosterDo
- Having(conds ...gen.Condition) IUserPosterDo
- Limit(limit int) IUserPosterDo
- Offset(offset int) IUserPosterDo
- Count() (count int64, err error)
- Scopes(funcs ...func(gen.Dao) gen.Dao) IUserPosterDo
- Unscoped() IUserPosterDo
- Create(values ...*entity.UserPoster) error
- CreateInBatches(values []*entity.UserPoster, batchSize int) error
- Save(values ...*entity.UserPoster) error
- First() (*entity.UserPoster, error)
- Take() (*entity.UserPoster, error)
- Last() (*entity.UserPoster, error)
- Find() ([]*entity.UserPoster, error)
- FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*entity.UserPoster, err error)
- FindInBatches(result *[]*entity.UserPoster, batchSize int, fc func(tx gen.Dao, batch int) error) error
- Pluck(column field.Expr, dest interface{}) error
- Delete(...*entity.UserPoster) (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) IUserPosterDo
- Assign(attrs ...field.AssignExpr) IUserPosterDo
- Joins(fields ...field.RelationField) IUserPosterDo
- Preload(fields ...field.RelationField) IUserPosterDo
- FirstOrInit() (*entity.UserPoster, error)
- FirstOrCreate() (*entity.UserPoster, error)
- FindByPage(offset int, limit int) (result []*entity.UserPoster, 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) IUserPosterDo
- UnderlyingDB() *gorm.DB
- schema.Tabler
- }
- func (u MUserPosterDo) Debug() IUserPosterDo {
- return u.withDO(u.DO.Debug())
- }
- func (u MUserPosterDo) WithContext(ctx context.Context) IUserPosterDo {
- return u.withDO(u.DO.WithContext(ctx))
- }
- func (u MUserPosterDo) ReadDB() IUserPosterDo {
- return u.Clauses(dbresolver.Read)
- }
- func (u MUserPosterDo) WriteDB() IUserPosterDo {
- return u.Clauses(dbresolver.Write)
- }
- func (u MUserPosterDo) Session(config *gorm.Session) IUserPosterDo {
- return u.withDO(u.DO.Session(config))
- }
- func (u MUserPosterDo) Clauses(conds ...clause.Expression) IUserPosterDo {
- return u.withDO(u.DO.Clauses(conds...))
- }
- func (u MUserPosterDo) Returning(value interface{}, columns ...string) IUserPosterDo {
- return u.withDO(u.DO.Returning(value, columns...))
- }
- func (u MUserPosterDo) Not(conds ...gen.Condition) IUserPosterDo {
- return u.withDO(u.DO.Not(conds...))
- }
- func (u MUserPosterDo) Or(conds ...gen.Condition) IUserPosterDo {
- return u.withDO(u.DO.Or(conds...))
- }
- func (u MUserPosterDo) Select(conds ...field.Expr) IUserPosterDo {
- return u.withDO(u.DO.Select(conds...))
- }
- func (u MUserPosterDo) Where(conds ...gen.Condition) IUserPosterDo {
- return u.withDO(u.DO.Where(conds...))
- }
- func (u MUserPosterDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) IUserPosterDo {
- return u.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
- }
- func (u MUserPosterDo) Order(conds ...field.Expr) IUserPosterDo {
- return u.withDO(u.DO.Order(conds...))
- }
- func (u MUserPosterDo) Distinct(cols ...field.Expr) IUserPosterDo {
- return u.withDO(u.DO.Distinct(cols...))
- }
- func (u MUserPosterDo) Omit(cols ...field.Expr) IUserPosterDo {
- return u.withDO(u.DO.Omit(cols...))
- }
- func (u MUserPosterDo) Join(table schema.Tabler, on ...field.Expr) IUserPosterDo {
- return u.withDO(u.DO.Join(table, on...))
- }
- func (u MUserPosterDo) LeftJoin(table schema.Tabler, on ...field.Expr) IUserPosterDo {
- return u.withDO(u.DO.LeftJoin(table, on...))
- }
- func (u MUserPosterDo) RightJoin(table schema.Tabler, on ...field.Expr) IUserPosterDo {
- return u.withDO(u.DO.RightJoin(table, on...))
- }
- func (u MUserPosterDo) Group(cols ...field.Expr) IUserPosterDo {
- return u.withDO(u.DO.Group(cols...))
- }
- func (u MUserPosterDo) Having(conds ...gen.Condition) IUserPosterDo {
- return u.withDO(u.DO.Having(conds...))
- }
- func (u MUserPosterDo) Limit(limit int) IUserPosterDo {
- return u.withDO(u.DO.Limit(limit))
- }
- func (u MUserPosterDo) Offset(offset int) IUserPosterDo {
- return u.withDO(u.DO.Offset(offset))
- }
- func (u MUserPosterDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IUserPosterDo {
- return u.withDO(u.DO.Scopes(funcs...))
- }
- func (u MUserPosterDo) Unscoped() IUserPosterDo {
- return u.withDO(u.DO.Unscoped())
- }
- func (u MUserPosterDo) Create(values ...*entity.UserPoster) error {
- if len(values) == 0 {
- return nil
- }
- return u.DO.Create(values)
- }
- func (u MUserPosterDo) CreateInBatches(values []*entity.UserPoster, batchSize int) error {
- return u.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 (u MUserPosterDo) Save(values ...*entity.UserPoster) error {
- if len(values) == 0 {
- return nil
- }
- return u.DO.Save(values)
- }
- func (u MUserPosterDo) First() (*entity.UserPoster, error) {
- if result, err := u.DO.First(); err != nil {
- return nil, err
- } else {
- return result.(*entity.UserPoster), nil
- }
- }
- func (u MUserPosterDo) Take() (*entity.UserPoster, error) {
- if result, err := u.DO.Take(); err != nil {
- return nil, err
- } else {
- return result.(*entity.UserPoster), nil
- }
- }
- func (u MUserPosterDo) Last() (*entity.UserPoster, error) {
- if result, err := u.DO.Last(); err != nil {
- return nil, err
- } else {
- return result.(*entity.UserPoster), nil
- }
- }
- func (u MUserPosterDo) Find() ([]*entity.UserPoster, error) {
- result, err := u.DO.Find()
- return result.([]*entity.UserPoster), err
- }
- func (u MUserPosterDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*entity.UserPoster, err error) {
- buf := make([]*entity.UserPoster, 0, batchSize)
- err = u.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 (u MUserPosterDo) FindInBatches(result *[]*entity.UserPoster, batchSize int, fc func(tx gen.Dao, batch int) error) error {
- return u.DO.FindInBatches(result, batchSize, fc)
- }
- func (u MUserPosterDo) Attrs(attrs ...field.AssignExpr) IUserPosterDo {
- return u.withDO(u.DO.Attrs(attrs...))
- }
- func (u MUserPosterDo) Assign(attrs ...field.AssignExpr) IUserPosterDo {
- return u.withDO(u.DO.Assign(attrs...))
- }
- func (u MUserPosterDo) Joins(fields ...field.RelationField) IUserPosterDo {
- for _, _f := range fields {
- u = *u.withDO(u.DO.Joins(_f))
- }
- return &u
- }
- func (u MUserPosterDo) Preload(fields ...field.RelationField) IUserPosterDo {
- for _, _f := range fields {
- u = *u.withDO(u.DO.Preload(_f))
- }
- return &u
- }
- func (u MUserPosterDo) FirstOrInit() (*entity.UserPoster, error) {
- if result, err := u.DO.FirstOrInit(); err != nil {
- return nil, err
- } else {
- return result.(*entity.UserPoster), nil
- }
- }
- func (u MUserPosterDo) FirstOrCreate() (*entity.UserPoster, error) {
- if result, err := u.DO.FirstOrCreate(); err != nil {
- return nil, err
- } else {
- return result.(*entity.UserPoster), nil
- }
- }
- func (u MUserPosterDo) FindByPage(offset int, limit int) (result []*entity.UserPoster, count int64, err error) {
- result, err = u.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 = u.Offset(-1).Limit(-1).Count()
- return
- }
- func (u MUserPosterDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
- count, err = u.Count()
- if err != nil {
- return
- }
- err = u.Offset(offset).Limit(limit).Scan(result)
- return
- }
- func (u MUserPosterDo) Scan(result interface{}) (err error) {
- return u.DO.Scan(result)
- }
- func (u MUserPosterDo) Delete(models ...*entity.UserPoster) (result gen.ResultInfo, err error) {
- return u.DO.Delete(models)
- }
- func (u *MUserPosterDo) withDO(do gen.Dao) *MUserPosterDo {
- u.DO = *do.(*gen.DO)
- return u
- }
|