You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sonic/dal/post_category.gen.go

346 lines
9.3 KiB
Go

2 years ago
// 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 dal
import (
"context"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/plugin/dbresolver"
"github.com/go-sonic/sonic/model/entity"
)
2 years ago
func newPostCategory(db *gorm.DB, opts ...gen.DOOption) postCategory {
2 years ago
_postCategory := postCategory{}
2 years ago
_postCategory.postCategoryDo.UseDB(db, opts...)
2 years ago
_postCategory.postCategoryDo.UseModel(&entity.PostCategory{})
tableName := _postCategory.postCategoryDo.TableName()
_postCategory.ALL = field.NewAsterisk(tableName)
_postCategory.ID = field.NewInt32(tableName, "id")
_postCategory.CreateTime = field.NewTime(tableName, "create_time")
_postCategory.UpdateTime = field.NewTime(tableName, "update_time")
_postCategory.CategoryID = field.NewInt32(tableName, "category_id")
_postCategory.PostID = field.NewInt32(tableName, "post_id")
_postCategory.fillFieldMap()
return _postCategory
}
type postCategory struct {
postCategoryDo postCategoryDo
ALL field.Asterisk
ID field.Int32
CreateTime field.Time
UpdateTime field.Time
CategoryID field.Int32
PostID field.Int32
fieldMap map[string]field.Expr
}
func (p postCategory) Table(newTableName string) *postCategory {
p.postCategoryDo.UseTable(newTableName)
return p.updateTableName(newTableName)
}
func (p postCategory) As(alias string) *postCategory {
p.postCategoryDo.DO = *(p.postCategoryDo.As(alias).(*gen.DO))
return p.updateTableName(alias)
}
func (p *postCategory) updateTableName(table string) *postCategory {
p.ALL = field.NewAsterisk(table)
p.ID = field.NewInt32(table, "id")
p.CreateTime = field.NewTime(table, "create_time")
p.UpdateTime = field.NewTime(table, "update_time")
p.CategoryID = field.NewInt32(table, "category_id")
p.PostID = field.NewInt32(table, "post_id")
p.fillFieldMap()
return p
}
func (p *postCategory) WithContext(ctx context.Context) *postCategoryDo {
return p.postCategoryDo.WithContext(ctx)
}
func (p postCategory) TableName() string { return p.postCategoryDo.TableName() }
func (p postCategory) Alias() string { return p.postCategoryDo.Alias() }
func (p *postCategory) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := p.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (p *postCategory) fillFieldMap() {
p.fieldMap = make(map[string]field.Expr, 5)
p.fieldMap["id"] = p.ID
p.fieldMap["create_time"] = p.CreateTime
p.fieldMap["update_time"] = p.UpdateTime
p.fieldMap["category_id"] = p.CategoryID
p.fieldMap["post_id"] = p.PostID
}
func (p postCategory) clone(db *gorm.DB) postCategory {
2 years ago
p.postCategoryDo.ReplaceConnPool(db.Statement.ConnPool)
return p
}
func (p postCategory) replaceDB(db *gorm.DB) postCategory {
2 years ago
p.postCategoryDo.ReplaceDB(db)
return p
}
type postCategoryDo struct{ gen.DO }
func (p postCategoryDo) Debug() *postCategoryDo {
return p.withDO(p.DO.Debug())
}
func (p postCategoryDo) WithContext(ctx context.Context) *postCategoryDo {
return p.withDO(p.DO.WithContext(ctx))
}
func (p postCategoryDo) ReadDB() *postCategoryDo {
return p.Clauses(dbresolver.Read)
}
func (p postCategoryDo) WriteDB() *postCategoryDo {
return p.Clauses(dbresolver.Write)
}
2 years ago
func (p postCategoryDo) Session(config *gorm.Session) *postCategoryDo {
return p.withDO(p.DO.Session(config))
}
2 years ago
func (p postCategoryDo) Clauses(conds ...clause.Expression) *postCategoryDo {
return p.withDO(p.DO.Clauses(conds...))
}
func (p postCategoryDo) Returning(value interface{}, columns ...string) *postCategoryDo {
return p.withDO(p.DO.Returning(value, columns...))
}
func (p postCategoryDo) Not(conds ...gen.Condition) *postCategoryDo {
return p.withDO(p.DO.Not(conds...))
}
func (p postCategoryDo) Or(conds ...gen.Condition) *postCategoryDo {
return p.withDO(p.DO.Or(conds...))
}
func (p postCategoryDo) Select(conds ...field.Expr) *postCategoryDo {
return p.withDO(p.DO.Select(conds...))
}
func (p postCategoryDo) Where(conds ...gen.Condition) *postCategoryDo {
return p.withDO(p.DO.Where(conds...))
}
func (p postCategoryDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *postCategoryDo {
return p.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
}
func (p postCategoryDo) Order(conds ...field.Expr) *postCategoryDo {
return p.withDO(p.DO.Order(conds...))
}
func (p postCategoryDo) Distinct(cols ...field.Expr) *postCategoryDo {
return p.withDO(p.DO.Distinct(cols...))
}
func (p postCategoryDo) Omit(cols ...field.Expr) *postCategoryDo {
return p.withDO(p.DO.Omit(cols...))
}
func (p postCategoryDo) Join(table schema.Tabler, on ...field.Expr) *postCategoryDo {
return p.withDO(p.DO.Join(table, on...))
}
func (p postCategoryDo) LeftJoin(table schema.Tabler, on ...field.Expr) *postCategoryDo {
return p.withDO(p.DO.LeftJoin(table, on...))
}
func (p postCategoryDo) RightJoin(table schema.Tabler, on ...field.Expr) *postCategoryDo {
return p.withDO(p.DO.RightJoin(table, on...))
}
func (p postCategoryDo) Group(cols ...field.Expr) *postCategoryDo {
return p.withDO(p.DO.Group(cols...))
}
func (p postCategoryDo) Having(conds ...gen.Condition) *postCategoryDo {
return p.withDO(p.DO.Having(conds...))
}
func (p postCategoryDo) Limit(limit int) *postCategoryDo {
return p.withDO(p.DO.Limit(limit))
}
func (p postCategoryDo) Offset(offset int) *postCategoryDo {
return p.withDO(p.DO.Offset(offset))
}
func (p postCategoryDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *postCategoryDo {
return p.withDO(p.DO.Scopes(funcs...))
}
func (p postCategoryDo) Unscoped() *postCategoryDo {
return p.withDO(p.DO.Unscoped())
}
func (p postCategoryDo) Create(values ...*entity.PostCategory) error {
if len(values) == 0 {
return nil
}
return p.DO.Create(values)
}
func (p postCategoryDo) CreateInBatches(values []*entity.PostCategory, batchSize int) error {
return p.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 (p postCategoryDo) Save(values ...*entity.PostCategory) error {
if len(values) == 0 {
return nil
}
return p.DO.Save(values)
}
func (p postCategoryDo) First() (*entity.PostCategory, error) {
if result, err := p.DO.First(); err != nil {
return nil, err
} else {
return result.(*entity.PostCategory), nil
}
}
func (p postCategoryDo) Take() (*entity.PostCategory, error) {
if result, err := p.DO.Take(); err != nil {
return nil, err
} else {
return result.(*entity.PostCategory), nil
}
}
func (p postCategoryDo) Last() (*entity.PostCategory, error) {
if result, err := p.DO.Last(); err != nil {
return nil, err
} else {
return result.(*entity.PostCategory), nil
}
}
func (p postCategoryDo) Find() ([]*entity.PostCategory, error) {
result, err := p.DO.Find()
return result.([]*entity.PostCategory), err
}
func (p postCategoryDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*entity.PostCategory, err error) {
buf := make([]*entity.PostCategory, 0, batchSize)
err = p.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 (p postCategoryDo) FindInBatches(result *[]*entity.PostCategory, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return p.DO.FindInBatches(result, batchSize, fc)
}
func (p postCategoryDo) Attrs(attrs ...field.AssignExpr) *postCategoryDo {
return p.withDO(p.DO.Attrs(attrs...))
}
func (p postCategoryDo) Assign(attrs ...field.AssignExpr) *postCategoryDo {
return p.withDO(p.DO.Assign(attrs...))
}
func (p postCategoryDo) Joins(fields ...field.RelationField) *postCategoryDo {
for _, _f := range fields {
p = *p.withDO(p.DO.Joins(_f))
}
return &p
}
func (p postCategoryDo) Preload(fields ...field.RelationField) *postCategoryDo {
for _, _f := range fields {
p = *p.withDO(p.DO.Preload(_f))
}
return &p
}
func (p postCategoryDo) FirstOrInit() (*entity.PostCategory, error) {
if result, err := p.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*entity.PostCategory), nil
}
}
func (p postCategoryDo) FirstOrCreate() (*entity.PostCategory, error) {
if result, err := p.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*entity.PostCategory), nil
}
}
func (p postCategoryDo) FindByPage(offset int, limit int) (result []*entity.PostCategory, count int64, err error) {
result, err = p.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 = p.Offset(-1).Limit(-1).Count()
return
}
func (p postCategoryDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = p.Count()
if err != nil {
return
}
err = p.Offset(offset).Limit(limit).Scan(result)
return
}
func (p postCategoryDo) Scan(result interface{}) (err error) {
return p.DO.Scan(result)
}
func (p postCategoryDo) Delete(models ...*entity.PostCategory) (result gen.ResultInfo, err error) {
return p.DO.Delete(models)
}
func (p *postCategoryDo) withDO(do gen.Dao) *postCategoryDo {
p.DO = *do.(*gen.DO)
return p
}