389 lines
12 KiB
Go
389 lines
12 KiB
Go
// 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 newProjectPublishLink(db *gorm.DB, opts ...gen.DOOption) projectPublishLink {
|
|
_projectPublishLink := projectPublishLink{}
|
|
|
|
_projectPublishLink.projectPublishLinkDo.UseDB(db, opts...)
|
|
_projectPublishLink.projectPublishLinkDo.UseModel(&model.ProjectPublishLink{})
|
|
|
|
tableName := _projectPublishLink.projectPublishLinkDo.TableName()
|
|
_projectPublishLink.ALL = field.NewAsterisk(tableName)
|
|
_projectPublishLink.ID = field.NewInt32(tableName, "id")
|
|
_projectPublishLink.Pid = field.NewInt32(tableName, "pid")
|
|
_projectPublishLink.Mid = field.NewInt32(tableName, "mid")
|
|
|
|
_projectPublishLink.fillFieldMap()
|
|
|
|
return _projectPublishLink
|
|
}
|
|
|
|
type projectPublishLink struct {
|
|
projectPublishLinkDo
|
|
|
|
ALL field.Asterisk
|
|
ID field.Int32 // 主键
|
|
Pid field.Int32 // 项目主键
|
|
Mid field.Int32 // 发布的地图ID
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (p projectPublishLink) Table(newTableName string) *projectPublishLink {
|
|
p.projectPublishLinkDo.UseTable(newTableName)
|
|
return p.updateTableName(newTableName)
|
|
}
|
|
|
|
func (p projectPublishLink) As(alias string) *projectPublishLink {
|
|
p.projectPublishLinkDo.DO = *(p.projectPublishLinkDo.As(alias).(*gen.DO))
|
|
return p.updateTableName(alias)
|
|
}
|
|
|
|
func (p *projectPublishLink) updateTableName(table string) *projectPublishLink {
|
|
p.ALL = field.NewAsterisk(table)
|
|
p.ID = field.NewInt32(table, "id")
|
|
p.Pid = field.NewInt32(table, "pid")
|
|
p.Mid = field.NewInt32(table, "mid")
|
|
|
|
p.fillFieldMap()
|
|
|
|
return p
|
|
}
|
|
|
|
func (p *projectPublishLink) 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 *projectPublishLink) fillFieldMap() {
|
|
p.fieldMap = make(map[string]field.Expr, 3)
|
|
p.fieldMap["id"] = p.ID
|
|
p.fieldMap["pid"] = p.Pid
|
|
p.fieldMap["mid"] = p.Mid
|
|
}
|
|
|
|
func (p projectPublishLink) clone(db *gorm.DB) projectPublishLink {
|
|
p.projectPublishLinkDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return p
|
|
}
|
|
|
|
func (p projectPublishLink) replaceDB(db *gorm.DB) projectPublishLink {
|
|
p.projectPublishLinkDo.ReplaceDB(db)
|
|
return p
|
|
}
|
|
|
|
type projectPublishLinkDo struct{ gen.DO }
|
|
|
|
type IProjectPublishLinkDo interface {
|
|
gen.SubQuery
|
|
Debug() IProjectPublishLinkDo
|
|
WithContext(ctx context.Context) IProjectPublishLinkDo
|
|
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
|
ReplaceDB(db *gorm.DB)
|
|
ReadDB() IProjectPublishLinkDo
|
|
WriteDB() IProjectPublishLinkDo
|
|
As(alias string) gen.Dao
|
|
Session(config *gorm.Session) IProjectPublishLinkDo
|
|
Columns(cols ...field.Expr) gen.Columns
|
|
Clauses(conds ...clause.Expression) IProjectPublishLinkDo
|
|
Not(conds ...gen.Condition) IProjectPublishLinkDo
|
|
Or(conds ...gen.Condition) IProjectPublishLinkDo
|
|
Select(conds ...field.Expr) IProjectPublishLinkDo
|
|
Where(conds ...gen.Condition) IProjectPublishLinkDo
|
|
Order(conds ...field.Expr) IProjectPublishLinkDo
|
|
Distinct(cols ...field.Expr) IProjectPublishLinkDo
|
|
Omit(cols ...field.Expr) IProjectPublishLinkDo
|
|
Join(table schema.Tabler, on ...field.Expr) IProjectPublishLinkDo
|
|
LeftJoin(table schema.Tabler, on ...field.Expr) IProjectPublishLinkDo
|
|
RightJoin(table schema.Tabler, on ...field.Expr) IProjectPublishLinkDo
|
|
Group(cols ...field.Expr) IProjectPublishLinkDo
|
|
Having(conds ...gen.Condition) IProjectPublishLinkDo
|
|
Limit(limit int) IProjectPublishLinkDo
|
|
Offset(offset int) IProjectPublishLinkDo
|
|
Count() (count int64, err error)
|
|
Scopes(funcs ...func(gen.Dao) gen.Dao) IProjectPublishLinkDo
|
|
Unscoped() IProjectPublishLinkDo
|
|
Create(values ...*model.ProjectPublishLink) error
|
|
CreateInBatches(values []*model.ProjectPublishLink, batchSize int) error
|
|
Save(values ...*model.ProjectPublishLink) error
|
|
First() (*model.ProjectPublishLink, error)
|
|
Take() (*model.ProjectPublishLink, error)
|
|
Last() (*model.ProjectPublishLink, error)
|
|
Find() ([]*model.ProjectPublishLink, error)
|
|
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ProjectPublishLink, err error)
|
|
FindInBatches(result *[]*model.ProjectPublishLink, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
|
Pluck(column field.Expr, dest interface{}) error
|
|
Delete(...*model.ProjectPublishLink) (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) IProjectPublishLinkDo
|
|
Assign(attrs ...field.AssignExpr) IProjectPublishLinkDo
|
|
Joins(fields ...field.RelationField) IProjectPublishLinkDo
|
|
Preload(fields ...field.RelationField) IProjectPublishLinkDo
|
|
FirstOrInit() (*model.ProjectPublishLink, error)
|
|
FirstOrCreate() (*model.ProjectPublishLink, error)
|
|
FindByPage(offset int, limit int) (result []*model.ProjectPublishLink, 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) IProjectPublishLinkDo
|
|
UnderlyingDB() *gorm.DB
|
|
schema.Tabler
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Debug() IProjectPublishLinkDo {
|
|
return p.withDO(p.DO.Debug())
|
|
}
|
|
|
|
func (p projectPublishLinkDo) WithContext(ctx context.Context) IProjectPublishLinkDo {
|
|
return p.withDO(p.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (p projectPublishLinkDo) ReadDB() IProjectPublishLinkDo {
|
|
return p.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (p projectPublishLinkDo) WriteDB() IProjectPublishLinkDo {
|
|
return p.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Session(config *gorm.Session) IProjectPublishLinkDo {
|
|
return p.withDO(p.DO.Session(config))
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Clauses(conds ...clause.Expression) IProjectPublishLinkDo {
|
|
return p.withDO(p.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Returning(value interface{}, columns ...string) IProjectPublishLinkDo {
|
|
return p.withDO(p.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Not(conds ...gen.Condition) IProjectPublishLinkDo {
|
|
return p.withDO(p.DO.Not(conds...))
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Or(conds ...gen.Condition) IProjectPublishLinkDo {
|
|
return p.withDO(p.DO.Or(conds...))
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Select(conds ...field.Expr) IProjectPublishLinkDo {
|
|
return p.withDO(p.DO.Select(conds...))
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Where(conds ...gen.Condition) IProjectPublishLinkDo {
|
|
return p.withDO(p.DO.Where(conds...))
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Order(conds ...field.Expr) IProjectPublishLinkDo {
|
|
return p.withDO(p.DO.Order(conds...))
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Distinct(cols ...field.Expr) IProjectPublishLinkDo {
|
|
return p.withDO(p.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Omit(cols ...field.Expr) IProjectPublishLinkDo {
|
|
return p.withDO(p.DO.Omit(cols...))
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Join(table schema.Tabler, on ...field.Expr) IProjectPublishLinkDo {
|
|
return p.withDO(p.DO.Join(table, on...))
|
|
}
|
|
|
|
func (p projectPublishLinkDo) LeftJoin(table schema.Tabler, on ...field.Expr) IProjectPublishLinkDo {
|
|
return p.withDO(p.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (p projectPublishLinkDo) RightJoin(table schema.Tabler, on ...field.Expr) IProjectPublishLinkDo {
|
|
return p.withDO(p.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Group(cols ...field.Expr) IProjectPublishLinkDo {
|
|
return p.withDO(p.DO.Group(cols...))
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Having(conds ...gen.Condition) IProjectPublishLinkDo {
|
|
return p.withDO(p.DO.Having(conds...))
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Limit(limit int) IProjectPublishLinkDo {
|
|
return p.withDO(p.DO.Limit(limit))
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Offset(offset int) IProjectPublishLinkDo {
|
|
return p.withDO(p.DO.Offset(offset))
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IProjectPublishLinkDo {
|
|
return p.withDO(p.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Unscoped() IProjectPublishLinkDo {
|
|
return p.withDO(p.DO.Unscoped())
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Create(values ...*model.ProjectPublishLink) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return p.DO.Create(values)
|
|
}
|
|
|
|
func (p projectPublishLinkDo) CreateInBatches(values []*model.ProjectPublishLink, 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 projectPublishLinkDo) Save(values ...*model.ProjectPublishLink) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return p.DO.Save(values)
|
|
}
|
|
|
|
func (p projectPublishLinkDo) First() (*model.ProjectPublishLink, error) {
|
|
if result, err := p.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ProjectPublishLink), nil
|
|
}
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Take() (*model.ProjectPublishLink, error) {
|
|
if result, err := p.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ProjectPublishLink), nil
|
|
}
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Last() (*model.ProjectPublishLink, error) {
|
|
if result, err := p.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ProjectPublishLink), nil
|
|
}
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Find() ([]*model.ProjectPublishLink, error) {
|
|
result, err := p.DO.Find()
|
|
return result.([]*model.ProjectPublishLink), err
|
|
}
|
|
|
|
func (p projectPublishLinkDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ProjectPublishLink, err error) {
|
|
buf := make([]*model.ProjectPublishLink, 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 projectPublishLinkDo) FindInBatches(result *[]*model.ProjectPublishLink, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return p.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Attrs(attrs ...field.AssignExpr) IProjectPublishLinkDo {
|
|
return p.withDO(p.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Assign(attrs ...field.AssignExpr) IProjectPublishLinkDo {
|
|
return p.withDO(p.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Joins(fields ...field.RelationField) IProjectPublishLinkDo {
|
|
for _, _f := range fields {
|
|
p = *p.withDO(p.DO.Joins(_f))
|
|
}
|
|
return &p
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Preload(fields ...field.RelationField) IProjectPublishLinkDo {
|
|
for _, _f := range fields {
|
|
p = *p.withDO(p.DO.Preload(_f))
|
|
}
|
|
return &p
|
|
}
|
|
|
|
func (p projectPublishLinkDo) FirstOrInit() (*model.ProjectPublishLink, error) {
|
|
if result, err := p.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ProjectPublishLink), nil
|
|
}
|
|
}
|
|
|
|
func (p projectPublishLinkDo) FirstOrCreate() (*model.ProjectPublishLink, error) {
|
|
if result, err := p.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ProjectPublishLink), nil
|
|
}
|
|
}
|
|
|
|
func (p projectPublishLinkDo) FindByPage(offset int, limit int) (result []*model.ProjectPublishLink, 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 projectPublishLinkDo) 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 projectPublishLinkDo) Scan(result interface{}) (err error) {
|
|
return p.DO.Scan(result)
|
|
}
|
|
|
|
func (p projectPublishLinkDo) Delete(models ...*model.ProjectPublishLink) (result gen.ResultInfo, err error) {
|
|
return p.DO.Delete(models)
|
|
}
|
|
|
|
func (p *projectPublishLinkDo) withDO(do gen.Dao) *projectPublishLinkDo {
|
|
p.DO = *do.(*gen.DO)
|
|
return p
|
|
}
|