2023-11-17 16:22:22 +08:00
|
|
|
// 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 dbquery
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"gorm.io/gorm"
|
|
|
|
"gorm.io/gorm/clause"
|
|
|
|
"gorm.io/gorm/schema"
|
|
|
|
|
|
|
|
"gorm.io/gen"
|
|
|
|
"gorm.io/gen/field"
|
|
|
|
|
|
|
|
"gorm.io/plugin/dbresolver"
|
|
|
|
|
|
|
|
"joylink.club/bj-rtsts-server/db/model"
|
|
|
|
)
|
|
|
|
|
|
|
|
func newPublishedVersion(db *gorm.DB, opts ...gen.DOOption) publishedVersion {
|
|
|
|
_publishedVersion := publishedVersion{}
|
|
|
|
|
|
|
|
_publishedVersion.publishedVersionDo.UseDB(db, opts...)
|
|
|
|
_publishedVersion.publishedVersionDo.UseModel(&model.PublishedVersion{})
|
|
|
|
|
|
|
|
tableName := _publishedVersion.publishedVersionDo.TableName()
|
|
|
|
_publishedVersion.ALL = field.NewAsterisk(tableName)
|
|
|
|
_publishedVersion.ID = field.NewInt32(tableName, "id")
|
|
|
|
_publishedVersion.Proto = field.NewBytes(tableName, "proto")
|
|
|
|
_publishedVersion.UserID = field.NewInt32(tableName, "user_id")
|
|
|
|
_publishedVersion.PublishAt = field.NewTime(tableName, "publish_at")
|
|
|
|
_publishedVersion.Note = field.NewString(tableName, "note")
|
|
|
|
_publishedVersion.Version = field.NewInt32(tableName, "version")
|
|
|
|
_publishedVersion.Code = field.NewString(tableName, "code")
|
2023-11-22 17:05:38 +08:00
|
|
|
_publishedVersion.PublishID = field.NewInt32(tableName, "publish_id")
|
|
|
|
_publishedVersion.Type = field.NewInt32(tableName, "type")
|
|
|
|
_publishedVersion.Category = field.NewString(tableName, "category")
|
2023-11-17 16:22:22 +08:00
|
|
|
|
|
|
|
_publishedVersion.fillFieldMap()
|
|
|
|
|
|
|
|
return _publishedVersion
|
|
|
|
}
|
|
|
|
|
|
|
|
type publishedVersion struct {
|
|
|
|
publishedVersionDo
|
|
|
|
|
|
|
|
ALL field.Asterisk
|
|
|
|
ID field.Int32 // id
|
|
|
|
Proto field.Bytes // 图形界面数据
|
|
|
|
UserID field.Int32 // 发布用户id
|
|
|
|
PublishAt field.Time // 发布时间
|
|
|
|
Note field.String // 发布描述
|
|
|
|
Version field.Int32 // 版本
|
2023-11-22 17:05:38 +08:00
|
|
|
Code field.String // 发布草稿数据名称
|
|
|
|
PublishID field.Int32 // 对应发布图的ID
|
|
|
|
Type field.Int32
|
|
|
|
Category field.String
|
2023-11-17 16:22:22 +08:00
|
|
|
|
|
|
|
fieldMap map[string]field.Expr
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersion) Table(newTableName string) *publishedVersion {
|
|
|
|
p.publishedVersionDo.UseTable(newTableName)
|
|
|
|
return p.updateTableName(newTableName)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersion) As(alias string) *publishedVersion {
|
|
|
|
p.publishedVersionDo.DO = *(p.publishedVersionDo.As(alias).(*gen.DO))
|
|
|
|
return p.updateTableName(alias)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *publishedVersion) updateTableName(table string) *publishedVersion {
|
|
|
|
p.ALL = field.NewAsterisk(table)
|
|
|
|
p.ID = field.NewInt32(table, "id")
|
|
|
|
p.Proto = field.NewBytes(table, "proto")
|
|
|
|
p.UserID = field.NewInt32(table, "user_id")
|
|
|
|
p.PublishAt = field.NewTime(table, "publish_at")
|
|
|
|
p.Note = field.NewString(table, "note")
|
|
|
|
p.Version = field.NewInt32(table, "version")
|
|
|
|
p.Code = field.NewString(table, "code")
|
2023-11-22 17:05:38 +08:00
|
|
|
p.PublishID = field.NewInt32(table, "publish_id")
|
|
|
|
p.Type = field.NewInt32(table, "type")
|
|
|
|
p.Category = field.NewString(table, "category")
|
2023-11-17 16:22:22 +08:00
|
|
|
|
|
|
|
p.fillFieldMap()
|
|
|
|
|
|
|
|
return p
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *publishedVersion) 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 *publishedVersion) fillFieldMap() {
|
2023-11-22 17:05:38 +08:00
|
|
|
p.fieldMap = make(map[string]field.Expr, 10)
|
2023-11-17 16:22:22 +08:00
|
|
|
p.fieldMap["id"] = p.ID
|
|
|
|
p.fieldMap["proto"] = p.Proto
|
|
|
|
p.fieldMap["user_id"] = p.UserID
|
|
|
|
p.fieldMap["publish_at"] = p.PublishAt
|
|
|
|
p.fieldMap["note"] = p.Note
|
|
|
|
p.fieldMap["version"] = p.Version
|
|
|
|
p.fieldMap["code"] = p.Code
|
2023-11-22 17:05:38 +08:00
|
|
|
p.fieldMap["publish_id"] = p.PublishID
|
|
|
|
p.fieldMap["type"] = p.Type
|
|
|
|
p.fieldMap["category"] = p.Category
|
2023-11-17 16:22:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersion) clone(db *gorm.DB) publishedVersion {
|
|
|
|
p.publishedVersionDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
|
|
return p
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersion) replaceDB(db *gorm.DB) publishedVersion {
|
|
|
|
p.publishedVersionDo.ReplaceDB(db)
|
|
|
|
return p
|
|
|
|
}
|
|
|
|
|
|
|
|
type publishedVersionDo struct{ gen.DO }
|
|
|
|
|
|
|
|
type IPublishedVersionDo interface {
|
|
|
|
gen.SubQuery
|
|
|
|
Debug() IPublishedVersionDo
|
|
|
|
WithContext(ctx context.Context) IPublishedVersionDo
|
|
|
|
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
|
|
|
ReplaceDB(db *gorm.DB)
|
|
|
|
ReadDB() IPublishedVersionDo
|
|
|
|
WriteDB() IPublishedVersionDo
|
|
|
|
As(alias string) gen.Dao
|
|
|
|
Session(config *gorm.Session) IPublishedVersionDo
|
|
|
|
Columns(cols ...field.Expr) gen.Columns
|
|
|
|
Clauses(conds ...clause.Expression) IPublishedVersionDo
|
|
|
|
Not(conds ...gen.Condition) IPublishedVersionDo
|
|
|
|
Or(conds ...gen.Condition) IPublishedVersionDo
|
|
|
|
Select(conds ...field.Expr) IPublishedVersionDo
|
|
|
|
Where(conds ...gen.Condition) IPublishedVersionDo
|
|
|
|
Order(conds ...field.Expr) IPublishedVersionDo
|
|
|
|
Distinct(cols ...field.Expr) IPublishedVersionDo
|
|
|
|
Omit(cols ...field.Expr) IPublishedVersionDo
|
|
|
|
Join(table schema.Tabler, on ...field.Expr) IPublishedVersionDo
|
|
|
|
LeftJoin(table schema.Tabler, on ...field.Expr) IPublishedVersionDo
|
|
|
|
RightJoin(table schema.Tabler, on ...field.Expr) IPublishedVersionDo
|
|
|
|
Group(cols ...field.Expr) IPublishedVersionDo
|
|
|
|
Having(conds ...gen.Condition) IPublishedVersionDo
|
|
|
|
Limit(limit int) IPublishedVersionDo
|
|
|
|
Offset(offset int) IPublishedVersionDo
|
|
|
|
Count() (count int64, err error)
|
|
|
|
Scopes(funcs ...func(gen.Dao) gen.Dao) IPublishedVersionDo
|
|
|
|
Unscoped() IPublishedVersionDo
|
|
|
|
Create(values ...*model.PublishedVersion) error
|
|
|
|
CreateInBatches(values []*model.PublishedVersion, batchSize int) error
|
|
|
|
Save(values ...*model.PublishedVersion) error
|
|
|
|
First() (*model.PublishedVersion, error)
|
|
|
|
Take() (*model.PublishedVersion, error)
|
|
|
|
Last() (*model.PublishedVersion, error)
|
|
|
|
Find() ([]*model.PublishedVersion, error)
|
|
|
|
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.PublishedVersion, err error)
|
|
|
|
FindInBatches(result *[]*model.PublishedVersion, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
|
|
|
Pluck(column field.Expr, dest interface{}) error
|
|
|
|
Delete(...*model.PublishedVersion) (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) IPublishedVersionDo
|
|
|
|
Assign(attrs ...field.AssignExpr) IPublishedVersionDo
|
|
|
|
Joins(fields ...field.RelationField) IPublishedVersionDo
|
|
|
|
Preload(fields ...field.RelationField) IPublishedVersionDo
|
|
|
|
FirstOrInit() (*model.PublishedVersion, error)
|
|
|
|
FirstOrCreate() (*model.PublishedVersion, error)
|
|
|
|
FindByPage(offset int, limit int) (result []*model.PublishedVersion, 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) IPublishedVersionDo
|
|
|
|
UnderlyingDB() *gorm.DB
|
|
|
|
schema.Tabler
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Debug() IPublishedVersionDo {
|
|
|
|
return p.withDO(p.DO.Debug())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) WithContext(ctx context.Context) IPublishedVersionDo {
|
|
|
|
return p.withDO(p.DO.WithContext(ctx))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) ReadDB() IPublishedVersionDo {
|
|
|
|
return p.Clauses(dbresolver.Read)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) WriteDB() IPublishedVersionDo {
|
|
|
|
return p.Clauses(dbresolver.Write)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Session(config *gorm.Session) IPublishedVersionDo {
|
|
|
|
return p.withDO(p.DO.Session(config))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Clauses(conds ...clause.Expression) IPublishedVersionDo {
|
|
|
|
return p.withDO(p.DO.Clauses(conds...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Returning(value interface{}, columns ...string) IPublishedVersionDo {
|
|
|
|
return p.withDO(p.DO.Returning(value, columns...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Not(conds ...gen.Condition) IPublishedVersionDo {
|
|
|
|
return p.withDO(p.DO.Not(conds...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Or(conds ...gen.Condition) IPublishedVersionDo {
|
|
|
|
return p.withDO(p.DO.Or(conds...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Select(conds ...field.Expr) IPublishedVersionDo {
|
|
|
|
return p.withDO(p.DO.Select(conds...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Where(conds ...gen.Condition) IPublishedVersionDo {
|
|
|
|
return p.withDO(p.DO.Where(conds...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Order(conds ...field.Expr) IPublishedVersionDo {
|
|
|
|
return p.withDO(p.DO.Order(conds...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Distinct(cols ...field.Expr) IPublishedVersionDo {
|
|
|
|
return p.withDO(p.DO.Distinct(cols...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Omit(cols ...field.Expr) IPublishedVersionDo {
|
|
|
|
return p.withDO(p.DO.Omit(cols...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Join(table schema.Tabler, on ...field.Expr) IPublishedVersionDo {
|
|
|
|
return p.withDO(p.DO.Join(table, on...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) LeftJoin(table schema.Tabler, on ...field.Expr) IPublishedVersionDo {
|
|
|
|
return p.withDO(p.DO.LeftJoin(table, on...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) RightJoin(table schema.Tabler, on ...field.Expr) IPublishedVersionDo {
|
|
|
|
return p.withDO(p.DO.RightJoin(table, on...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Group(cols ...field.Expr) IPublishedVersionDo {
|
|
|
|
return p.withDO(p.DO.Group(cols...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Having(conds ...gen.Condition) IPublishedVersionDo {
|
|
|
|
return p.withDO(p.DO.Having(conds...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Limit(limit int) IPublishedVersionDo {
|
|
|
|
return p.withDO(p.DO.Limit(limit))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Offset(offset int) IPublishedVersionDo {
|
|
|
|
return p.withDO(p.DO.Offset(offset))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IPublishedVersionDo {
|
|
|
|
return p.withDO(p.DO.Scopes(funcs...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Unscoped() IPublishedVersionDo {
|
|
|
|
return p.withDO(p.DO.Unscoped())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Create(values ...*model.PublishedVersion) error {
|
|
|
|
if len(values) == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return p.DO.Create(values)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) CreateInBatches(values []*model.PublishedVersion, 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 publishedVersionDo) Save(values ...*model.PublishedVersion) error {
|
|
|
|
if len(values) == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return p.DO.Save(values)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) First() (*model.PublishedVersion, error) {
|
|
|
|
if result, err := p.DO.First(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
} else {
|
|
|
|
return result.(*model.PublishedVersion), nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Take() (*model.PublishedVersion, error) {
|
|
|
|
if result, err := p.DO.Take(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
} else {
|
|
|
|
return result.(*model.PublishedVersion), nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Last() (*model.PublishedVersion, error) {
|
|
|
|
if result, err := p.DO.Last(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
} else {
|
|
|
|
return result.(*model.PublishedVersion), nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Find() ([]*model.PublishedVersion, error) {
|
|
|
|
result, err := p.DO.Find()
|
|
|
|
return result.([]*model.PublishedVersion), err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.PublishedVersion, err error) {
|
|
|
|
buf := make([]*model.PublishedVersion, 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 publishedVersionDo) FindInBatches(result *[]*model.PublishedVersion, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
|
|
return p.DO.FindInBatches(result, batchSize, fc)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Attrs(attrs ...field.AssignExpr) IPublishedVersionDo {
|
|
|
|
return p.withDO(p.DO.Attrs(attrs...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Assign(attrs ...field.AssignExpr) IPublishedVersionDo {
|
|
|
|
return p.withDO(p.DO.Assign(attrs...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Joins(fields ...field.RelationField) IPublishedVersionDo {
|
|
|
|
for _, _f := range fields {
|
|
|
|
p = *p.withDO(p.DO.Joins(_f))
|
|
|
|
}
|
|
|
|
return &p
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Preload(fields ...field.RelationField) IPublishedVersionDo {
|
|
|
|
for _, _f := range fields {
|
|
|
|
p = *p.withDO(p.DO.Preload(_f))
|
|
|
|
}
|
|
|
|
return &p
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) FirstOrInit() (*model.PublishedVersion, error) {
|
|
|
|
if result, err := p.DO.FirstOrInit(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
} else {
|
|
|
|
return result.(*model.PublishedVersion), nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) FirstOrCreate() (*model.PublishedVersion, error) {
|
|
|
|
if result, err := p.DO.FirstOrCreate(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
} else {
|
|
|
|
return result.(*model.PublishedVersion), nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) FindByPage(offset int, limit int) (result []*model.PublishedVersion, 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 publishedVersionDo) 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 publishedVersionDo) Scan(result interface{}) (err error) {
|
|
|
|
return p.DO.Scan(result)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p publishedVersionDo) Delete(models ...*model.PublishedVersion) (result gen.ResultInfo, err error) {
|
|
|
|
return p.DO.Delete(models)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *publishedVersionDo) withDO(do gen.Dao) *publishedVersionDo {
|
|
|
|
p.DO = *do.(*gen.DO)
|
|
|
|
return p
|
|
|
|
}
|