rts-sim-testing-service/db/dbquery/gen.go

224 lines
7.1 KiB
Go
Raw Normal View History

// 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"
"database/sql"
"gorm.io/gorm"
"gorm.io/gen"
"gorm.io/plugin/dbresolver"
)
var (
Q = new(Query)
2023-08-30 09:28:21 +08:00
AuthAPIPath *authAPIPath
AuthRole *authRole
AuthRoleAPIPath *authRoleAPIPath
AuthRoleUser *authRoleUser
Category *category
Drafting *drafting
Project *project
ProjectPublishLink *projectPublishLink
ProjectRunConfig *projectRunConfig
ProjectTrainSizeLink *projectTrainSizeLink
PublishedGi *publishedGi
TrainModel *trainModel
2023-11-13 14:20:45 +08:00
TrainSensor *trainSensor
TrainSize *trainSize
TrainWheel *trainWheel
User *user
)
func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
*Q = *Use(db, opts...)
2023-08-30 09:28:21 +08:00
AuthAPIPath = &Q.AuthAPIPath
AuthRole = &Q.AuthRole
AuthRoleAPIPath = &Q.AuthRoleAPIPath
AuthRoleUser = &Q.AuthRoleUser
2023-08-03 17:01:28 +08:00
Category = &Q.Category
Drafting = &Q.Drafting
Project = &Q.Project
ProjectPublishLink = &Q.ProjectPublishLink
ProjectRunConfig = &Q.ProjectRunConfig
ProjectTrainSizeLink = &Q.ProjectTrainSizeLink
PublishedGi = &Q.PublishedGi
2023-08-22 16:44:34 +08:00
TrainModel = &Q.TrainModel
2023-11-13 14:20:45 +08:00
TrainSensor = &Q.TrainSensor
TrainSize = &Q.TrainSize
TrainWheel = &Q.TrainWheel
User = &Q.User
}
func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
return &Query{
db: db,
2023-08-30 09:28:21 +08:00
AuthAPIPath: newAuthAPIPath(db, opts...),
AuthRole: newAuthRole(db, opts...),
AuthRoleAPIPath: newAuthRoleAPIPath(db, opts...),
AuthRoleUser: newAuthRoleUser(db, opts...),
Category: newCategory(db, opts...),
Drafting: newDrafting(db, opts...),
Project: newProject(db, opts...),
ProjectPublishLink: newProjectPublishLink(db, opts...),
ProjectRunConfig: newProjectRunConfig(db, opts...),
ProjectTrainSizeLink: newProjectTrainSizeLink(db, opts...),
PublishedGi: newPublishedGi(db, opts...),
TrainModel: newTrainModel(db, opts...),
2023-11-13 14:20:45 +08:00
TrainSensor: newTrainSensor(db, opts...),
TrainSize: newTrainSize(db, opts...),
TrainWheel: newTrainWheel(db, opts...),
User: newUser(db, opts...),
}
}
type Query struct {
db *gorm.DB
2023-08-30 09:28:21 +08:00
AuthAPIPath authAPIPath
AuthRole authRole
AuthRoleAPIPath authRoleAPIPath
AuthRoleUser authRoleUser
Category category
Drafting drafting
Project project
ProjectPublishLink projectPublishLink
ProjectRunConfig projectRunConfig
ProjectTrainSizeLink projectTrainSizeLink
PublishedGi publishedGi
TrainModel trainModel
2023-11-13 14:20:45 +08:00
TrainSensor trainSensor
TrainSize trainSize
TrainWheel trainWheel
User user
}
func (q *Query) Available() bool { return q.db != nil }
func (q *Query) clone(db *gorm.DB) *Query {
return &Query{
db: db,
2023-08-30 09:28:21 +08:00
AuthAPIPath: q.AuthAPIPath.clone(db),
AuthRole: q.AuthRole.clone(db),
AuthRoleAPIPath: q.AuthRoleAPIPath.clone(db),
AuthRoleUser: q.AuthRoleUser.clone(db),
Category: q.Category.clone(db),
Drafting: q.Drafting.clone(db),
Project: q.Project.clone(db),
ProjectPublishLink: q.ProjectPublishLink.clone(db),
ProjectRunConfig: q.ProjectRunConfig.clone(db),
ProjectTrainSizeLink: q.ProjectTrainSizeLink.clone(db),
PublishedGi: q.PublishedGi.clone(db),
TrainModel: q.TrainModel.clone(db),
2023-11-13 14:20:45 +08:00
TrainSensor: q.TrainSensor.clone(db),
TrainSize: q.TrainSize.clone(db),
TrainWheel: q.TrainWheel.clone(db),
User: q.User.clone(db),
}
}
func (q *Query) ReadDB() *Query {
return q.ReplaceDB(q.db.Clauses(dbresolver.Read))
}
func (q *Query) WriteDB() *Query {
return q.ReplaceDB(q.db.Clauses(dbresolver.Write))
}
func (q *Query) ReplaceDB(db *gorm.DB) *Query {
return &Query{
db: db,
2023-08-30 09:28:21 +08:00
AuthAPIPath: q.AuthAPIPath.replaceDB(db),
AuthRole: q.AuthRole.replaceDB(db),
AuthRoleAPIPath: q.AuthRoleAPIPath.replaceDB(db),
AuthRoleUser: q.AuthRoleUser.replaceDB(db),
Category: q.Category.replaceDB(db),
Drafting: q.Drafting.replaceDB(db),
Project: q.Project.replaceDB(db),
ProjectPublishLink: q.ProjectPublishLink.replaceDB(db),
ProjectRunConfig: q.ProjectRunConfig.replaceDB(db),
ProjectTrainSizeLink: q.ProjectTrainSizeLink.replaceDB(db),
PublishedGi: q.PublishedGi.replaceDB(db),
TrainModel: q.TrainModel.replaceDB(db),
2023-11-13 14:20:45 +08:00
TrainSensor: q.TrainSensor.replaceDB(db),
TrainSize: q.TrainSize.replaceDB(db),
TrainWheel: q.TrainWheel.replaceDB(db),
User: q.User.replaceDB(db),
}
}
type queryCtx struct {
2023-08-30 09:28:21 +08:00
AuthAPIPath IAuthAPIPathDo
AuthRole IAuthRoleDo
AuthRoleAPIPath IAuthRoleAPIPathDo
AuthRoleUser IAuthRoleUserDo
Category ICategoryDo
Drafting IDraftingDo
Project IProjectDo
ProjectPublishLink IProjectPublishLinkDo
ProjectRunConfig IProjectRunConfigDo
ProjectTrainSizeLink IProjectTrainSizeLinkDo
PublishedGi IPublishedGiDo
TrainModel ITrainModelDo
2023-11-13 14:20:45 +08:00
TrainSensor ITrainSensorDo
TrainSize ITrainSizeDo
TrainWheel ITrainWheelDo
User IUserDo
}
func (q *Query) WithContext(ctx context.Context) *queryCtx {
return &queryCtx{
2023-08-30 09:28:21 +08:00
AuthAPIPath: q.AuthAPIPath.WithContext(ctx),
AuthRole: q.AuthRole.WithContext(ctx),
AuthRoleAPIPath: q.AuthRoleAPIPath.WithContext(ctx),
AuthRoleUser: q.AuthRoleUser.WithContext(ctx),
Category: q.Category.WithContext(ctx),
Drafting: q.Drafting.WithContext(ctx),
Project: q.Project.WithContext(ctx),
ProjectPublishLink: q.ProjectPublishLink.WithContext(ctx),
ProjectRunConfig: q.ProjectRunConfig.WithContext(ctx),
ProjectTrainSizeLink: q.ProjectTrainSizeLink.WithContext(ctx),
PublishedGi: q.PublishedGi.WithContext(ctx),
TrainModel: q.TrainModel.WithContext(ctx),
2023-11-13 14:20:45 +08:00
TrainSensor: q.TrainSensor.WithContext(ctx),
TrainSize: q.TrainSize.WithContext(ctx),
TrainWheel: q.TrainWheel.WithContext(ctx),
User: q.User.WithContext(ctx),
}
}
func (q *Query) Transaction(fc func(tx *Query) error, opts ...*sql.TxOptions) error {
return q.db.Transaction(func(tx *gorm.DB) error { return fc(q.clone(tx)) }, opts...)
}
func (q *Query) Begin(opts ...*sql.TxOptions) *QueryTx {
tx := q.db.Begin(opts...)
return &QueryTx{Query: q.clone(tx), Error: tx.Error}
}
type QueryTx struct {
*Query
Error error
}
func (q *QueryTx) Commit() error {
return q.db.Commit().Error
}
func (q *QueryTx) Rollback() error {
return q.db.Rollback().Error
}
func (q *QueryTx) SavePoint(name string) error {
return q.db.SavePoint(name).Error
}
func (q *QueryTx) RollbackTo(name string) error {
return q.db.RollbackTo(name).Error
}