// 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" "gorm.io/gorm" "gorm.io/gorm/clause" "gorm.io/gorm/schema" "gorm.io/gen" "gorm.io/gen/field" "gorm.io/plugin/dbresolver" "github.com/coze-dev/coze-studio/backend/bizpkg/config/modelmgr/internal/model" ) func newModelInstance(db *gorm.DB, opts ...gen.DOOption) modelInstance { _modelInstance := modelInstance{} _modelInstance.modelInstanceDo.UseDB(db, opts...) _modelInstance.modelInstanceDo.UseModel(&model.ModelInstance{}) tableName := _modelInstance.modelInstanceDo.TableName() _modelInstance.ALL = field.NewAsterisk(tableName) _modelInstance.ID = field.NewInt64(tableName, "id") _modelInstance.Type = field.NewInt32(tableName, "type") _modelInstance.Provider = field.NewField(tableName, "provider") _modelInstance.DisplayInfo = field.NewField(tableName, "display_info") _modelInstance.Connection = field.NewField(tableName, "connection") _modelInstance.Capability = field.NewField(tableName, "capability") _modelInstance.Parameters = field.NewField(tableName, "parameters") _modelInstance.Extra = field.NewString(tableName, "extra") _modelInstance.CreatedAt = field.NewInt64(tableName, "created_at") _modelInstance.UpdatedAt = field.NewInt64(tableName, "updated_at") _modelInstance.DeletedAt = field.NewField(tableName, "deleted_at") _modelInstance.fillFieldMap() return _modelInstance } // modelInstance Model Instance Management Table type modelInstance struct { modelInstanceDo ALL field.Asterisk ID field.Int64 // id Type field.Int32 // Model Type 0-LLM 1-TextEmbedding 2-Rerank Provider field.Field // Provider Information DisplayInfo field.Field // Display Information Connection field.Field // Connection Information Capability field.Field // Model Capability Parameters field.Field // Model Parameters Extra field.String // Extra Information CreatedAt field.Int64 // Create Time in Milliseconds UpdatedAt field.Int64 // Update Time in Milliseconds DeletedAt field.Field // Delete Time fieldMap map[string]field.Expr } func (m modelInstance) Table(newTableName string) *modelInstance { m.modelInstanceDo.UseTable(newTableName) return m.updateTableName(newTableName) } func (m modelInstance) As(alias string) *modelInstance { m.modelInstanceDo.DO = *(m.modelInstanceDo.As(alias).(*gen.DO)) return m.updateTableName(alias) } func (m *modelInstance) updateTableName(table string) *modelInstance { m.ALL = field.NewAsterisk(table) m.ID = field.NewInt64(table, "id") m.Type = field.NewInt32(table, "type") m.Provider = field.NewField(table, "provider") m.DisplayInfo = field.NewField(table, "display_info") m.Connection = field.NewField(table, "connection") m.Capability = field.NewField(table, "capability") m.Parameters = field.NewField(table, "parameters") m.Extra = field.NewString(table, "extra") m.CreatedAt = field.NewInt64(table, "created_at") m.UpdatedAt = field.NewInt64(table, "updated_at") m.DeletedAt = field.NewField(table, "deleted_at") m.fillFieldMap() return m } func (m *modelInstance) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := m.fieldMap[fieldName] if !ok || _f == nil { return nil, false } _oe, ok := _f.(field.OrderExpr) return _oe, ok } func (m *modelInstance) fillFieldMap() { m.fieldMap = make(map[string]field.Expr, 11) m.fieldMap["id"] = m.ID m.fieldMap["type"] = m.Type m.fieldMap["provider"] = m.Provider m.fieldMap["display_info"] = m.DisplayInfo m.fieldMap["connection"] = m.Connection m.fieldMap["capability"] = m.Capability m.fieldMap["parameters"] = m.Parameters m.fieldMap["extra"] = m.Extra m.fieldMap["created_at"] = m.CreatedAt m.fieldMap["updated_at"] = m.UpdatedAt m.fieldMap["deleted_at"] = m.DeletedAt } func (m modelInstance) clone(db *gorm.DB) modelInstance { m.modelInstanceDo.ReplaceConnPool(db.Statement.ConnPool) return m } func (m modelInstance) replaceDB(db *gorm.DB) modelInstance { m.modelInstanceDo.ReplaceDB(db) return m } type modelInstanceDo struct{ gen.DO } type IModelInstanceDo interface { gen.SubQuery Debug() IModelInstanceDo WithContext(ctx context.Context) IModelInstanceDo WithResult(fc func(tx gen.Dao)) gen.ResultInfo ReplaceDB(db *gorm.DB) ReadDB() IModelInstanceDo WriteDB() IModelInstanceDo As(alias string) gen.Dao Session(config *gorm.Session) IModelInstanceDo Columns(cols ...field.Expr) gen.Columns Clauses(conds ...clause.Expression) IModelInstanceDo Not(conds ...gen.Condition) IModelInstanceDo Or(conds ...gen.Condition) IModelInstanceDo Select(conds ...field.Expr) IModelInstanceDo Where(conds ...gen.Condition) IModelInstanceDo Order(conds ...field.Expr) IModelInstanceDo Distinct(cols ...field.Expr) IModelInstanceDo Omit(cols ...field.Expr) IModelInstanceDo Join(table schema.Tabler, on ...field.Expr) IModelInstanceDo LeftJoin(table schema.Tabler, on ...field.Expr) IModelInstanceDo RightJoin(table schema.Tabler, on ...field.Expr) IModelInstanceDo Group(cols ...field.Expr) IModelInstanceDo Having(conds ...gen.Condition) IModelInstanceDo Limit(limit int) IModelInstanceDo Offset(offset int) IModelInstanceDo Count() (count int64, err error) Scopes(funcs ...func(gen.Dao) gen.Dao) IModelInstanceDo Unscoped() IModelInstanceDo Create(values ...*model.ModelInstance) error CreateInBatches(values []*model.ModelInstance, batchSize int) error Save(values ...*model.ModelInstance) error First() (*model.ModelInstance, error) Take() (*model.ModelInstance, error) Last() (*model.ModelInstance, error) Find() ([]*model.ModelInstance, error) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ModelInstance, err error) FindInBatches(result *[]*model.ModelInstance, batchSize int, fc func(tx gen.Dao, batch int) error) error Pluck(column field.Expr, dest interface{}) error Delete(...*model.ModelInstance) (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) IModelInstanceDo Assign(attrs ...field.AssignExpr) IModelInstanceDo Joins(fields ...field.RelationField) IModelInstanceDo Preload(fields ...field.RelationField) IModelInstanceDo FirstOrInit() (*model.ModelInstance, error) FirstOrCreate() (*model.ModelInstance, error) FindByPage(offset int, limit int) (result []*model.ModelInstance, 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) IModelInstanceDo UnderlyingDB() *gorm.DB schema.Tabler } func (m modelInstanceDo) Debug() IModelInstanceDo { return m.withDO(m.DO.Debug()) } func (m modelInstanceDo) WithContext(ctx context.Context) IModelInstanceDo { return m.withDO(m.DO.WithContext(ctx)) } func (m modelInstanceDo) ReadDB() IModelInstanceDo { return m.Clauses(dbresolver.Read) } func (m modelInstanceDo) WriteDB() IModelInstanceDo { return m.Clauses(dbresolver.Write) } func (m modelInstanceDo) Session(config *gorm.Session) IModelInstanceDo { return m.withDO(m.DO.Session(config)) } func (m modelInstanceDo) Clauses(conds ...clause.Expression) IModelInstanceDo { return m.withDO(m.DO.Clauses(conds...)) } func (m modelInstanceDo) Returning(value interface{}, columns ...string) IModelInstanceDo { return m.withDO(m.DO.Returning(value, columns...)) } func (m modelInstanceDo) Not(conds ...gen.Condition) IModelInstanceDo { return m.withDO(m.DO.Not(conds...)) } func (m modelInstanceDo) Or(conds ...gen.Condition) IModelInstanceDo { return m.withDO(m.DO.Or(conds...)) } func (m modelInstanceDo) Select(conds ...field.Expr) IModelInstanceDo { return m.withDO(m.DO.Select(conds...)) } func (m modelInstanceDo) Where(conds ...gen.Condition) IModelInstanceDo { return m.withDO(m.DO.Where(conds...)) } func (m modelInstanceDo) Order(conds ...field.Expr) IModelInstanceDo { return m.withDO(m.DO.Order(conds...)) } func (m modelInstanceDo) Distinct(cols ...field.Expr) IModelInstanceDo { return m.withDO(m.DO.Distinct(cols...)) } func (m modelInstanceDo) Omit(cols ...field.Expr) IModelInstanceDo { return m.withDO(m.DO.Omit(cols...)) } func (m modelInstanceDo) Join(table schema.Tabler, on ...field.Expr) IModelInstanceDo { return m.withDO(m.DO.Join(table, on...)) } func (m modelInstanceDo) LeftJoin(table schema.Tabler, on ...field.Expr) IModelInstanceDo { return m.withDO(m.DO.LeftJoin(table, on...)) } func (m modelInstanceDo) RightJoin(table schema.Tabler, on ...field.Expr) IModelInstanceDo { return m.withDO(m.DO.RightJoin(table, on...)) } func (m modelInstanceDo) Group(cols ...field.Expr) IModelInstanceDo { return m.withDO(m.DO.Group(cols...)) } func (m modelInstanceDo) Having(conds ...gen.Condition) IModelInstanceDo { return m.withDO(m.DO.Having(conds...)) } func (m modelInstanceDo) Limit(limit int) IModelInstanceDo { return m.withDO(m.DO.Limit(limit)) } func (m modelInstanceDo) Offset(offset int) IModelInstanceDo { return m.withDO(m.DO.Offset(offset)) } func (m modelInstanceDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IModelInstanceDo { return m.withDO(m.DO.Scopes(funcs...)) } func (m modelInstanceDo) Unscoped() IModelInstanceDo { return m.withDO(m.DO.Unscoped()) } func (m modelInstanceDo) Create(values ...*model.ModelInstance) error { if len(values) == 0 { return nil } return m.DO.Create(values) } func (m modelInstanceDo) CreateInBatches(values []*model.ModelInstance, batchSize int) error { return m.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 (m modelInstanceDo) Save(values ...*model.ModelInstance) error { if len(values) == 0 { return nil } return m.DO.Save(values) } func (m modelInstanceDo) First() (*model.ModelInstance, error) { if result, err := m.DO.First(); err != nil { return nil, err } else { return result.(*model.ModelInstance), nil } } func (m modelInstanceDo) Take() (*model.ModelInstance, error) { if result, err := m.DO.Take(); err != nil { return nil, err } else { return result.(*model.ModelInstance), nil } } func (m modelInstanceDo) Last() (*model.ModelInstance, error) { if result, err := m.DO.Last(); err != nil { return nil, err } else { return result.(*model.ModelInstance), nil } } func (m modelInstanceDo) Find() ([]*model.ModelInstance, error) { result, err := m.DO.Find() return result.([]*model.ModelInstance), err } func (m modelInstanceDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ModelInstance, err error) { buf := make([]*model.ModelInstance, 0, batchSize) err = m.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 (m modelInstanceDo) FindInBatches(result *[]*model.ModelInstance, batchSize int, fc func(tx gen.Dao, batch int) error) error { return m.DO.FindInBatches(result, batchSize, fc) } func (m modelInstanceDo) Attrs(attrs ...field.AssignExpr) IModelInstanceDo { return m.withDO(m.DO.Attrs(attrs...)) } func (m modelInstanceDo) Assign(attrs ...field.AssignExpr) IModelInstanceDo { return m.withDO(m.DO.Assign(attrs...)) } func (m modelInstanceDo) Joins(fields ...field.RelationField) IModelInstanceDo { for _, _f := range fields { m = *m.withDO(m.DO.Joins(_f)) } return &m } func (m modelInstanceDo) Preload(fields ...field.RelationField) IModelInstanceDo { for _, _f := range fields { m = *m.withDO(m.DO.Preload(_f)) } return &m } func (m modelInstanceDo) FirstOrInit() (*model.ModelInstance, error) { if result, err := m.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*model.ModelInstance), nil } } func (m modelInstanceDo) FirstOrCreate() (*model.ModelInstance, error) { if result, err := m.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*model.ModelInstance), nil } } func (m modelInstanceDo) FindByPage(offset int, limit int) (result []*model.ModelInstance, count int64, err error) { result, err = m.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 = m.Offset(-1).Limit(-1).Count() return } func (m modelInstanceDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { count, err = m.Count() if err != nil { return } err = m.Offset(offset).Limit(limit).Scan(result) return } func (m modelInstanceDo) Scan(result interface{}) (err error) { return m.DO.Scan(result) } func (m modelInstanceDo) Delete(models ...*model.ModelInstance) (result gen.ResultInfo, err error) { return m.DO.Delete(models) } func (m *modelInstanceDo) withDO(do gen.Dao) *modelInstanceDo { m.DO = *do.(*gen.DO) return m }