mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-02-03 07:13:26 +08:00
1050 lines
41 KiB
Go
1050 lines
41 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package intercept
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"github.com/chaitin/MonkeyCode/backend/db"
|
|
"github.com/chaitin/MonkeyCode/backend/db/admin"
|
|
"github.com/chaitin/MonkeyCode/backend/db/adminloginhistory"
|
|
"github.com/chaitin/MonkeyCode/backend/db/adminrole"
|
|
"github.com/chaitin/MonkeyCode/backend/db/aiemployee"
|
|
"github.com/chaitin/MonkeyCode/backend/db/aitask"
|
|
"github.com/chaitin/MonkeyCode/backend/db/apikey"
|
|
"github.com/chaitin/MonkeyCode/backend/db/billingplan"
|
|
"github.com/chaitin/MonkeyCode/backend/db/billingquota"
|
|
"github.com/chaitin/MonkeyCode/backend/db/billingrecord"
|
|
"github.com/chaitin/MonkeyCode/backend/db/billingusage"
|
|
"github.com/chaitin/MonkeyCode/backend/db/codesnippet"
|
|
"github.com/chaitin/MonkeyCode/backend/db/extension"
|
|
"github.com/chaitin/MonkeyCode/backend/db/invitecode"
|
|
"github.com/chaitin/MonkeyCode/backend/db/license"
|
|
"github.com/chaitin/MonkeyCode/backend/db/model"
|
|
"github.com/chaitin/MonkeyCode/backend/db/modelprovider"
|
|
"github.com/chaitin/MonkeyCode/backend/db/modelprovidermodel"
|
|
"github.com/chaitin/MonkeyCode/backend/db/predicate"
|
|
"github.com/chaitin/MonkeyCode/backend/db/role"
|
|
"github.com/chaitin/MonkeyCode/backend/db/securityscanning"
|
|
"github.com/chaitin/MonkeyCode/backend/db/securityscanningresult"
|
|
"github.com/chaitin/MonkeyCode/backend/db/setting"
|
|
"github.com/chaitin/MonkeyCode/backend/db/task"
|
|
"github.com/chaitin/MonkeyCode/backend/db/taskrecord"
|
|
"github.com/chaitin/MonkeyCode/backend/db/user"
|
|
"github.com/chaitin/MonkeyCode/backend/db/usergroup"
|
|
"github.com/chaitin/MonkeyCode/backend/db/usergroupadmin"
|
|
"github.com/chaitin/MonkeyCode/backend/db/usergroupuser"
|
|
"github.com/chaitin/MonkeyCode/backend/db/useridentity"
|
|
"github.com/chaitin/MonkeyCode/backend/db/userloginhistory"
|
|
"github.com/chaitin/MonkeyCode/backend/db/workspace"
|
|
"github.com/chaitin/MonkeyCode/backend/db/workspacefile"
|
|
)
|
|
|
|
// The Query interface represents an operation that queries a graph.
|
|
// By using this interface, users can write generic code that manipulates
|
|
// query builders of different types.
|
|
type Query interface {
|
|
// Type returns the string representation of the query type.
|
|
Type() string
|
|
// Limit the number of records to be returned by this query.
|
|
Limit(int)
|
|
// Offset to start from.
|
|
Offset(int)
|
|
// Unique configures the query builder to filter duplicate records.
|
|
Unique(bool)
|
|
// Order specifies how the records should be ordered.
|
|
Order(...func(*sql.Selector))
|
|
// WhereP appends storage-level predicates to the query builder. Using this method, users
|
|
// can use type-assertion to append predicates that do not depend on any generated package.
|
|
WhereP(...func(*sql.Selector))
|
|
}
|
|
|
|
// The Func type is an adapter that allows ordinary functions to be used as interceptors.
|
|
// Unlike traversal functions, interceptors are skipped during graph traversals. Note that the
|
|
// implementation of Func is different from the one defined in entgo.io/ent.InterceptFunc.
|
|
type Func func(context.Context, Query) error
|
|
|
|
// Intercept calls f(ctx, q) and then applied the next Querier.
|
|
func (f Func) Intercept(next db.Querier) db.Querier {
|
|
return db.QuerierFunc(func(ctx context.Context, q db.Query) (db.Value, error) {
|
|
query, err := NewQuery(q)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if err := f(ctx, query); err != nil {
|
|
return nil, err
|
|
}
|
|
return next.Query(ctx, q)
|
|
})
|
|
}
|
|
|
|
// The TraverseFunc type is an adapter to allow the use of ordinary function as Traverser.
|
|
// If f is a function with the appropriate signature, TraverseFunc(f) is a Traverser that calls f.
|
|
type TraverseFunc func(context.Context, Query) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseFunc) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseFunc) Traverse(ctx context.Context, q db.Query) error {
|
|
query, err := NewQuery(q)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return f(ctx, query)
|
|
}
|
|
|
|
// The AIEmployeeFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type AIEmployeeFunc func(context.Context, *db.AIEmployeeQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f AIEmployeeFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.AIEmployeeQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.AIEmployeeQuery", q)
|
|
}
|
|
|
|
// The TraverseAIEmployee type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseAIEmployee func(context.Context, *db.AIEmployeeQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseAIEmployee) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseAIEmployee) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.AIEmployeeQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.AIEmployeeQuery", q)
|
|
}
|
|
|
|
// The AITaskFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type AITaskFunc func(context.Context, *db.AITaskQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f AITaskFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.AITaskQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.AITaskQuery", q)
|
|
}
|
|
|
|
// The TraverseAITask type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseAITask func(context.Context, *db.AITaskQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseAITask) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseAITask) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.AITaskQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.AITaskQuery", q)
|
|
}
|
|
|
|
// The AdminFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type AdminFunc func(context.Context, *db.AdminQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f AdminFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.AdminQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.AdminQuery", q)
|
|
}
|
|
|
|
// The TraverseAdmin type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseAdmin func(context.Context, *db.AdminQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseAdmin) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseAdmin) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.AdminQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.AdminQuery", q)
|
|
}
|
|
|
|
// The AdminLoginHistoryFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type AdminLoginHistoryFunc func(context.Context, *db.AdminLoginHistoryQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f AdminLoginHistoryFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.AdminLoginHistoryQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.AdminLoginHistoryQuery", q)
|
|
}
|
|
|
|
// The TraverseAdminLoginHistory type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseAdminLoginHistory func(context.Context, *db.AdminLoginHistoryQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseAdminLoginHistory) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseAdminLoginHistory) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.AdminLoginHistoryQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.AdminLoginHistoryQuery", q)
|
|
}
|
|
|
|
// The AdminRoleFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type AdminRoleFunc func(context.Context, *db.AdminRoleQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f AdminRoleFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.AdminRoleQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.AdminRoleQuery", q)
|
|
}
|
|
|
|
// The TraverseAdminRole type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseAdminRole func(context.Context, *db.AdminRoleQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseAdminRole) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseAdminRole) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.AdminRoleQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.AdminRoleQuery", q)
|
|
}
|
|
|
|
// The ApiKeyFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type ApiKeyFunc func(context.Context, *db.ApiKeyQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f ApiKeyFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.ApiKeyQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.ApiKeyQuery", q)
|
|
}
|
|
|
|
// The TraverseApiKey type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseApiKey func(context.Context, *db.ApiKeyQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseApiKey) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseApiKey) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.ApiKeyQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.ApiKeyQuery", q)
|
|
}
|
|
|
|
// The BillingPlanFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type BillingPlanFunc func(context.Context, *db.BillingPlanQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f BillingPlanFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.BillingPlanQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.BillingPlanQuery", q)
|
|
}
|
|
|
|
// The TraverseBillingPlan type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseBillingPlan func(context.Context, *db.BillingPlanQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseBillingPlan) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseBillingPlan) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.BillingPlanQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.BillingPlanQuery", q)
|
|
}
|
|
|
|
// The BillingQuotaFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type BillingQuotaFunc func(context.Context, *db.BillingQuotaQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f BillingQuotaFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.BillingQuotaQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.BillingQuotaQuery", q)
|
|
}
|
|
|
|
// The TraverseBillingQuota type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseBillingQuota func(context.Context, *db.BillingQuotaQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseBillingQuota) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseBillingQuota) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.BillingQuotaQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.BillingQuotaQuery", q)
|
|
}
|
|
|
|
// The BillingRecordFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type BillingRecordFunc func(context.Context, *db.BillingRecordQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f BillingRecordFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.BillingRecordQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.BillingRecordQuery", q)
|
|
}
|
|
|
|
// The TraverseBillingRecord type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseBillingRecord func(context.Context, *db.BillingRecordQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseBillingRecord) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseBillingRecord) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.BillingRecordQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.BillingRecordQuery", q)
|
|
}
|
|
|
|
// The BillingUsageFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type BillingUsageFunc func(context.Context, *db.BillingUsageQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f BillingUsageFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.BillingUsageQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.BillingUsageQuery", q)
|
|
}
|
|
|
|
// The TraverseBillingUsage type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseBillingUsage func(context.Context, *db.BillingUsageQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseBillingUsage) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseBillingUsage) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.BillingUsageQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.BillingUsageQuery", q)
|
|
}
|
|
|
|
// The CodeSnippetFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type CodeSnippetFunc func(context.Context, *db.CodeSnippetQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f CodeSnippetFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.CodeSnippetQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.CodeSnippetQuery", q)
|
|
}
|
|
|
|
// The TraverseCodeSnippet type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseCodeSnippet func(context.Context, *db.CodeSnippetQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseCodeSnippet) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseCodeSnippet) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.CodeSnippetQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.CodeSnippetQuery", q)
|
|
}
|
|
|
|
// The ExtensionFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type ExtensionFunc func(context.Context, *db.ExtensionQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f ExtensionFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.ExtensionQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.ExtensionQuery", q)
|
|
}
|
|
|
|
// The TraverseExtension type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseExtension func(context.Context, *db.ExtensionQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseExtension) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseExtension) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.ExtensionQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.ExtensionQuery", q)
|
|
}
|
|
|
|
// The InviteCodeFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type InviteCodeFunc func(context.Context, *db.InviteCodeQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f InviteCodeFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.InviteCodeQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.InviteCodeQuery", q)
|
|
}
|
|
|
|
// The TraverseInviteCode type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseInviteCode func(context.Context, *db.InviteCodeQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseInviteCode) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseInviteCode) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.InviteCodeQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.InviteCodeQuery", q)
|
|
}
|
|
|
|
// The LicenseFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type LicenseFunc func(context.Context, *db.LicenseQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f LicenseFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.LicenseQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.LicenseQuery", q)
|
|
}
|
|
|
|
// The TraverseLicense type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseLicense func(context.Context, *db.LicenseQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseLicense) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseLicense) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.LicenseQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.LicenseQuery", q)
|
|
}
|
|
|
|
// The ModelFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type ModelFunc func(context.Context, *db.ModelQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f ModelFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.ModelQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.ModelQuery", q)
|
|
}
|
|
|
|
// The TraverseModel type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseModel func(context.Context, *db.ModelQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseModel) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseModel) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.ModelQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.ModelQuery", q)
|
|
}
|
|
|
|
// The ModelProviderFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type ModelProviderFunc func(context.Context, *db.ModelProviderQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f ModelProviderFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.ModelProviderQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.ModelProviderQuery", q)
|
|
}
|
|
|
|
// The TraverseModelProvider type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseModelProvider func(context.Context, *db.ModelProviderQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseModelProvider) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseModelProvider) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.ModelProviderQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.ModelProviderQuery", q)
|
|
}
|
|
|
|
// The ModelProviderModelFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type ModelProviderModelFunc func(context.Context, *db.ModelProviderModelQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f ModelProviderModelFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.ModelProviderModelQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.ModelProviderModelQuery", q)
|
|
}
|
|
|
|
// The TraverseModelProviderModel type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseModelProviderModel func(context.Context, *db.ModelProviderModelQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseModelProviderModel) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseModelProviderModel) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.ModelProviderModelQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.ModelProviderModelQuery", q)
|
|
}
|
|
|
|
// The RoleFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type RoleFunc func(context.Context, *db.RoleQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f RoleFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.RoleQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.RoleQuery", q)
|
|
}
|
|
|
|
// The TraverseRole type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseRole func(context.Context, *db.RoleQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseRole) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseRole) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.RoleQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.RoleQuery", q)
|
|
}
|
|
|
|
// The SecurityScanningFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type SecurityScanningFunc func(context.Context, *db.SecurityScanningQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f SecurityScanningFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.SecurityScanningQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.SecurityScanningQuery", q)
|
|
}
|
|
|
|
// The TraverseSecurityScanning type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseSecurityScanning func(context.Context, *db.SecurityScanningQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseSecurityScanning) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseSecurityScanning) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.SecurityScanningQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.SecurityScanningQuery", q)
|
|
}
|
|
|
|
// The SecurityScanningResultFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type SecurityScanningResultFunc func(context.Context, *db.SecurityScanningResultQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f SecurityScanningResultFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.SecurityScanningResultQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.SecurityScanningResultQuery", q)
|
|
}
|
|
|
|
// The TraverseSecurityScanningResult type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseSecurityScanningResult func(context.Context, *db.SecurityScanningResultQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseSecurityScanningResult) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseSecurityScanningResult) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.SecurityScanningResultQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.SecurityScanningResultQuery", q)
|
|
}
|
|
|
|
// The SettingFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type SettingFunc func(context.Context, *db.SettingQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f SettingFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.SettingQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.SettingQuery", q)
|
|
}
|
|
|
|
// The TraverseSetting type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseSetting func(context.Context, *db.SettingQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseSetting) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseSetting) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.SettingQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.SettingQuery", q)
|
|
}
|
|
|
|
// The TaskFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type TaskFunc func(context.Context, *db.TaskQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f TaskFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.TaskQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.TaskQuery", q)
|
|
}
|
|
|
|
// The TraverseTask type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseTask func(context.Context, *db.TaskQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseTask) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseTask) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.TaskQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.TaskQuery", q)
|
|
}
|
|
|
|
// The TaskRecordFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type TaskRecordFunc func(context.Context, *db.TaskRecordQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f TaskRecordFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.TaskRecordQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.TaskRecordQuery", q)
|
|
}
|
|
|
|
// The TraverseTaskRecord type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseTaskRecord func(context.Context, *db.TaskRecordQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseTaskRecord) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseTaskRecord) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.TaskRecordQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.TaskRecordQuery", q)
|
|
}
|
|
|
|
// The UserFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type UserFunc func(context.Context, *db.UserQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f UserFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.UserQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.UserQuery", q)
|
|
}
|
|
|
|
// The TraverseUser type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseUser func(context.Context, *db.UserQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseUser) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseUser) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.UserQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.UserQuery", q)
|
|
}
|
|
|
|
// The UserGroupFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type UserGroupFunc func(context.Context, *db.UserGroupQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f UserGroupFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.UserGroupQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.UserGroupQuery", q)
|
|
}
|
|
|
|
// The TraverseUserGroup type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseUserGroup func(context.Context, *db.UserGroupQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseUserGroup) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseUserGroup) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.UserGroupQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.UserGroupQuery", q)
|
|
}
|
|
|
|
// The UserGroupAdminFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type UserGroupAdminFunc func(context.Context, *db.UserGroupAdminQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f UserGroupAdminFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.UserGroupAdminQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.UserGroupAdminQuery", q)
|
|
}
|
|
|
|
// The TraverseUserGroupAdmin type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseUserGroupAdmin func(context.Context, *db.UserGroupAdminQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseUserGroupAdmin) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseUserGroupAdmin) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.UserGroupAdminQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.UserGroupAdminQuery", q)
|
|
}
|
|
|
|
// The UserGroupUserFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type UserGroupUserFunc func(context.Context, *db.UserGroupUserQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f UserGroupUserFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.UserGroupUserQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.UserGroupUserQuery", q)
|
|
}
|
|
|
|
// The TraverseUserGroupUser type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseUserGroupUser func(context.Context, *db.UserGroupUserQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseUserGroupUser) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseUserGroupUser) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.UserGroupUserQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.UserGroupUserQuery", q)
|
|
}
|
|
|
|
// The UserIdentityFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type UserIdentityFunc func(context.Context, *db.UserIdentityQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f UserIdentityFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.UserIdentityQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.UserIdentityQuery", q)
|
|
}
|
|
|
|
// The TraverseUserIdentity type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseUserIdentity func(context.Context, *db.UserIdentityQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseUserIdentity) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseUserIdentity) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.UserIdentityQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.UserIdentityQuery", q)
|
|
}
|
|
|
|
// The UserLoginHistoryFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type UserLoginHistoryFunc func(context.Context, *db.UserLoginHistoryQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f UserLoginHistoryFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.UserLoginHistoryQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.UserLoginHistoryQuery", q)
|
|
}
|
|
|
|
// The TraverseUserLoginHistory type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseUserLoginHistory func(context.Context, *db.UserLoginHistoryQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseUserLoginHistory) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseUserLoginHistory) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.UserLoginHistoryQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.UserLoginHistoryQuery", q)
|
|
}
|
|
|
|
// The WorkspaceFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type WorkspaceFunc func(context.Context, *db.WorkspaceQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f WorkspaceFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.WorkspaceQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.WorkspaceQuery", q)
|
|
}
|
|
|
|
// The TraverseWorkspace type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseWorkspace func(context.Context, *db.WorkspaceQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseWorkspace) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseWorkspace) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.WorkspaceQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.WorkspaceQuery", q)
|
|
}
|
|
|
|
// The WorkspaceFileFunc type is an adapter to allow the use of ordinary function as a Querier.
|
|
type WorkspaceFileFunc func(context.Context, *db.WorkspaceFileQuery) (db.Value, error)
|
|
|
|
// Query calls f(ctx, q).
|
|
func (f WorkspaceFileFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
|
if q, ok := q.(*db.WorkspaceFileQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return nil, fmt.Errorf("unexpected query type %T. expect *db.WorkspaceFileQuery", q)
|
|
}
|
|
|
|
// The TraverseWorkspaceFile type is an adapter to allow the use of ordinary function as Traverser.
|
|
type TraverseWorkspaceFile func(context.Context, *db.WorkspaceFileQuery) error
|
|
|
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
|
func (f TraverseWorkspaceFile) Intercept(next db.Querier) db.Querier {
|
|
return next
|
|
}
|
|
|
|
// Traverse calls f(ctx, q).
|
|
func (f TraverseWorkspaceFile) Traverse(ctx context.Context, q db.Query) error {
|
|
if q, ok := q.(*db.WorkspaceFileQuery); ok {
|
|
return f(ctx, q)
|
|
}
|
|
return fmt.Errorf("unexpected query type %T. expect *db.WorkspaceFileQuery", q)
|
|
}
|
|
|
|
// NewQuery returns the generic Query interface for the given typed query.
|
|
func NewQuery(q db.Query) (Query, error) {
|
|
switch q := q.(type) {
|
|
case *db.AIEmployeeQuery:
|
|
return &query[*db.AIEmployeeQuery, predicate.AIEmployee, aiemployee.OrderOption]{typ: db.TypeAIEmployee, tq: q}, nil
|
|
case *db.AITaskQuery:
|
|
return &query[*db.AITaskQuery, predicate.AITask, aitask.OrderOption]{typ: db.TypeAITask, tq: q}, nil
|
|
case *db.AdminQuery:
|
|
return &query[*db.AdminQuery, predicate.Admin, admin.OrderOption]{typ: db.TypeAdmin, tq: q}, nil
|
|
case *db.AdminLoginHistoryQuery:
|
|
return &query[*db.AdminLoginHistoryQuery, predicate.AdminLoginHistory, adminloginhistory.OrderOption]{typ: db.TypeAdminLoginHistory, tq: q}, nil
|
|
case *db.AdminRoleQuery:
|
|
return &query[*db.AdminRoleQuery, predicate.AdminRole, adminrole.OrderOption]{typ: db.TypeAdminRole, tq: q}, nil
|
|
case *db.ApiKeyQuery:
|
|
return &query[*db.ApiKeyQuery, predicate.ApiKey, apikey.OrderOption]{typ: db.TypeApiKey, tq: q}, nil
|
|
case *db.BillingPlanQuery:
|
|
return &query[*db.BillingPlanQuery, predicate.BillingPlan, billingplan.OrderOption]{typ: db.TypeBillingPlan, tq: q}, nil
|
|
case *db.BillingQuotaQuery:
|
|
return &query[*db.BillingQuotaQuery, predicate.BillingQuota, billingquota.OrderOption]{typ: db.TypeBillingQuota, tq: q}, nil
|
|
case *db.BillingRecordQuery:
|
|
return &query[*db.BillingRecordQuery, predicate.BillingRecord, billingrecord.OrderOption]{typ: db.TypeBillingRecord, tq: q}, nil
|
|
case *db.BillingUsageQuery:
|
|
return &query[*db.BillingUsageQuery, predicate.BillingUsage, billingusage.OrderOption]{typ: db.TypeBillingUsage, tq: q}, nil
|
|
case *db.CodeSnippetQuery:
|
|
return &query[*db.CodeSnippetQuery, predicate.CodeSnippet, codesnippet.OrderOption]{typ: db.TypeCodeSnippet, tq: q}, nil
|
|
case *db.ExtensionQuery:
|
|
return &query[*db.ExtensionQuery, predicate.Extension, extension.OrderOption]{typ: db.TypeExtension, tq: q}, nil
|
|
case *db.InviteCodeQuery:
|
|
return &query[*db.InviteCodeQuery, predicate.InviteCode, invitecode.OrderOption]{typ: db.TypeInviteCode, tq: q}, nil
|
|
case *db.LicenseQuery:
|
|
return &query[*db.LicenseQuery, predicate.License, license.OrderOption]{typ: db.TypeLicense, tq: q}, nil
|
|
case *db.ModelQuery:
|
|
return &query[*db.ModelQuery, predicate.Model, model.OrderOption]{typ: db.TypeModel, tq: q}, nil
|
|
case *db.ModelProviderQuery:
|
|
return &query[*db.ModelProviderQuery, predicate.ModelProvider, modelprovider.OrderOption]{typ: db.TypeModelProvider, tq: q}, nil
|
|
case *db.ModelProviderModelQuery:
|
|
return &query[*db.ModelProviderModelQuery, predicate.ModelProviderModel, modelprovidermodel.OrderOption]{typ: db.TypeModelProviderModel, tq: q}, nil
|
|
case *db.RoleQuery:
|
|
return &query[*db.RoleQuery, predicate.Role, role.OrderOption]{typ: db.TypeRole, tq: q}, nil
|
|
case *db.SecurityScanningQuery:
|
|
return &query[*db.SecurityScanningQuery, predicate.SecurityScanning, securityscanning.OrderOption]{typ: db.TypeSecurityScanning, tq: q}, nil
|
|
case *db.SecurityScanningResultQuery:
|
|
return &query[*db.SecurityScanningResultQuery, predicate.SecurityScanningResult, securityscanningresult.OrderOption]{typ: db.TypeSecurityScanningResult, tq: q}, nil
|
|
case *db.SettingQuery:
|
|
return &query[*db.SettingQuery, predicate.Setting, setting.OrderOption]{typ: db.TypeSetting, tq: q}, nil
|
|
case *db.TaskQuery:
|
|
return &query[*db.TaskQuery, predicate.Task, task.OrderOption]{typ: db.TypeTask, tq: q}, nil
|
|
case *db.TaskRecordQuery:
|
|
return &query[*db.TaskRecordQuery, predicate.TaskRecord, taskrecord.OrderOption]{typ: db.TypeTaskRecord, tq: q}, nil
|
|
case *db.UserQuery:
|
|
return &query[*db.UserQuery, predicate.User, user.OrderOption]{typ: db.TypeUser, tq: q}, nil
|
|
case *db.UserGroupQuery:
|
|
return &query[*db.UserGroupQuery, predicate.UserGroup, usergroup.OrderOption]{typ: db.TypeUserGroup, tq: q}, nil
|
|
case *db.UserGroupAdminQuery:
|
|
return &query[*db.UserGroupAdminQuery, predicate.UserGroupAdmin, usergroupadmin.OrderOption]{typ: db.TypeUserGroupAdmin, tq: q}, nil
|
|
case *db.UserGroupUserQuery:
|
|
return &query[*db.UserGroupUserQuery, predicate.UserGroupUser, usergroupuser.OrderOption]{typ: db.TypeUserGroupUser, tq: q}, nil
|
|
case *db.UserIdentityQuery:
|
|
return &query[*db.UserIdentityQuery, predicate.UserIdentity, useridentity.OrderOption]{typ: db.TypeUserIdentity, tq: q}, nil
|
|
case *db.UserLoginHistoryQuery:
|
|
return &query[*db.UserLoginHistoryQuery, predicate.UserLoginHistory, userloginhistory.OrderOption]{typ: db.TypeUserLoginHistory, tq: q}, nil
|
|
case *db.WorkspaceQuery:
|
|
return &query[*db.WorkspaceQuery, predicate.Workspace, workspace.OrderOption]{typ: db.TypeWorkspace, tq: q}, nil
|
|
case *db.WorkspaceFileQuery:
|
|
return &query[*db.WorkspaceFileQuery, predicate.WorkspaceFile, workspacefile.OrderOption]{typ: db.TypeWorkspaceFile, tq: q}, nil
|
|
default:
|
|
return nil, fmt.Errorf("unknown query type %T", q)
|
|
}
|
|
}
|
|
|
|
type query[T any, P ~func(*sql.Selector), R ~func(*sql.Selector)] struct {
|
|
typ string
|
|
tq interface {
|
|
Limit(int) T
|
|
Offset(int) T
|
|
Unique(bool) T
|
|
Order(...R) T
|
|
Where(...P) T
|
|
}
|
|
}
|
|
|
|
func (q query[T, P, R]) Type() string {
|
|
return q.typ
|
|
}
|
|
|
|
func (q query[T, P, R]) Limit(limit int) {
|
|
q.tq.Limit(limit)
|
|
}
|
|
|
|
func (q query[T, P, R]) Offset(offset int) {
|
|
q.tq.Offset(offset)
|
|
}
|
|
|
|
func (q query[T, P, R]) Unique(unique bool) {
|
|
q.tq.Unique(unique)
|
|
}
|
|
|
|
func (q query[T, P, R]) Order(orders ...func(*sql.Selector)) {
|
|
rs := make([]R, len(orders))
|
|
for i := range orders {
|
|
rs[i] = orders[i]
|
|
}
|
|
q.tq.Order(rs...)
|
|
}
|
|
|
|
func (q query[T, P, R]) WhereP(ps ...func(*sql.Selector)) {
|
|
p := make([]P, len(ps))
|
|
for i := range ps {
|
|
p[i] = ps[i]
|
|
}
|
|
q.tq.Where(p...)
|
|
}
|