Files

448 lines
14 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 query
import (
"context"
"database/sql"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"github.com/rulego/gflow-engine/model"
)
func newWfProcess(db *gorm.DB, opts ...gen.DOOption) wfProcess {
_wfProcess := wfProcess{}
_wfProcess.wfProcessDo.UseDB(db, opts...)
_wfProcess.wfProcessDo.UseModel(&model.WfProcess{})
tableName := _wfProcess.wfProcessDo.TableName()
_wfProcess.ALL = field.NewAsterisk(tableName)
_wfProcess.ID = field.NewString(tableName, "id")
_wfProcess.ProcessKey = field.NewString(tableName, "process_key")
_wfProcess.Name = field.NewString(tableName, "name")
_wfProcess.Version = field.NewInt32(tableName, "version")
_wfProcess.Category = field.NewString(tableName, "category")
_wfProcess.Description = field.NewString(tableName, "description")
_wfProcess.DefinitionJSON = field.NewString(tableName, "definition_json")
_wfProcess.Status = field.NewString(tableName, "status")
_wfProcess.PublishTime = field.NewTime(tableName, "publish_time")
_wfProcess.Icon = field.NewString(tableName, "icon")
_wfProcess.ProcessType = field.NewString(tableName, "process_type")
_wfProcess.TenantID = field.NewString(tableName, "tenant_id")
_wfProcess.CreatedBy = field.NewString(tableName, "created_by")
_wfProcess.CreatedAt = field.NewTime(tableName, "created_at")
_wfProcess.UpdatedBy = field.NewString(tableName, "updated_by")
_wfProcess.UpdatedAt = field.NewTime(tableName, "updated_at")
_wfProcess.Ext = field.NewString(tableName, "ext")
_wfProcess.fillFieldMap()
return _wfProcess
}
type wfProcess struct {
wfProcessDo
ALL field.Asterisk
ID field.String // UUID 主键
ProcessKey field.String // 流程键(业务唯一标识)
Name field.String // 流程名称
Version field.Int32 // 版本号(从 1 开始递增)
Category field.String // 分类(可用于权限/报表筛选)
Description field.String // 流程描述
DefinitionJSON field.String // 流程定义DSL
Status field.String // 状态:active=生效,retired=已停用
PublishTime field.Time // 版本发布时间
Icon field.String // 流程图标
ProcessType field.String // 流程定义类型:main 主流程、sub 子流程
TenantID field.String // 租户 ID
CreatedBy field.String // 创建人
CreatedAt field.Time // 创建时间
UpdatedBy field.String // 更新人
UpdatedAt field.Time // 更新时间
Ext field.String // 结构化扩展字段
fieldMap map[string]field.Expr
}
func (w wfProcess) Table(newTableName string) *wfProcess {
w.wfProcessDo.UseTable(newTableName)
return w.updateTableName(newTableName)
}
func (w wfProcess) As(alias string) *wfProcess {
w.wfProcessDo.DO = *(w.wfProcessDo.As(alias).(*gen.DO))
return w.updateTableName(alias)
}
func (w *wfProcess) updateTableName(table string) *wfProcess {
w.ALL = field.NewAsterisk(table)
w.ID = field.NewString(table, "id")
w.ProcessKey = field.NewString(table, "process_key")
w.Name = field.NewString(table, "name")
w.Version = field.NewInt32(table, "version")
w.Category = field.NewString(table, "category")
w.Description = field.NewString(table, "description")
w.DefinitionJSON = field.NewString(table, "definition_json")
w.Status = field.NewString(table, "status")
w.PublishTime = field.NewTime(table, "publish_time")
w.Icon = field.NewString(table, "icon")
w.ProcessType = field.NewString(table, "process_type")
w.TenantID = field.NewString(table, "tenant_id")
w.CreatedBy = field.NewString(table, "created_by")
w.CreatedAt = field.NewTime(table, "created_at")
w.UpdatedBy = field.NewString(table, "updated_by")
w.UpdatedAt = field.NewTime(table, "updated_at")
w.Ext = field.NewString(table, "ext")
w.fillFieldMap()
return w
}
func (w *wfProcess) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := w.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (w *wfProcess) fillFieldMap() {
w.fieldMap = make(map[string]field.Expr, 17)
w.fieldMap["id"] = w.ID
w.fieldMap["process_key"] = w.ProcessKey
w.fieldMap["name"] = w.Name
w.fieldMap["version"] = w.Version
w.fieldMap["category"] = w.Category
w.fieldMap["description"] = w.Description
w.fieldMap["definition_json"] = w.DefinitionJSON
w.fieldMap["status"] = w.Status
w.fieldMap["publish_time"] = w.PublishTime
w.fieldMap["icon"] = w.Icon
w.fieldMap["process_type"] = w.ProcessType
w.fieldMap["tenant_id"] = w.TenantID
w.fieldMap["created_by"] = w.CreatedBy
w.fieldMap["created_at"] = w.CreatedAt
w.fieldMap["updated_by"] = w.UpdatedBy
w.fieldMap["updated_at"] = w.UpdatedAt
w.fieldMap["ext"] = w.Ext
}
func (w wfProcess) clone(db *gorm.DB) wfProcess {
w.wfProcessDo.ReplaceConnPool(db.Statement.ConnPool)
return w
}
func (w wfProcess) replaceDB(db *gorm.DB) wfProcess {
w.wfProcessDo.ReplaceDB(db)
return w
}
type wfProcessDo struct{ gen.DO }
type IWfProcessDo interface {
gen.SubQuery
Debug() IWfProcessDo
WithContext(ctx context.Context) IWfProcessDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IWfProcessDo
WriteDB() IWfProcessDo
As(alias string) gen.Dao
Session(config *gorm.Session) IWfProcessDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IWfProcessDo
Not(conds ...gen.Condition) IWfProcessDo
Or(conds ...gen.Condition) IWfProcessDo
Select(conds ...field.Expr) IWfProcessDo
Where(conds ...gen.Condition) IWfProcessDo
Order(conds ...field.Expr) IWfProcessDo
Distinct(cols ...field.Expr) IWfProcessDo
Omit(cols ...field.Expr) IWfProcessDo
Join(table schema.Tabler, on ...field.Expr) IWfProcessDo
LeftJoin(table schema.Tabler, on ...field.Expr) IWfProcessDo
RightJoin(table schema.Tabler, on ...field.Expr) IWfProcessDo
Group(cols ...field.Expr) IWfProcessDo
Having(conds ...gen.Condition) IWfProcessDo
Limit(limit int) IWfProcessDo
Offset(offset int) IWfProcessDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IWfProcessDo
Unscoped() IWfProcessDo
Create(values ...*model.WfProcess) error
CreateInBatches(values []*model.WfProcess, batchSize int) error
Save(values ...*model.WfProcess) error
First() (*model.WfProcess, error)
Take() (*model.WfProcess, error)
Last() (*model.WfProcess, error)
Find() ([]*model.WfProcess, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.WfProcess, err error)
FindInBatches(result *[]*model.WfProcess, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.WfProcess) (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) IWfProcessDo
Assign(attrs ...field.AssignExpr) IWfProcessDo
Joins(fields ...field.RelationField) IWfProcessDo
Preload(fields ...field.RelationField) IWfProcessDo
FirstOrInit() (*model.WfProcess, error)
FirstOrCreate() (*model.WfProcess, error)
FindByPage(offset int, limit int) (result []*model.WfProcess, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Rows() (*sql.Rows, error)
Row() *sql.Row
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IWfProcessDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (w wfProcessDo) Debug() IWfProcessDo {
return w.withDO(w.DO.Debug())
}
func (w wfProcessDo) WithContext(ctx context.Context) IWfProcessDo {
return w.withDO(w.DO.WithContext(ctx))
}
func (w wfProcessDo) ReadDB() IWfProcessDo {
return w.Clauses(dbresolver.Read)
}
func (w wfProcessDo) WriteDB() IWfProcessDo {
return w.Clauses(dbresolver.Write)
}
func (w wfProcessDo) Session(config *gorm.Session) IWfProcessDo {
return w.withDO(w.DO.Session(config))
}
func (w wfProcessDo) Clauses(conds ...clause.Expression) IWfProcessDo {
return w.withDO(w.DO.Clauses(conds...))
}
func (w wfProcessDo) Returning(value interface{}, columns ...string) IWfProcessDo {
return w.withDO(w.DO.Returning(value, columns...))
}
func (w wfProcessDo) Not(conds ...gen.Condition) IWfProcessDo {
return w.withDO(w.DO.Not(conds...))
}
func (w wfProcessDo) Or(conds ...gen.Condition) IWfProcessDo {
return w.withDO(w.DO.Or(conds...))
}
func (w wfProcessDo) Select(conds ...field.Expr) IWfProcessDo {
return w.withDO(w.DO.Select(conds...))
}
func (w wfProcessDo) Where(conds ...gen.Condition) IWfProcessDo {
return w.withDO(w.DO.Where(conds...))
}
func (w wfProcessDo) Order(conds ...field.Expr) IWfProcessDo {
return w.withDO(w.DO.Order(conds...))
}
func (w wfProcessDo) Distinct(cols ...field.Expr) IWfProcessDo {
return w.withDO(w.DO.Distinct(cols...))
}
func (w wfProcessDo) Omit(cols ...field.Expr) IWfProcessDo {
return w.withDO(w.DO.Omit(cols...))
}
func (w wfProcessDo) Join(table schema.Tabler, on ...field.Expr) IWfProcessDo {
return w.withDO(w.DO.Join(table, on...))
}
func (w wfProcessDo) LeftJoin(table schema.Tabler, on ...field.Expr) IWfProcessDo {
return w.withDO(w.DO.LeftJoin(table, on...))
}
func (w wfProcessDo) RightJoin(table schema.Tabler, on ...field.Expr) IWfProcessDo {
return w.withDO(w.DO.RightJoin(table, on...))
}
func (w wfProcessDo) Group(cols ...field.Expr) IWfProcessDo {
return w.withDO(w.DO.Group(cols...))
}
func (w wfProcessDo) Having(conds ...gen.Condition) IWfProcessDo {
return w.withDO(w.DO.Having(conds...))
}
func (w wfProcessDo) Limit(limit int) IWfProcessDo {
return w.withDO(w.DO.Limit(limit))
}
func (w wfProcessDo) Offset(offset int) IWfProcessDo {
return w.withDO(w.DO.Offset(offset))
}
func (w wfProcessDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IWfProcessDo {
return w.withDO(w.DO.Scopes(funcs...))
}
func (w wfProcessDo) Unscoped() IWfProcessDo {
return w.withDO(w.DO.Unscoped())
}
func (w wfProcessDo) Create(values ...*model.WfProcess) error {
if len(values) == 0 {
return nil
}
return w.DO.Create(values)
}
func (w wfProcessDo) CreateInBatches(values []*model.WfProcess, batchSize int) error {
return w.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 (w wfProcessDo) Save(values ...*model.WfProcess) error {
if len(values) == 0 {
return nil
}
return w.DO.Save(values)
}
func (w wfProcessDo) First() (*model.WfProcess, error) {
if result, err := w.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.WfProcess), nil
}
}
func (w wfProcessDo) Take() (*model.WfProcess, error) {
if result, err := w.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.WfProcess), nil
}
}
func (w wfProcessDo) Last() (*model.WfProcess, error) {
if result, err := w.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.WfProcess), nil
}
}
func (w wfProcessDo) Find() ([]*model.WfProcess, error) {
result, err := w.DO.Find()
return result.([]*model.WfProcess), err
}
func (w wfProcessDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.WfProcess, err error) {
buf := make([]*model.WfProcess, 0, batchSize)
err = w.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 (w wfProcessDo) FindInBatches(result *[]*model.WfProcess, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return w.DO.FindInBatches(result, batchSize, fc)
}
func (w wfProcessDo) Attrs(attrs ...field.AssignExpr) IWfProcessDo {
return w.withDO(w.DO.Attrs(attrs...))
}
func (w wfProcessDo) Assign(attrs ...field.AssignExpr) IWfProcessDo {
return w.withDO(w.DO.Assign(attrs...))
}
func (w wfProcessDo) Joins(fields ...field.RelationField) IWfProcessDo {
for _, _f := range fields {
w = *w.withDO(w.DO.Joins(_f))
}
return &w
}
func (w wfProcessDo) Preload(fields ...field.RelationField) IWfProcessDo {
for _, _f := range fields {
w = *w.withDO(w.DO.Preload(_f))
}
return &w
}
func (w wfProcessDo) FirstOrInit() (*model.WfProcess, error) {
if result, err := w.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.WfProcess), nil
}
}
func (w wfProcessDo) FirstOrCreate() (*model.WfProcess, error) {
if result, err := w.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.WfProcess), nil
}
}
func (w wfProcessDo) FindByPage(offset int, limit int) (result []*model.WfProcess, count int64, err error) {
result, err = w.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 = w.Offset(-1).Limit(-1).Count()
return
}
func (w wfProcessDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = w.Count()
if err != nil {
return
}
err = w.Offset(offset).Limit(limit).Scan(result)
return
}
func (w wfProcessDo) Scan(result interface{}) (err error) {
return w.DO.Scan(result)
}
func (w wfProcessDo) Delete(models ...*model.WfProcess) (result gen.ResultInfo, err error) {
return w.DO.Delete(models)
}
func (w *wfProcessDo) withDO(do gen.Dao) *wfProcessDo {
w.DO = *do.(*gen.DO)
return w
}