mirror of
https://github.com/rulego/gflow-engine.git
synced 2026-12-05 16:02:03 +00:00
452 lines
15 KiB
Go
452 lines
15 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 newWfHiInstance(db *gorm.DB, opts ...gen.DOOption) wfHiInstance {
|
|
_wfHiInstance := wfHiInstance{}
|
|
|
|
_wfHiInstance.wfHiInstanceDo.UseDB(db, opts...)
|
|
_wfHiInstance.wfHiInstanceDo.UseModel(&model.WfHiInstance{})
|
|
|
|
tableName := _wfHiInstance.wfHiInstanceDo.TableName()
|
|
_wfHiInstance.ALL = field.NewAsterisk(tableName)
|
|
_wfHiInstance.ID = field.NewString(tableName, "id")
|
|
_wfHiInstance.ProcessID = field.NewString(tableName, "process_id")
|
|
_wfHiInstance.BusinessKey = field.NewString(tableName, "business_key")
|
|
_wfHiInstance.Name = field.NewString(tableName, "name")
|
|
_wfHiInstance.StartUserID = field.NewString(tableName, "start_user_id")
|
|
_wfHiInstance.Status = field.NewString(tableName, "status")
|
|
_wfHiInstance.Variables = field.NewString(tableName, "variables")
|
|
_wfHiInstance.CurrentActivity = field.NewString(tableName, "current_activity")
|
|
_wfHiInstance.Priority = field.NewInt32(tableName, "priority")
|
|
_wfHiInstance.ParentID = field.NewString(tableName, "parent_id")
|
|
_wfHiInstance.TenantID = field.NewString(tableName, "tenant_id")
|
|
_wfHiInstance.CreatedBy = field.NewString(tableName, "created_by")
|
|
_wfHiInstance.CreatedAt = field.NewTime(tableName, "created_at")
|
|
_wfHiInstance.UpdatedBy = field.NewString(tableName, "updated_by")
|
|
_wfHiInstance.UpdatedAt = field.NewTime(tableName, "updated_at")
|
|
_wfHiInstance.EndReason = field.NewString(tableName, "end_reason")
|
|
_wfHiInstance.Duration = field.NewInt64(tableName, "duration")
|
|
_wfHiInstance.EndedAt = field.NewTime(tableName, "ended_at")
|
|
|
|
_wfHiInstance.fillFieldMap()
|
|
|
|
return _wfHiInstance
|
|
}
|
|
|
|
type wfHiInstance struct {
|
|
wfHiInstanceDo
|
|
|
|
ALL field.Asterisk
|
|
ID field.String // 主键UUID
|
|
ProcessID field.String // 流程定义ID
|
|
BusinessKey field.String // 业务键
|
|
Name field.String // 实例名称
|
|
StartUserID field.String // 流程发起人用户ID;系统触发时为空字符串
|
|
Status field.String // 生命周期状态:draft / active / completed / suspended / terminated/cancelled/failed
|
|
Variables field.String // 流程变量
|
|
CurrentActivity field.String // 最后停留节点
|
|
Priority field.Int32 // 优先级
|
|
ParentID field.String // 父流程实例ID
|
|
TenantID field.String // 租户ID
|
|
CreatedBy field.String // 发起人
|
|
CreatedAt field.Time // 实例创建时间
|
|
UpdatedBy field.String // 最后更新人
|
|
UpdatedAt field.Time // 最后更新时间
|
|
EndReason field.String // 完成/终止原因(包含错误信息)
|
|
Duration field.Int64 // 运行时长(毫秒)
|
|
EndedAt field.Time // 流程结束时间
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (w wfHiInstance) Table(newTableName string) *wfHiInstance {
|
|
w.wfHiInstanceDo.UseTable(newTableName)
|
|
return w.updateTableName(newTableName)
|
|
}
|
|
|
|
func (w wfHiInstance) As(alias string) *wfHiInstance {
|
|
w.wfHiInstanceDo.DO = *(w.wfHiInstanceDo.As(alias).(*gen.DO))
|
|
return w.updateTableName(alias)
|
|
}
|
|
|
|
func (w *wfHiInstance) updateTableName(table string) *wfHiInstance {
|
|
w.ALL = field.NewAsterisk(table)
|
|
w.ID = field.NewString(table, "id")
|
|
w.ProcessID = field.NewString(table, "process_id")
|
|
w.BusinessKey = field.NewString(table, "business_key")
|
|
w.Name = field.NewString(table, "name")
|
|
w.StartUserID = field.NewString(table, "start_user_id")
|
|
w.Status = field.NewString(table, "status")
|
|
w.Variables = field.NewString(table, "variables")
|
|
w.CurrentActivity = field.NewString(table, "current_activity")
|
|
w.Priority = field.NewInt32(table, "priority")
|
|
w.ParentID = field.NewString(table, "parent_id")
|
|
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.EndReason = field.NewString(table, "end_reason")
|
|
w.Duration = field.NewInt64(table, "duration")
|
|
w.EndedAt = field.NewTime(table, "ended_at")
|
|
|
|
w.fillFieldMap()
|
|
|
|
return w
|
|
}
|
|
|
|
func (w *wfHiInstance) 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 *wfHiInstance) fillFieldMap() {
|
|
w.fieldMap = make(map[string]field.Expr, 18)
|
|
w.fieldMap["id"] = w.ID
|
|
w.fieldMap["process_id"] = w.ProcessID
|
|
w.fieldMap["business_key"] = w.BusinessKey
|
|
w.fieldMap["name"] = w.Name
|
|
w.fieldMap["start_user_id"] = w.StartUserID
|
|
w.fieldMap["status"] = w.Status
|
|
w.fieldMap["variables"] = w.Variables
|
|
w.fieldMap["current_activity"] = w.CurrentActivity
|
|
w.fieldMap["priority"] = w.Priority
|
|
w.fieldMap["parent_id"] = w.ParentID
|
|
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["end_reason"] = w.EndReason
|
|
w.fieldMap["duration"] = w.Duration
|
|
w.fieldMap["ended_at"] = w.EndedAt
|
|
}
|
|
|
|
func (w wfHiInstance) clone(db *gorm.DB) wfHiInstance {
|
|
w.wfHiInstanceDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return w
|
|
}
|
|
|
|
func (w wfHiInstance) replaceDB(db *gorm.DB) wfHiInstance {
|
|
w.wfHiInstanceDo.ReplaceDB(db)
|
|
return w
|
|
}
|
|
|
|
type wfHiInstanceDo struct{ gen.DO }
|
|
|
|
type IWfHiInstanceDo interface {
|
|
gen.SubQuery
|
|
Debug() IWfHiInstanceDo
|
|
WithContext(ctx context.Context) IWfHiInstanceDo
|
|
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
|
ReplaceDB(db *gorm.DB)
|
|
ReadDB() IWfHiInstanceDo
|
|
WriteDB() IWfHiInstanceDo
|
|
As(alias string) gen.Dao
|
|
Session(config *gorm.Session) IWfHiInstanceDo
|
|
Columns(cols ...field.Expr) gen.Columns
|
|
Clauses(conds ...clause.Expression) IWfHiInstanceDo
|
|
Not(conds ...gen.Condition) IWfHiInstanceDo
|
|
Or(conds ...gen.Condition) IWfHiInstanceDo
|
|
Select(conds ...field.Expr) IWfHiInstanceDo
|
|
Where(conds ...gen.Condition) IWfHiInstanceDo
|
|
Order(conds ...field.Expr) IWfHiInstanceDo
|
|
Distinct(cols ...field.Expr) IWfHiInstanceDo
|
|
Omit(cols ...field.Expr) IWfHiInstanceDo
|
|
Join(table schema.Tabler, on ...field.Expr) IWfHiInstanceDo
|
|
LeftJoin(table schema.Tabler, on ...field.Expr) IWfHiInstanceDo
|
|
RightJoin(table schema.Tabler, on ...field.Expr) IWfHiInstanceDo
|
|
Group(cols ...field.Expr) IWfHiInstanceDo
|
|
Having(conds ...gen.Condition) IWfHiInstanceDo
|
|
Limit(limit int) IWfHiInstanceDo
|
|
Offset(offset int) IWfHiInstanceDo
|
|
Count() (count int64, err error)
|
|
Scopes(funcs ...func(gen.Dao) gen.Dao) IWfHiInstanceDo
|
|
Unscoped() IWfHiInstanceDo
|
|
Create(values ...*model.WfHiInstance) error
|
|
CreateInBatches(values []*model.WfHiInstance, batchSize int) error
|
|
Save(values ...*model.WfHiInstance) error
|
|
First() (*model.WfHiInstance, error)
|
|
Take() (*model.WfHiInstance, error)
|
|
Last() (*model.WfHiInstance, error)
|
|
Find() ([]*model.WfHiInstance, error)
|
|
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.WfHiInstance, err error)
|
|
FindInBatches(result *[]*model.WfHiInstance, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
|
Pluck(column field.Expr, dest interface{}) error
|
|
Delete(...*model.WfHiInstance) (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) IWfHiInstanceDo
|
|
Assign(attrs ...field.AssignExpr) IWfHiInstanceDo
|
|
Joins(fields ...field.RelationField) IWfHiInstanceDo
|
|
Preload(fields ...field.RelationField) IWfHiInstanceDo
|
|
FirstOrInit() (*model.WfHiInstance, error)
|
|
FirstOrCreate() (*model.WfHiInstance, error)
|
|
FindByPage(offset int, limit int) (result []*model.WfHiInstance, 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) IWfHiInstanceDo
|
|
UnderlyingDB() *gorm.DB
|
|
schema.Tabler
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Debug() IWfHiInstanceDo {
|
|
return w.withDO(w.DO.Debug())
|
|
}
|
|
|
|
func (w wfHiInstanceDo) WithContext(ctx context.Context) IWfHiInstanceDo {
|
|
return w.withDO(w.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (w wfHiInstanceDo) ReadDB() IWfHiInstanceDo {
|
|
return w.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (w wfHiInstanceDo) WriteDB() IWfHiInstanceDo {
|
|
return w.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Session(config *gorm.Session) IWfHiInstanceDo {
|
|
return w.withDO(w.DO.Session(config))
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Clauses(conds ...clause.Expression) IWfHiInstanceDo {
|
|
return w.withDO(w.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Returning(value interface{}, columns ...string) IWfHiInstanceDo {
|
|
return w.withDO(w.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Not(conds ...gen.Condition) IWfHiInstanceDo {
|
|
return w.withDO(w.DO.Not(conds...))
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Or(conds ...gen.Condition) IWfHiInstanceDo {
|
|
return w.withDO(w.DO.Or(conds...))
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Select(conds ...field.Expr) IWfHiInstanceDo {
|
|
return w.withDO(w.DO.Select(conds...))
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Where(conds ...gen.Condition) IWfHiInstanceDo {
|
|
return w.withDO(w.DO.Where(conds...))
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Order(conds ...field.Expr) IWfHiInstanceDo {
|
|
return w.withDO(w.DO.Order(conds...))
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Distinct(cols ...field.Expr) IWfHiInstanceDo {
|
|
return w.withDO(w.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Omit(cols ...field.Expr) IWfHiInstanceDo {
|
|
return w.withDO(w.DO.Omit(cols...))
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Join(table schema.Tabler, on ...field.Expr) IWfHiInstanceDo {
|
|
return w.withDO(w.DO.Join(table, on...))
|
|
}
|
|
|
|
func (w wfHiInstanceDo) LeftJoin(table schema.Tabler, on ...field.Expr) IWfHiInstanceDo {
|
|
return w.withDO(w.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (w wfHiInstanceDo) RightJoin(table schema.Tabler, on ...field.Expr) IWfHiInstanceDo {
|
|
return w.withDO(w.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Group(cols ...field.Expr) IWfHiInstanceDo {
|
|
return w.withDO(w.DO.Group(cols...))
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Having(conds ...gen.Condition) IWfHiInstanceDo {
|
|
return w.withDO(w.DO.Having(conds...))
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Limit(limit int) IWfHiInstanceDo {
|
|
return w.withDO(w.DO.Limit(limit))
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Offset(offset int) IWfHiInstanceDo {
|
|
return w.withDO(w.DO.Offset(offset))
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IWfHiInstanceDo {
|
|
return w.withDO(w.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Unscoped() IWfHiInstanceDo {
|
|
return w.withDO(w.DO.Unscoped())
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Create(values ...*model.WfHiInstance) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return w.DO.Create(values)
|
|
}
|
|
|
|
func (w wfHiInstanceDo) CreateInBatches(values []*model.WfHiInstance, 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 wfHiInstanceDo) Save(values ...*model.WfHiInstance) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return w.DO.Save(values)
|
|
}
|
|
|
|
func (w wfHiInstanceDo) First() (*model.WfHiInstance, error) {
|
|
if result, err := w.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.WfHiInstance), nil
|
|
}
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Take() (*model.WfHiInstance, error) {
|
|
if result, err := w.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.WfHiInstance), nil
|
|
}
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Last() (*model.WfHiInstance, error) {
|
|
if result, err := w.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.WfHiInstance), nil
|
|
}
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Find() ([]*model.WfHiInstance, error) {
|
|
result, err := w.DO.Find()
|
|
return result.([]*model.WfHiInstance), err
|
|
}
|
|
|
|
func (w wfHiInstanceDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.WfHiInstance, err error) {
|
|
buf := make([]*model.WfHiInstance, 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 wfHiInstanceDo) FindInBatches(result *[]*model.WfHiInstance, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return w.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Attrs(attrs ...field.AssignExpr) IWfHiInstanceDo {
|
|
return w.withDO(w.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Assign(attrs ...field.AssignExpr) IWfHiInstanceDo {
|
|
return w.withDO(w.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Joins(fields ...field.RelationField) IWfHiInstanceDo {
|
|
for _, _f := range fields {
|
|
w = *w.withDO(w.DO.Joins(_f))
|
|
}
|
|
return &w
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Preload(fields ...field.RelationField) IWfHiInstanceDo {
|
|
for _, _f := range fields {
|
|
w = *w.withDO(w.DO.Preload(_f))
|
|
}
|
|
return &w
|
|
}
|
|
|
|
func (w wfHiInstanceDo) FirstOrInit() (*model.WfHiInstance, error) {
|
|
if result, err := w.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.WfHiInstance), nil
|
|
}
|
|
}
|
|
|
|
func (w wfHiInstanceDo) FirstOrCreate() (*model.WfHiInstance, error) {
|
|
if result, err := w.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.WfHiInstance), nil
|
|
}
|
|
}
|
|
|
|
func (w wfHiInstanceDo) FindByPage(offset int, limit int) (result []*model.WfHiInstance, 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 wfHiInstanceDo) 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 wfHiInstanceDo) Scan(result interface{}) (err error) {
|
|
return w.DO.Scan(result)
|
|
}
|
|
|
|
func (w wfHiInstanceDo) Delete(models ...*model.WfHiInstance) (result gen.ResultInfo, err error) {
|
|
return w.DO.Delete(models)
|
|
}
|
|
|
|
func (w *wfHiInstanceDo) withDO(do gen.Dao) *wfHiInstanceDo {
|
|
w.DO = *do.(*gen.DO)
|
|
return w
|
|
}
|