Commit 112a2d08 authored by ianshaw's avatar ianshaw
Browse files

chore: 更新依赖、配置和代码生成

主要更新:
- 更新 go.mod/go.sum 依赖
- 重新生成 Ent ORM 代码
- 更新 Wire 依赖注入配置
- 添加 docker-compose.override.yml 到 .gitignore
- 更新 README 文档(Simple Mode 说明和已知问题)
- 清理调试日志
- 其他代码优化和格式修复
parent b1702de5
...@@ -273,14 +273,14 @@ func (_u *GroupUpdate) AddDefaultValidityDays(v int) *GroupUpdate { ...@@ -273,14 +273,14 @@ func (_u *GroupUpdate) AddDefaultValidityDays(v int) *GroupUpdate {
return _u return _u
} }
// AddAPIKeyIDs adds the "api_keys" edge to the APIKey entity by IDs. // AddAPIKeyIDs adds the "api_keys" edge to the ApiKey entity by IDs.
func (_u *GroupUpdate) AddAPIKeyIDs(ids ...int64) *GroupUpdate { func (_u *GroupUpdate) AddAPIKeyIDs(ids ...int64) *GroupUpdate {
_u.mutation.AddAPIKeyIDs(ids...) _u.mutation.AddAPIKeyIDs(ids...)
return _u return _u
} }
// AddAPIKeys adds the "api_keys" edges to the APIKey entity. // AddAPIKeys adds the "api_keys" edges to the ApiKey entity.
func (_u *GroupUpdate) AddAPIKeys(v ...*APIKey) *GroupUpdate { func (_u *GroupUpdate) AddAPIKeys(v ...*ApiKey) *GroupUpdate {
ids := make([]int64, len(v)) ids := make([]int64, len(v))
for i := range v { for i := range v {
ids[i] = v[i].ID ids[i] = v[i].ID
...@@ -368,20 +368,20 @@ func (_u *GroupUpdate) Mutation() *GroupMutation { ...@@ -368,20 +368,20 @@ func (_u *GroupUpdate) Mutation() *GroupMutation {
return _u.mutation return _u.mutation
} }
// ClearAPIKeys clears all "api_keys" edges to the APIKey entity. // ClearAPIKeys clears all "api_keys" edges to the ApiKey entity.
func (_u *GroupUpdate) ClearAPIKeys() *GroupUpdate { func (_u *GroupUpdate) ClearAPIKeys() *GroupUpdate {
_u.mutation.ClearAPIKeys() _u.mutation.ClearAPIKeys()
return _u return _u
} }
// RemoveAPIKeyIDs removes the "api_keys" edge to APIKey entities by IDs. // RemoveAPIKeyIDs removes the "api_keys" edge to ApiKey entities by IDs.
func (_u *GroupUpdate) RemoveAPIKeyIDs(ids ...int64) *GroupUpdate { func (_u *GroupUpdate) RemoveAPIKeyIDs(ids ...int64) *GroupUpdate {
_u.mutation.RemoveAPIKeyIDs(ids...) _u.mutation.RemoveAPIKeyIDs(ids...)
return _u return _u
} }
// RemoveAPIKeys removes "api_keys" edges to APIKey entities. // RemoveAPIKeys removes "api_keys" edges to ApiKey entities.
func (_u *GroupUpdate) RemoveAPIKeys(v ...*APIKey) *GroupUpdate { func (_u *GroupUpdate) RemoveAPIKeys(v ...*ApiKey) *GroupUpdate {
ids := make([]int64, len(v)) ids := make([]int64, len(v))
for i := range v { for i := range v {
ids[i] = v[i].ID ids[i] = v[i].ID
...@@ -1195,14 +1195,14 @@ func (_u *GroupUpdateOne) AddDefaultValidityDays(v int) *GroupUpdateOne { ...@@ -1195,14 +1195,14 @@ func (_u *GroupUpdateOne) AddDefaultValidityDays(v int) *GroupUpdateOne {
return _u return _u
} }
// AddAPIKeyIDs adds the "api_keys" edge to the APIKey entity by IDs. // AddAPIKeyIDs adds the "api_keys" edge to the ApiKey entity by IDs.
func (_u *GroupUpdateOne) AddAPIKeyIDs(ids ...int64) *GroupUpdateOne { func (_u *GroupUpdateOne) AddAPIKeyIDs(ids ...int64) *GroupUpdateOne {
_u.mutation.AddAPIKeyIDs(ids...) _u.mutation.AddAPIKeyIDs(ids...)
return _u return _u
} }
// AddAPIKeys adds the "api_keys" edges to the APIKey entity. // AddAPIKeys adds the "api_keys" edges to the ApiKey entity.
func (_u *GroupUpdateOne) AddAPIKeys(v ...*APIKey) *GroupUpdateOne { func (_u *GroupUpdateOne) AddAPIKeys(v ...*ApiKey) *GroupUpdateOne {
ids := make([]int64, len(v)) ids := make([]int64, len(v))
for i := range v { for i := range v {
ids[i] = v[i].ID ids[i] = v[i].ID
...@@ -1290,20 +1290,20 @@ func (_u *GroupUpdateOne) Mutation() *GroupMutation { ...@@ -1290,20 +1290,20 @@ func (_u *GroupUpdateOne) Mutation() *GroupMutation {
return _u.mutation return _u.mutation
} }
// ClearAPIKeys clears all "api_keys" edges to the APIKey entity. // ClearAPIKeys clears all "api_keys" edges to the ApiKey entity.
func (_u *GroupUpdateOne) ClearAPIKeys() *GroupUpdateOne { func (_u *GroupUpdateOne) ClearAPIKeys() *GroupUpdateOne {
_u.mutation.ClearAPIKeys() _u.mutation.ClearAPIKeys()
return _u return _u
} }
// RemoveAPIKeyIDs removes the "api_keys" edge to APIKey entities by IDs. // RemoveAPIKeyIDs removes the "api_keys" edge to ApiKey entities by IDs.
func (_u *GroupUpdateOne) RemoveAPIKeyIDs(ids ...int64) *GroupUpdateOne { func (_u *GroupUpdateOne) RemoveAPIKeyIDs(ids ...int64) *GroupUpdateOne {
_u.mutation.RemoveAPIKeyIDs(ids...) _u.mutation.RemoveAPIKeyIDs(ids...)
return _u return _u
} }
// RemoveAPIKeys removes "api_keys" edges to APIKey entities. // RemoveAPIKeys removes "api_keys" edges to ApiKey entities.
func (_u *GroupUpdateOne) RemoveAPIKeys(v ...*APIKey) *GroupUpdateOne { func (_u *GroupUpdateOne) RemoveAPIKeys(v ...*ApiKey) *GroupUpdateOne {
ids := make([]int64, len(v)) ids := make([]int64, len(v))
for i := range v { for i := range v {
ids[i] = v[i].ID ids[i] = v[i].ID
......
...@@ -9,18 +9,6 @@ import ( ...@@ -9,18 +9,6 @@ import (
"github.com/Wei-Shaw/sub2api/ent" "github.com/Wei-Shaw/sub2api/ent"
) )
// The APIKeyFunc type is an adapter to allow the use of ordinary
// function as APIKey mutator.
type APIKeyFunc func(context.Context, *ent.APIKeyMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f APIKeyFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.APIKeyMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.APIKeyMutation", m)
}
// The AccountFunc type is an adapter to allow the use of ordinary // The AccountFunc type is an adapter to allow the use of ordinary
// function as Account mutator. // function as Account mutator.
type AccountFunc func(context.Context, *ent.AccountMutation) (ent.Value, error) type AccountFunc func(context.Context, *ent.AccountMutation) (ent.Value, error)
...@@ -45,6 +33,18 @@ func (f AccountGroupFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value ...@@ -45,6 +33,18 @@ func (f AccountGroupFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AccountGroupMutation", m) return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AccountGroupMutation", m)
} }
// The ApiKeyFunc type is an adapter to allow the use of ordinary
// function as ApiKey mutator.
type ApiKeyFunc func(context.Context, *ent.ApiKeyMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f ApiKeyFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.ApiKeyMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ApiKeyMutation", m)
}
// The GroupFunc type is an adapter to allow the use of ordinary // The GroupFunc type is an adapter to allow the use of ordinary
// function as Group mutator. // function as Group mutator.
type GroupFunc func(context.Context, *ent.GroupMutation) (ent.Value, error) type GroupFunc func(context.Context, *ent.GroupMutation) (ent.Value, error)
......
...@@ -80,33 +80,6 @@ func (f TraverseFunc) Traverse(ctx context.Context, q ent.Query) error { ...@@ -80,33 +80,6 @@ func (f TraverseFunc) Traverse(ctx context.Context, q ent.Query) error {
return f(ctx, query) return f(ctx, query)
} }
// The APIKeyFunc type is an adapter to allow the use of ordinary function as a Querier.
type APIKeyFunc func(context.Context, *ent.APIKeyQuery) (ent.Value, error)
// Query calls f(ctx, q).
func (f APIKeyFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
if q, ok := q.(*ent.APIKeyQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *ent.APIKeyQuery", q)
}
// The TraverseAPIKey type is an adapter to allow the use of ordinary function as Traverser.
type TraverseAPIKey func(context.Context, *ent.APIKeyQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseAPIKey) Intercept(next ent.Querier) ent.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseAPIKey) Traverse(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.APIKeyQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *ent.APIKeyQuery", q)
}
// The AccountFunc type is an adapter to allow the use of ordinary function as a Querier. // The AccountFunc type is an adapter to allow the use of ordinary function as a Querier.
type AccountFunc func(context.Context, *ent.AccountQuery) (ent.Value, error) type AccountFunc func(context.Context, *ent.AccountQuery) (ent.Value, error)
...@@ -161,6 +134,33 @@ func (f TraverseAccountGroup) Traverse(ctx context.Context, q ent.Query) error { ...@@ -161,6 +134,33 @@ func (f TraverseAccountGroup) Traverse(ctx context.Context, q ent.Query) error {
return fmt.Errorf("unexpected query type %T. expect *ent.AccountGroupQuery", q) return fmt.Errorf("unexpected query type %T. expect *ent.AccountGroupQuery", q)
} }
// The ApiKeyFunc type is an adapter to allow the use of ordinary function as a Querier.
type ApiKeyFunc func(context.Context, *ent.ApiKeyQuery) (ent.Value, error)
// Query calls f(ctx, q).
func (f ApiKeyFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
if q, ok := q.(*ent.ApiKeyQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *ent.ApiKeyQuery", q)
}
// The TraverseApiKey type is an adapter to allow the use of ordinary function as Traverser.
type TraverseApiKey func(context.Context, *ent.ApiKeyQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseApiKey) Intercept(next ent.Querier) ent.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseApiKey) Traverse(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.ApiKeyQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *ent.ApiKeyQuery", q)
}
// The GroupFunc type is an adapter to allow the use of ordinary function as a Querier. // The GroupFunc type is an adapter to allow the use of ordinary function as a Querier.
type GroupFunc func(context.Context, *ent.GroupQuery) (ent.Value, error) type GroupFunc func(context.Context, *ent.GroupQuery) (ent.Value, error)
...@@ -434,12 +434,12 @@ func (f TraverseUserSubscription) Traverse(ctx context.Context, q ent.Query) err ...@@ -434,12 +434,12 @@ func (f TraverseUserSubscription) Traverse(ctx context.Context, q ent.Query) err
// NewQuery returns the generic Query interface for the given typed query. // NewQuery returns the generic Query interface for the given typed query.
func NewQuery(q ent.Query) (Query, error) { func NewQuery(q ent.Query) (Query, error) {
switch q := q.(type) { switch q := q.(type) {
case *ent.APIKeyQuery:
return &query[*ent.APIKeyQuery, predicate.APIKey, apikey.OrderOption]{typ: ent.TypeAPIKey, tq: q}, nil
case *ent.AccountQuery: case *ent.AccountQuery:
return &query[*ent.AccountQuery, predicate.Account, account.OrderOption]{typ: ent.TypeAccount, tq: q}, nil return &query[*ent.AccountQuery, predicate.Account, account.OrderOption]{typ: ent.TypeAccount, tq: q}, nil
case *ent.AccountGroupQuery: case *ent.AccountGroupQuery:
return &query[*ent.AccountGroupQuery, predicate.AccountGroup, accountgroup.OrderOption]{typ: ent.TypeAccountGroup, tq: q}, nil return &query[*ent.AccountGroupQuery, predicate.AccountGroup, accountgroup.OrderOption]{typ: ent.TypeAccountGroup, tq: q}, nil
case *ent.ApiKeyQuery:
return &query[*ent.ApiKeyQuery, predicate.ApiKey, apikey.OrderOption]{typ: ent.TypeApiKey, tq: q}, nil
case *ent.GroupQuery: case *ent.GroupQuery:
return &query[*ent.GroupQuery, predicate.Group, group.OrderOption]{typ: ent.TypeGroup, tq: q}, nil return &query[*ent.GroupQuery, predicate.Group, group.OrderOption]{typ: ent.TypeGroup, tq: q}, nil
case *ent.ProxyQuery: case *ent.ProxyQuery:
......
...@@ -9,60 +9,6 @@ import ( ...@@ -9,60 +9,6 @@ import (
) )
var ( var (
// APIKeysColumns holds the columns for the "api_keys" table.
APIKeysColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true},
{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "timestamptz"}},
{Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "timestamptz"}},
{Name: "deleted_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"postgres": "timestamptz"}},
{Name: "key", Type: field.TypeString, Unique: true, Size: 128},
{Name: "name", Type: field.TypeString, Size: 100},
{Name: "status", Type: field.TypeString, Size: 20, Default: "active"},
{Name: "group_id", Type: field.TypeInt64, Nullable: true},
{Name: "user_id", Type: field.TypeInt64},
}
// APIKeysTable holds the schema information for the "api_keys" table.
APIKeysTable = &schema.Table{
Name: "api_keys",
Columns: APIKeysColumns,
PrimaryKey: []*schema.Column{APIKeysColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "api_keys_groups_api_keys",
Columns: []*schema.Column{APIKeysColumns[7]},
RefColumns: []*schema.Column{GroupsColumns[0]},
OnDelete: schema.SetNull,
},
{
Symbol: "api_keys_users_api_keys",
Columns: []*schema.Column{APIKeysColumns[8]},
RefColumns: []*schema.Column{UsersColumns[0]},
OnDelete: schema.NoAction,
},
},
Indexes: []*schema.Index{
{
Name: "apikey_user_id",
Unique: false,
Columns: []*schema.Column{APIKeysColumns[8]},
},
{
Name: "apikey_group_id",
Unique: false,
Columns: []*schema.Column{APIKeysColumns[7]},
},
{
Name: "apikey_status",
Unique: false,
Columns: []*schema.Column{APIKeysColumns[6]},
},
{
Name: "apikey_deleted_at",
Unique: false,
Columns: []*schema.Column{APIKeysColumns[3]},
},
},
}
// AccountsColumns holds the columns for the "accounts" table. // AccountsColumns holds the columns for the "accounts" table.
AccountsColumns = []*schema.Column{ AccountsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "id", Type: field.TypeInt64, Increment: true},
...@@ -198,6 +144,60 @@ var ( ...@@ -198,6 +144,60 @@ var (
}, },
}, },
} }
// APIKeysColumns holds the columns for the "api_keys" table.
APIKeysColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true},
{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "timestamptz"}},
{Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "timestamptz"}},
{Name: "deleted_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"postgres": "timestamptz"}},
{Name: "key", Type: field.TypeString, Unique: true, Size: 128},
{Name: "name", Type: field.TypeString, Size: 100},
{Name: "status", Type: field.TypeString, Size: 20, Default: "active"},
{Name: "group_id", Type: field.TypeInt64, Nullable: true},
{Name: "user_id", Type: field.TypeInt64},
}
// APIKeysTable holds the schema information for the "api_keys" table.
APIKeysTable = &schema.Table{
Name: "api_keys",
Columns: APIKeysColumns,
PrimaryKey: []*schema.Column{APIKeysColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "api_keys_groups_api_keys",
Columns: []*schema.Column{APIKeysColumns[7]},
RefColumns: []*schema.Column{GroupsColumns[0]},
OnDelete: schema.SetNull,
},
{
Symbol: "api_keys_users_api_keys",
Columns: []*schema.Column{APIKeysColumns[8]},
RefColumns: []*schema.Column{UsersColumns[0]},
OnDelete: schema.NoAction,
},
},
Indexes: []*schema.Index{
{
Name: "apikey_user_id",
Unique: false,
Columns: []*schema.Column{APIKeysColumns[8]},
},
{
Name: "apikey_group_id",
Unique: false,
Columns: []*schema.Column{APIKeysColumns[7]},
},
{
Name: "apikey_status",
Unique: false,
Columns: []*schema.Column{APIKeysColumns[6]},
},
{
Name: "apikey_deleted_at",
Unique: false,
Columns: []*schema.Column{APIKeysColumns[3]},
},
},
}
// GroupsColumns holds the columns for the "groups" table. // GroupsColumns holds the columns for the "groups" table.
GroupsColumns = []*schema.Column{ GroupsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "id", Type: field.TypeInt64, Increment: true},
...@@ -368,8 +368,8 @@ var ( ...@@ -368,8 +368,8 @@ var (
{Name: "duration_ms", Type: field.TypeInt, Nullable: true}, {Name: "duration_ms", Type: field.TypeInt, Nullable: true},
{Name: "first_token_ms", Type: field.TypeInt, Nullable: true}, {Name: "first_token_ms", Type: field.TypeInt, Nullable: true},
{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "timestamptz"}}, {Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "timestamptz"}},
{Name: "api_key_id", Type: field.TypeInt64},
{Name: "account_id", Type: field.TypeInt64}, {Name: "account_id", Type: field.TypeInt64},
{Name: "api_key_id", Type: field.TypeInt64},
{Name: "group_id", Type: field.TypeInt64, Nullable: true}, {Name: "group_id", Type: field.TypeInt64, Nullable: true},
{Name: "user_id", Type: field.TypeInt64}, {Name: "user_id", Type: field.TypeInt64},
{Name: "subscription_id", Type: field.TypeInt64, Nullable: true}, {Name: "subscription_id", Type: field.TypeInt64, Nullable: true},
...@@ -381,15 +381,15 @@ var ( ...@@ -381,15 +381,15 @@ var (
PrimaryKey: []*schema.Column{UsageLogsColumns[0]}, PrimaryKey: []*schema.Column{UsageLogsColumns[0]},
ForeignKeys: []*schema.ForeignKey{ ForeignKeys: []*schema.ForeignKey{
{ {
Symbol: "usage_logs_api_keys_usage_logs", Symbol: "usage_logs_accounts_usage_logs",
Columns: []*schema.Column{UsageLogsColumns[21]}, Columns: []*schema.Column{UsageLogsColumns[21]},
RefColumns: []*schema.Column{APIKeysColumns[0]}, RefColumns: []*schema.Column{AccountsColumns[0]},
OnDelete: schema.NoAction, OnDelete: schema.NoAction,
}, },
{ {
Symbol: "usage_logs_accounts_usage_logs", Symbol: "usage_logs_api_keys_usage_logs",
Columns: []*schema.Column{UsageLogsColumns[22]}, Columns: []*schema.Column{UsageLogsColumns[22]},
RefColumns: []*schema.Column{AccountsColumns[0]}, RefColumns: []*schema.Column{APIKeysColumns[0]},
OnDelete: schema.NoAction, OnDelete: schema.NoAction,
}, },
{ {
...@@ -420,12 +420,12 @@ var ( ...@@ -420,12 +420,12 @@ var (
{ {
Name: "usagelog_api_key_id", Name: "usagelog_api_key_id",
Unique: false, Unique: false,
Columns: []*schema.Column{UsageLogsColumns[21]}, Columns: []*schema.Column{UsageLogsColumns[22]},
}, },
{ {
Name: "usagelog_account_id", Name: "usagelog_account_id",
Unique: false, Unique: false,
Columns: []*schema.Column{UsageLogsColumns[22]}, Columns: []*schema.Column{UsageLogsColumns[21]},
}, },
{ {
Name: "usagelog_group_id", Name: "usagelog_group_id",
...@@ -460,7 +460,7 @@ var ( ...@@ -460,7 +460,7 @@ var (
{ {
Name: "usagelog_api_key_id_created_at", Name: "usagelog_api_key_id_created_at",
Unique: false, Unique: false,
Columns: []*schema.Column{UsageLogsColumns[21], UsageLogsColumns[20]}, Columns: []*schema.Column{UsageLogsColumns[22], UsageLogsColumns[20]},
}, },
}, },
} }
...@@ -702,9 +702,9 @@ var ( ...@@ -702,9 +702,9 @@ var (
} }
// Tables holds all the tables in the schema. // Tables holds all the tables in the schema.
Tables = []*schema.Table{ Tables = []*schema.Table{
APIKeysTable,
AccountsTable, AccountsTable,
AccountGroupsTable, AccountGroupsTable,
APIKeysTable,
GroupsTable, GroupsTable,
ProxiesTable, ProxiesTable,
RedeemCodesTable, RedeemCodesTable,
...@@ -719,11 +719,6 @@ var ( ...@@ -719,11 +719,6 @@ var (
) )
func init() { func init() {
APIKeysTable.ForeignKeys[0].RefTable = GroupsTable
APIKeysTable.ForeignKeys[1].RefTable = UsersTable
APIKeysTable.Annotation = &entsql.Annotation{
Table: "api_keys",
}
AccountsTable.ForeignKeys[0].RefTable = ProxiesTable AccountsTable.ForeignKeys[0].RefTable = ProxiesTable
AccountsTable.Annotation = &entsql.Annotation{ AccountsTable.Annotation = &entsql.Annotation{
Table: "accounts", Table: "accounts",
...@@ -733,6 +728,11 @@ func init() { ...@@ -733,6 +728,11 @@ func init() {
AccountGroupsTable.Annotation = &entsql.Annotation{ AccountGroupsTable.Annotation = &entsql.Annotation{
Table: "account_groups", Table: "account_groups",
} }
APIKeysTable.ForeignKeys[0].RefTable = GroupsTable
APIKeysTable.ForeignKeys[1].RefTable = UsersTable
APIKeysTable.Annotation = &entsql.Annotation{
Table: "api_keys",
}
GroupsTable.Annotation = &entsql.Annotation{ GroupsTable.Annotation = &entsql.Annotation{
Table: "groups", Table: "groups",
} }
...@@ -747,8 +747,8 @@ func init() { ...@@ -747,8 +747,8 @@ func init() {
SettingsTable.Annotation = &entsql.Annotation{ SettingsTable.Annotation = &entsql.Annotation{
Table: "settings", Table: "settings",
} }
UsageLogsTable.ForeignKeys[0].RefTable = APIKeysTable UsageLogsTable.ForeignKeys[0].RefTable = AccountsTable
UsageLogsTable.ForeignKeys[1].RefTable = AccountsTable UsageLogsTable.ForeignKeys[1].RefTable = APIKeysTable
UsageLogsTable.ForeignKeys[2].RefTable = GroupsTable UsageLogsTable.ForeignKeys[2].RefTable = GroupsTable
UsageLogsTable.ForeignKeys[3].RefTable = UsersTable UsageLogsTable.ForeignKeys[3].RefTable = UsersTable
UsageLogsTable.ForeignKeys[4].RefTable = UserSubscriptionsTable UsageLogsTable.ForeignKeys[4].RefTable = UserSubscriptionsTable
......
This diff is collapsed.
...@@ -6,15 +6,15 @@ import ( ...@@ -6,15 +6,15 @@ import (
"entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql"
) )
// APIKey is the predicate function for apikey builders.
type APIKey func(*sql.Selector)
// Account is the predicate function for account builders. // Account is the predicate function for account builders.
type Account func(*sql.Selector) type Account func(*sql.Selector)
// AccountGroup is the predicate function for accountgroup builders. // AccountGroup is the predicate function for accountgroup builders.
type AccountGroup func(*sql.Selector) type AccountGroup func(*sql.Selector)
// ApiKey is the predicate function for apikey builders.
type ApiKey func(*sql.Selector)
// Group is the predicate function for group builders. // Group is the predicate function for group builders.
type Group func(*sql.Selector) type Group func(*sql.Selector)
......
...@@ -25,67 +25,6 @@ import ( ...@@ -25,67 +25,6 @@ import (
// (default values, validators, hooks and policies) and stitches it // (default values, validators, hooks and policies) and stitches it
// to their package variables. // to their package variables.
func init() { func init() {
apikeyMixin := schema.APIKey{}.Mixin()
apikeyMixinHooks1 := apikeyMixin[1].Hooks()
apikey.Hooks[0] = apikeyMixinHooks1[0]
apikeyMixinInters1 := apikeyMixin[1].Interceptors()
apikey.Interceptors[0] = apikeyMixinInters1[0]
apikeyMixinFields0 := apikeyMixin[0].Fields()
_ = apikeyMixinFields0
apikeyFields := schema.APIKey{}.Fields()
_ = apikeyFields
// apikeyDescCreatedAt is the schema descriptor for created_at field.
apikeyDescCreatedAt := apikeyMixinFields0[0].Descriptor()
// apikey.DefaultCreatedAt holds the default value on creation for the created_at field.
apikey.DefaultCreatedAt = apikeyDescCreatedAt.Default.(func() time.Time)
// apikeyDescUpdatedAt is the schema descriptor for updated_at field.
apikeyDescUpdatedAt := apikeyMixinFields0[1].Descriptor()
// apikey.DefaultUpdatedAt holds the default value on creation for the updated_at field.
apikey.DefaultUpdatedAt = apikeyDescUpdatedAt.Default.(func() time.Time)
// apikey.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
apikey.UpdateDefaultUpdatedAt = apikeyDescUpdatedAt.UpdateDefault.(func() time.Time)
// apikeyDescKey is the schema descriptor for key field.
apikeyDescKey := apikeyFields[1].Descriptor()
// apikey.KeyValidator is a validator for the "key" field. It is called by the builders before save.
apikey.KeyValidator = func() func(string) error {
validators := apikeyDescKey.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(key string) error {
for _, fn := range fns {
if err := fn(key); err != nil {
return err
}
}
return nil
}
}()
// apikeyDescName is the schema descriptor for name field.
apikeyDescName := apikeyFields[2].Descriptor()
// apikey.NameValidator is a validator for the "name" field. It is called by the builders before save.
apikey.NameValidator = func() func(string) error {
validators := apikeyDescName.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(name string) error {
for _, fn := range fns {
if err := fn(name); err != nil {
return err
}
}
return nil
}
}()
// apikeyDescStatus is the schema descriptor for status field.
apikeyDescStatus := apikeyFields[4].Descriptor()
// apikey.DefaultStatus holds the default value on creation for the status field.
apikey.DefaultStatus = apikeyDescStatus.Default.(string)
// apikey.StatusValidator is a validator for the "status" field. It is called by the builders before save.
apikey.StatusValidator = apikeyDescStatus.Validators[0].(func(string) error)
accountMixin := schema.Account{}.Mixin() accountMixin := schema.Account{}.Mixin()
accountMixinHooks1 := accountMixin[1].Hooks() accountMixinHooks1 := accountMixin[1].Hooks()
account.Hooks[0] = accountMixinHooks1[0] account.Hooks[0] = accountMixinHooks1[0]
...@@ -199,6 +138,67 @@ func init() { ...@@ -199,6 +138,67 @@ func init() {
accountgroupDescCreatedAt := accountgroupFields[3].Descriptor() accountgroupDescCreatedAt := accountgroupFields[3].Descriptor()
// accountgroup.DefaultCreatedAt holds the default value on creation for the created_at field. // accountgroup.DefaultCreatedAt holds the default value on creation for the created_at field.
accountgroup.DefaultCreatedAt = accountgroupDescCreatedAt.Default.(func() time.Time) accountgroup.DefaultCreatedAt = accountgroupDescCreatedAt.Default.(func() time.Time)
apikeyMixin := schema.ApiKey{}.Mixin()
apikeyMixinHooks1 := apikeyMixin[1].Hooks()
apikey.Hooks[0] = apikeyMixinHooks1[0]
apikeyMixinInters1 := apikeyMixin[1].Interceptors()
apikey.Interceptors[0] = apikeyMixinInters1[0]
apikeyMixinFields0 := apikeyMixin[0].Fields()
_ = apikeyMixinFields0
apikeyFields := schema.ApiKey{}.Fields()
_ = apikeyFields
// apikeyDescCreatedAt is the schema descriptor for created_at field.
apikeyDescCreatedAt := apikeyMixinFields0[0].Descriptor()
// apikey.DefaultCreatedAt holds the default value on creation for the created_at field.
apikey.DefaultCreatedAt = apikeyDescCreatedAt.Default.(func() time.Time)
// apikeyDescUpdatedAt is the schema descriptor for updated_at field.
apikeyDescUpdatedAt := apikeyMixinFields0[1].Descriptor()
// apikey.DefaultUpdatedAt holds the default value on creation for the updated_at field.
apikey.DefaultUpdatedAt = apikeyDescUpdatedAt.Default.(func() time.Time)
// apikey.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
apikey.UpdateDefaultUpdatedAt = apikeyDescUpdatedAt.UpdateDefault.(func() time.Time)
// apikeyDescKey is the schema descriptor for key field.
apikeyDescKey := apikeyFields[1].Descriptor()
// apikey.KeyValidator is a validator for the "key" field. It is called by the builders before save.
apikey.KeyValidator = func() func(string) error {
validators := apikeyDescKey.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(key string) error {
for _, fn := range fns {
if err := fn(key); err != nil {
return err
}
}
return nil
}
}()
// apikeyDescName is the schema descriptor for name field.
apikeyDescName := apikeyFields[2].Descriptor()
// apikey.NameValidator is a validator for the "name" field. It is called by the builders before save.
apikey.NameValidator = func() func(string) error {
validators := apikeyDescName.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(name string) error {
for _, fn := range fns {
if err := fn(name); err != nil {
return err
}
}
return nil
}
}()
// apikeyDescStatus is the schema descriptor for status field.
apikeyDescStatus := apikeyFields[4].Descriptor()
// apikey.DefaultStatus holds the default value on creation for the status field.
apikey.DefaultStatus = apikeyDescStatus.Default.(string)
// apikey.StatusValidator is a validator for the "status" field. It is called by the builders before save.
apikey.StatusValidator = apikeyDescStatus.Validators[0].(func(string) error)
groupMixin := schema.Group{}.Mixin() groupMixin := schema.Group{}.Mixin()
groupMixinHooks1 := groupMixin[1].Hooks() groupMixinHooks1 := groupMixin[1].Hooks()
group.Hooks[0] = groupMixinHooks1[0] group.Hooks[0] = groupMixinHooks1[0]
......
...@@ -12,25 +12,25 @@ import ( ...@@ -12,25 +12,25 @@ import (
"entgo.io/ent/schema/index" "entgo.io/ent/schema/index"
) )
// APIKey holds the schema definition for the APIKey entity. // ApiKey holds the schema definition for the ApiKey entity.
type APIKey struct { type ApiKey struct {
ent.Schema ent.Schema
} }
func (APIKey) Annotations() []schema.Annotation { func (ApiKey) Annotations() []schema.Annotation {
return []schema.Annotation{ return []schema.Annotation{
entsql.Annotation{Table: "api_keys"}, entsql.Annotation{Table: "api_keys"},
} }
} }
func (APIKey) Mixin() []ent.Mixin { func (ApiKey) Mixin() []ent.Mixin {
return []ent.Mixin{ return []ent.Mixin{
mixins.TimeMixin{}, mixins.TimeMixin{},
mixins.SoftDeleteMixin{}, mixins.SoftDeleteMixin{},
} }
} }
func (APIKey) Fields() []ent.Field { func (ApiKey) Fields() []ent.Field {
return []ent.Field{ return []ent.Field{
field.Int64("user_id"), field.Int64("user_id"),
field.String("key"). field.String("key").
...@@ -49,7 +49,7 @@ func (APIKey) Fields() []ent.Field { ...@@ -49,7 +49,7 @@ func (APIKey) Fields() []ent.Field {
} }
} }
func (APIKey) Edges() []ent.Edge { func (ApiKey) Edges() []ent.Edge {
return []ent.Edge{ return []ent.Edge{
edge.From("user", User.Type). edge.From("user", User.Type).
Ref("api_keys"). Ref("api_keys").
...@@ -64,7 +64,7 @@ func (APIKey) Edges() []ent.Edge { ...@@ -64,7 +64,7 @@ func (APIKey) Edges() []ent.Edge {
} }
} }
func (APIKey) Indexes() []ent.Index { func (ApiKey) Indexes() []ent.Index {
return []ent.Index{ return []ent.Index{
// key 字段已在 Fields() 中声明 Unique(),无需重复索引 // key 字段已在 Fields() 中声明 Unique(),无需重复索引
index.Fields("user_id"), index.Fields("user_id"),
......
...@@ -77,7 +77,7 @@ func (Group) Fields() []ent.Field { ...@@ -77,7 +77,7 @@ func (Group) Fields() []ent.Field {
func (Group) Edges() []ent.Edge { func (Group) Edges() []ent.Edge {
return []ent.Edge{ return []ent.Edge{
edge.To("api_keys", APIKey.Type), edge.To("api_keys", ApiKey.Type),
edge.To("redeem_codes", RedeemCode.Type), edge.To("redeem_codes", RedeemCode.Type),
edge.To("subscriptions", UserSubscription.Type), edge.To("subscriptions", UserSubscription.Type),
edge.To("usage_logs", UsageLog.Type), edge.To("usage_logs", UsageLog.Type),
......
...@@ -113,7 +113,7 @@ func (UsageLog) Edges() []ent.Edge { ...@@ -113,7 +113,7 @@ func (UsageLog) Edges() []ent.Edge {
Field("user_id"). Field("user_id").
Required(). Required().
Unique(), Unique(),
edge.From("api_key", APIKey.Type). edge.From("api_key", ApiKey.Type).
Ref("usage_logs"). Ref("usage_logs").
Field("api_key_id"). Field("api_key_id").
Required(). Required().
......
...@@ -66,7 +66,7 @@ func (User) Fields() []ent.Field { ...@@ -66,7 +66,7 @@ func (User) Fields() []ent.Field {
func (User) Edges() []ent.Edge { func (User) Edges() []ent.Edge {
return []ent.Edge{ return []ent.Edge{
edge.To("api_keys", APIKey.Type), edge.To("api_keys", ApiKey.Type),
edge.To("redeem_codes", RedeemCode.Type), edge.To("redeem_codes", RedeemCode.Type),
edge.To("subscriptions", UserSubscription.Type), edge.To("subscriptions", UserSubscription.Type),
edge.To("assigned_subscriptions", UserSubscription.Type), edge.To("assigned_subscriptions", UserSubscription.Type),
......
...@@ -14,12 +14,12 @@ import ( ...@@ -14,12 +14,12 @@ import (
// Tx is a transactional client that is created by calling Client.Tx(). // Tx is a transactional client that is created by calling Client.Tx().
type Tx struct { type Tx struct {
config config
// APIKey is the client for interacting with the APIKey builders.
APIKey *APIKeyClient
// Account is the client for interacting with the Account builders. // Account is the client for interacting with the Account builders.
Account *AccountClient Account *AccountClient
// AccountGroup is the client for interacting with the AccountGroup builders. // AccountGroup is the client for interacting with the AccountGroup builders.
AccountGroup *AccountGroupClient AccountGroup *AccountGroupClient
// ApiKey is the client for interacting with the ApiKey builders.
ApiKey *ApiKeyClient
// Group is the client for interacting with the Group builders. // Group is the client for interacting with the Group builders.
Group *GroupClient Group *GroupClient
// Proxy is the client for interacting with the Proxy builders. // Proxy is the client for interacting with the Proxy builders.
...@@ -171,9 +171,9 @@ func (tx *Tx) Client() *Client { ...@@ -171,9 +171,9 @@ func (tx *Tx) Client() *Client {
} }
func (tx *Tx) init() { func (tx *Tx) init() {
tx.APIKey = NewAPIKeyClient(tx.config)
tx.Account = NewAccountClient(tx.config) tx.Account = NewAccountClient(tx.config)
tx.AccountGroup = NewAccountGroupClient(tx.config) tx.AccountGroup = NewAccountGroupClient(tx.config)
tx.ApiKey = NewApiKeyClient(tx.config)
tx.Group = NewGroupClient(tx.config) tx.Group = NewGroupClient(tx.config)
tx.Proxy = NewProxyClient(tx.config) tx.Proxy = NewProxyClient(tx.config)
tx.RedeemCode = NewRedeemCodeClient(tx.config) tx.RedeemCode = NewRedeemCodeClient(tx.config)
...@@ -193,7 +193,7 @@ func (tx *Tx) init() { ...@@ -193,7 +193,7 @@ func (tx *Tx) init() {
// of them in order to commit or rollback the transaction. // of them in order to commit or rollback the transaction.
// //
// If a closed transaction is embedded in one of the generated entities, and the entity // If a closed transaction is embedded in one of the generated entities, and the entity
// applies a query, for example: APIKey.QueryXXX(), the query will be executed // applies a query, for example: Account.QueryXXX(), the query will be executed
// through the driver which created this transaction. // through the driver which created this transaction.
// //
// Note that txDriver is not goroutine safe. // Note that txDriver is not goroutine safe.
......
...@@ -83,7 +83,7 @@ type UsageLogEdges struct { ...@@ -83,7 +83,7 @@ type UsageLogEdges struct {
// User holds the value of the user edge. // User holds the value of the user edge.
User *User `json:"user,omitempty"` User *User `json:"user,omitempty"`
// APIKey holds the value of the api_key edge. // APIKey holds the value of the api_key edge.
APIKey *APIKey `json:"api_key,omitempty"` APIKey *ApiKey `json:"api_key,omitempty"`
// Account holds the value of the account edge. // Account holds the value of the account edge.
Account *Account `json:"account,omitempty"` Account *Account `json:"account,omitempty"`
// Group holds the value of the group edge. // Group holds the value of the group edge.
...@@ -108,7 +108,7 @@ func (e UsageLogEdges) UserOrErr() (*User, error) { ...@@ -108,7 +108,7 @@ func (e UsageLogEdges) UserOrErr() (*User, error) {
// APIKeyOrErr returns the APIKey value or an error if the edge // APIKeyOrErr returns the APIKey value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found. // was not loaded in eager-loading, or loaded but was not found.
func (e UsageLogEdges) APIKeyOrErr() (*APIKey, error) { func (e UsageLogEdges) APIKeyOrErr() (*ApiKey, error) {
if e.APIKey != nil { if e.APIKey != nil {
return e.APIKey, nil return e.APIKey, nil
} else if e.loadedTypes[1] { } else if e.loadedTypes[1] {
...@@ -359,7 +359,7 @@ func (_m *UsageLog) QueryUser() *UserQuery { ...@@ -359,7 +359,7 @@ func (_m *UsageLog) QueryUser() *UserQuery {
} }
// QueryAPIKey queries the "api_key" edge of the UsageLog entity. // QueryAPIKey queries the "api_key" edge of the UsageLog entity.
func (_m *UsageLog) QueryAPIKey() *APIKeyQuery { func (_m *UsageLog) QueryAPIKey() *ApiKeyQuery {
return NewUsageLogClient(_m.config).QueryAPIKey(_m) return NewUsageLogClient(_m.config).QueryAPIKey(_m)
} }
......
...@@ -85,7 +85,7 @@ const ( ...@@ -85,7 +85,7 @@ const (
UserColumn = "user_id" UserColumn = "user_id"
// APIKeyTable is the table that holds the api_key relation/edge. // APIKeyTable is the table that holds the api_key relation/edge.
APIKeyTable = "usage_logs" APIKeyTable = "usage_logs"
// APIKeyInverseTable is the table name for the APIKey entity. // APIKeyInverseTable is the table name for the ApiKey entity.
// It exists in this package in order to avoid circular dependency with the "apikey" package. // It exists in this package in order to avoid circular dependency with the "apikey" package.
APIKeyInverseTable = "api_keys" APIKeyInverseTable = "api_keys"
// APIKeyColumn is the table column denoting the api_key relation/edge. // APIKeyColumn is the table column denoting the api_key relation/edge.
......
...@@ -1175,7 +1175,7 @@ func HasAPIKey() predicate.UsageLog { ...@@ -1175,7 +1175,7 @@ func HasAPIKey() predicate.UsageLog {
} }
// HasAPIKeyWith applies the HasEdge predicate on the "api_key" edge with a given conditions (other predicates). // HasAPIKeyWith applies the HasEdge predicate on the "api_key" edge with a given conditions (other predicates).
func HasAPIKeyWith(preds ...predicate.APIKey) predicate.UsageLog { func HasAPIKeyWith(preds ...predicate.ApiKey) predicate.UsageLog {
return predicate.UsageLog(func(s *sql.Selector) { return predicate.UsageLog(func(s *sql.Selector) {
step := newAPIKeyStep() step := newAPIKeyStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
......
...@@ -342,8 +342,8 @@ func (_c *UsageLogCreate) SetUser(v *User) *UsageLogCreate { ...@@ -342,8 +342,8 @@ func (_c *UsageLogCreate) SetUser(v *User) *UsageLogCreate {
return _c.SetUserID(v.ID) return _c.SetUserID(v.ID)
} }
// SetAPIKey sets the "api_key" edge to the APIKey entity. // SetAPIKey sets the "api_key" edge to the ApiKey entity.
func (_c *UsageLogCreate) SetAPIKey(v *APIKey) *UsageLogCreate { func (_c *UsageLogCreate) SetAPIKey(v *ApiKey) *UsageLogCreate {
return _c.SetAPIKeyID(v.ID) return _c.SetAPIKeyID(v.ID)
} }
......
...@@ -28,7 +28,7 @@ type UsageLogQuery struct { ...@@ -28,7 +28,7 @@ type UsageLogQuery struct {
inters []Interceptor inters []Interceptor
predicates []predicate.UsageLog predicates []predicate.UsageLog
withUser *UserQuery withUser *UserQuery
withAPIKey *APIKeyQuery withAPIKey *ApiKeyQuery
withAccount *AccountQuery withAccount *AccountQuery
withGroup *GroupQuery withGroup *GroupQuery
withSubscription *UserSubscriptionQuery withSubscription *UserSubscriptionQuery
...@@ -91,8 +91,8 @@ func (_q *UsageLogQuery) QueryUser() *UserQuery { ...@@ -91,8 +91,8 @@ func (_q *UsageLogQuery) QueryUser() *UserQuery {
} }
// QueryAPIKey chains the current query on the "api_key" edge. // QueryAPIKey chains the current query on the "api_key" edge.
func (_q *UsageLogQuery) QueryAPIKey() *APIKeyQuery { func (_q *UsageLogQuery) QueryAPIKey() *ApiKeyQuery {
query := (&APIKeyClient{config: _q.config}).Query() query := (&ApiKeyClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil { if err := _q.prepareQuery(ctx); err != nil {
return nil, err return nil, err
...@@ -394,8 +394,8 @@ func (_q *UsageLogQuery) WithUser(opts ...func(*UserQuery)) *UsageLogQuery { ...@@ -394,8 +394,8 @@ func (_q *UsageLogQuery) WithUser(opts ...func(*UserQuery)) *UsageLogQuery {
// WithAPIKey tells the query-builder to eager-load the nodes that are connected to // WithAPIKey tells the query-builder to eager-load the nodes that are connected to
// the "api_key" edge. The optional arguments are used to configure the query builder of the edge. // the "api_key" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *UsageLogQuery) WithAPIKey(opts ...func(*APIKeyQuery)) *UsageLogQuery { func (_q *UsageLogQuery) WithAPIKey(opts ...func(*ApiKeyQuery)) *UsageLogQuery {
query := (&APIKeyClient{config: _q.config}).Query() query := (&ApiKeyClient{config: _q.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
...@@ -548,7 +548,7 @@ func (_q *UsageLogQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Usa ...@@ -548,7 +548,7 @@ func (_q *UsageLogQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Usa
} }
if query := _q.withAPIKey; query != nil { if query := _q.withAPIKey; query != nil {
if err := _q.loadAPIKey(ctx, query, nodes, nil, if err := _q.loadAPIKey(ctx, query, nodes, nil,
func(n *UsageLog, e *APIKey) { n.Edges.APIKey = e }); err != nil { func(n *UsageLog, e *ApiKey) { n.Edges.APIKey = e }); err != nil {
return nil, err return nil, err
} }
} }
...@@ -602,7 +602,7 @@ func (_q *UsageLogQuery) loadUser(ctx context.Context, query *UserQuery, nodes [ ...@@ -602,7 +602,7 @@ func (_q *UsageLogQuery) loadUser(ctx context.Context, query *UserQuery, nodes [
} }
return nil return nil
} }
func (_q *UsageLogQuery) loadAPIKey(ctx context.Context, query *APIKeyQuery, nodes []*UsageLog, init func(*UsageLog), assign func(*UsageLog, *APIKey)) error { func (_q *UsageLogQuery) loadAPIKey(ctx context.Context, query *ApiKeyQuery, nodes []*UsageLog, init func(*UsageLog), assign func(*UsageLog, *ApiKey)) error {
ids := make([]int64, 0, len(nodes)) ids := make([]int64, 0, len(nodes))
nodeids := make(map[int64][]*UsageLog) nodeids := make(map[int64][]*UsageLog)
for i := range nodes { for i := range nodes {
......
...@@ -509,8 +509,8 @@ func (_u *UsageLogUpdate) SetUser(v *User) *UsageLogUpdate { ...@@ -509,8 +509,8 @@ func (_u *UsageLogUpdate) SetUser(v *User) *UsageLogUpdate {
return _u.SetUserID(v.ID) return _u.SetUserID(v.ID)
} }
// SetAPIKey sets the "api_key" edge to the APIKey entity. // SetAPIKey sets the "api_key" edge to the ApiKey entity.
func (_u *UsageLogUpdate) SetAPIKey(v *APIKey) *UsageLogUpdate { func (_u *UsageLogUpdate) SetAPIKey(v *ApiKey) *UsageLogUpdate {
return _u.SetAPIKeyID(v.ID) return _u.SetAPIKeyID(v.ID)
} }
...@@ -540,7 +540,7 @@ func (_u *UsageLogUpdate) ClearUser() *UsageLogUpdate { ...@@ -540,7 +540,7 @@ func (_u *UsageLogUpdate) ClearUser() *UsageLogUpdate {
return _u return _u
} }
// ClearAPIKey clears the "api_key" edge to the APIKey entity. // ClearAPIKey clears the "api_key" edge to the ApiKey entity.
func (_u *UsageLogUpdate) ClearAPIKey() *UsageLogUpdate { func (_u *UsageLogUpdate) ClearAPIKey() *UsageLogUpdate {
_u.mutation.ClearAPIKey() _u.mutation.ClearAPIKey()
return _u return _u
...@@ -1380,8 +1380,8 @@ func (_u *UsageLogUpdateOne) SetUser(v *User) *UsageLogUpdateOne { ...@@ -1380,8 +1380,8 @@ func (_u *UsageLogUpdateOne) SetUser(v *User) *UsageLogUpdateOne {
return _u.SetUserID(v.ID) return _u.SetUserID(v.ID)
} }
// SetAPIKey sets the "api_key" edge to the APIKey entity. // SetAPIKey sets the "api_key" edge to the ApiKey entity.
func (_u *UsageLogUpdateOne) SetAPIKey(v *APIKey) *UsageLogUpdateOne { func (_u *UsageLogUpdateOne) SetAPIKey(v *ApiKey) *UsageLogUpdateOne {
return _u.SetAPIKeyID(v.ID) return _u.SetAPIKeyID(v.ID)
} }
...@@ -1411,7 +1411,7 @@ func (_u *UsageLogUpdateOne) ClearUser() *UsageLogUpdateOne { ...@@ -1411,7 +1411,7 @@ func (_u *UsageLogUpdateOne) ClearUser() *UsageLogUpdateOne {
return _u return _u
} }
// ClearAPIKey clears the "api_key" edge to the APIKey entity. // ClearAPIKey clears the "api_key" edge to the ApiKey entity.
func (_u *UsageLogUpdateOne) ClearAPIKey() *UsageLogUpdateOne { func (_u *UsageLogUpdateOne) ClearAPIKey() *UsageLogUpdateOne {
_u.mutation.ClearAPIKey() _u.mutation.ClearAPIKey()
return _u return _u
......
...@@ -48,7 +48,7 @@ type User struct { ...@@ -48,7 +48,7 @@ type User struct {
// UserEdges holds the relations/edges for other nodes in the graph. // UserEdges holds the relations/edges for other nodes in the graph.
type UserEdges struct { type UserEdges struct {
// APIKeys holds the value of the api_keys edge. // APIKeys holds the value of the api_keys edge.
APIKeys []*APIKey `json:"api_keys,omitempty"` APIKeys []*ApiKey `json:"api_keys,omitempty"`
// RedeemCodes holds the value of the redeem_codes edge. // RedeemCodes holds the value of the redeem_codes edge.
RedeemCodes []*RedeemCode `json:"redeem_codes,omitempty"` RedeemCodes []*RedeemCode `json:"redeem_codes,omitempty"`
// Subscriptions holds the value of the subscriptions edge. // Subscriptions holds the value of the subscriptions edge.
...@@ -70,7 +70,7 @@ type UserEdges struct { ...@@ -70,7 +70,7 @@ type UserEdges struct {
// APIKeysOrErr returns the APIKeys value or an error if the edge // APIKeysOrErr returns the APIKeys value or an error if the edge
// was not loaded in eager-loading. // was not loaded in eager-loading.
func (e UserEdges) APIKeysOrErr() ([]*APIKey, error) { func (e UserEdges) APIKeysOrErr() ([]*ApiKey, error) {
if e.loadedTypes[0] { if e.loadedTypes[0] {
return e.APIKeys, nil return e.APIKeys, nil
} }
...@@ -255,7 +255,7 @@ func (_m *User) Value(name string) (ent.Value, error) { ...@@ -255,7 +255,7 @@ func (_m *User) Value(name string) (ent.Value, error) {
} }
// QueryAPIKeys queries the "api_keys" edge of the User entity. // QueryAPIKeys queries the "api_keys" edge of the User entity.
func (_m *User) QueryAPIKeys() *APIKeyQuery { func (_m *User) QueryAPIKeys() *ApiKeyQuery {
return NewUserClient(_m.config).QueryAPIKeys(_m) return NewUserClient(_m.config).QueryAPIKeys(_m)
} }
......
...@@ -57,7 +57,7 @@ const ( ...@@ -57,7 +57,7 @@ const (
Table = "users" Table = "users"
// APIKeysTable is the table that holds the api_keys relation/edge. // APIKeysTable is the table that holds the api_keys relation/edge.
APIKeysTable = "api_keys" APIKeysTable = "api_keys"
// APIKeysInverseTable is the table name for the APIKey entity. // APIKeysInverseTable is the table name for the ApiKey entity.
// It exists in this package in order to avoid circular dependency with the "apikey" package. // It exists in this package in order to avoid circular dependency with the "apikey" package.
APIKeysInverseTable = "api_keys" APIKeysInverseTable = "api_keys"
// APIKeysColumn is the table column denoting the api_keys relation/edge. // APIKeysColumn is the table column denoting the api_keys relation/edge.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment