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
...@@ -48,6 +48,7 @@ pnpm-debug.log* ...@@ -48,6 +48,7 @@ pnpm-debug.log*
.env.*.local .env.*.local
*.env *.env
!.env.example !.env.example
docker-compose.override.yml
# =================== # ===================
# IDE / 编辑器 # IDE / 编辑器
...@@ -78,8 +79,6 @@ temp/ ...@@ -78,8 +79,6 @@ temp/
*.log *.log
*.bak *.bak
.cache/ .cache/
.gemini-clipboard/
migrations/
# =================== # ===================
# 构建产物 # 构建产物
...@@ -121,3 +120,4 @@ code-reviews/ ...@@ -121,3 +120,4 @@ code-reviews/
AGENTS.md AGENTS.md
backend/cmd/server/server backend/cmd/server/server
deploy/docker-compose.override.yml deploy/docker-compose.override.yml
.gocache/
...@@ -297,6 +297,16 @@ go generate ./cmd/server ...@@ -297,6 +297,16 @@ go generate ./cmd/server
--- ---
## Simple Mode
Simple Mode is designed for individual developers or internal teams who want quick access without full SaaS features.
- Enable: Set environment variable `RUN_MODE=simple`
- Difference: Hides SaaS-related features and skips billing process
- Security note: In production, you must also set `SIMPLE_MODE_CONFIRM=true` to allow startup
---
## Antigravity Support ## Antigravity Support
Sub2API supports [Antigravity](https://antigravity.so/) accounts. After authorization, dedicated endpoints are available for Claude and Gemini models. Sub2API supports [Antigravity](https://antigravity.so/) accounts. After authorization, dedicated endpoints are available for Claude and Gemini models.
...@@ -321,6 +331,12 @@ Antigravity accounts support optional **hybrid scheduling**. When enabled, the g ...@@ -321,6 +331,12 @@ Antigravity accounts support optional **hybrid scheduling**. When enabled, the g
> **⚠️ Warning**: Anthropic Claude and Antigravity Claude **cannot be mixed within the same conversation context**. Use groups to isolate them properly. > **⚠️ Warning**: Anthropic Claude and Antigravity Claude **cannot be mixed within the same conversation context**. Use groups to isolate them properly.
### Known Issues
In Claude Code, Plan Mode cannot exit automatically. (Normally when using the native Claude API, after planning is complete, Claude Code will pop up options for users to approve or reject the plan.)
**Workaround**: Press `Shift + Tab` to manually exit Plan Mode, then type your response to approve or reject the plan.
--- ---
## Project Structure ## Project Structure
......
...@@ -331,6 +331,10 @@ Antigravity 账户支持可选的**混合调度**功能。开启后,通用端 ...@@ -331,6 +331,10 @@ Antigravity 账户支持可选的**混合调度**功能。开启后,通用端
> **⚠️ 注意**:Anthropic Claude 和 Antigravity Claude **不能在同一上下文中混合使用**,请通过分组功能做好隔离。 > **⚠️ 注意**:Anthropic Claude 和 Antigravity Claude **不能在同一上下文中混合使用**,请通过分组功能做好隔离。
### 已知问题
在 Claude Code 中,无法自动退出Plan Mode。(正常使用原生Claude Api时,Plan 完成后,Claude Code会弹出弹出选项让用户同意或拒绝Plan。)
解决办法:shift + Tab,手动退出Plan mode,然后输入内容 告诉 Claude Code 同意或拒绝 Plan
--- ---
## 项目结构 ## 项目结构
......
...@@ -70,13 +70,7 @@ func provideCleanup( ...@@ -70,13 +70,7 @@ func provideCleanup(
openaiOAuth *service.OpenAIOAuthService, openaiOAuth *service.OpenAIOAuthService,
geminiOAuth *service.GeminiOAuthService, geminiOAuth *service.GeminiOAuthService,
antigravityOAuth *service.AntigravityOAuthService, antigravityOAuth *service.AntigravityOAuthService,
antigravityQuota *service.AntigravityQuotaRefresher,
opsMetricsCollector *service.OpsMetricsCollector,
opsAlertService *service.OpsAlertService,
) func() { ) func() {
if opsAlertService != nil {
opsAlertService.Start()
}
return func() { return func() {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel() defer cancel()
...@@ -86,14 +80,6 @@ func provideCleanup( ...@@ -86,14 +80,6 @@ func provideCleanup(
name string name string
fn func() error fn func() error
}{ }{
{"OpsMetricsCollector", func() error {
opsMetricsCollector.Stop()
return nil
}},
{"OpsAlertService", func() error {
opsAlertService.Stop()
return nil
}},
{"TokenRefreshService", func() error { {"TokenRefreshService", func() error {
tokenRefresh.Stop() tokenRefresh.Stop()
return nil return nil
...@@ -126,10 +112,6 @@ func provideCleanup( ...@@ -126,10 +112,6 @@ func provideCleanup(
antigravityOAuth.Stop() antigravityOAuth.Stop()
return nil return nil
}}, }},
{"AntigravityQuotaRefresher", func() error {
antigravityQuota.Stop()
return nil
}},
{"Redis", func() error { {"Redis", func() error {
return rdb.Close() return rdb.Close()
}}, }},
......
...@@ -55,11 +55,11 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) { ...@@ -55,11 +55,11 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
userService := service.NewUserService(userRepository) userService := service.NewUserService(userRepository)
authHandler := handler.NewAuthHandler(configConfig, authService, userService) authHandler := handler.NewAuthHandler(configConfig, authService, userService)
userHandler := handler.NewUserHandler(userService) userHandler := handler.NewUserHandler(userService)
apiKeyRepository := repository.NewAPIKeyRepository(client) apiKeyRepository := repository.NewApiKeyRepository(client)
groupRepository := repository.NewGroupRepository(client, db) groupRepository := repository.NewGroupRepository(client, db)
userSubscriptionRepository := repository.NewUserSubscriptionRepository(client) userSubscriptionRepository := repository.NewUserSubscriptionRepository(client)
apiKeyCache := repository.NewAPIKeyCache(redisClient) apiKeyCache := repository.NewApiKeyCache(redisClient)
apiKeyService := service.NewAPIKeyService(apiKeyRepository, userRepository, groupRepository, userSubscriptionRepository, apiKeyCache, configConfig) apiKeyService := service.NewApiKeyService(apiKeyRepository, userRepository, groupRepository, userSubscriptionRepository, apiKeyCache, configConfig)
apiKeyHandler := handler.NewAPIKeyHandler(apiKeyService) apiKeyHandler := handler.NewAPIKeyHandler(apiKeyService)
usageLogRepository := repository.NewUsageLogRepository(client, db) usageLogRepository := repository.NewUsageLogRepository(client, db)
usageService := service.NewUsageService(usageLogRepository, userRepository) usageService := service.NewUsageService(usageLogRepository, userRepository)
...@@ -74,9 +74,6 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) { ...@@ -74,9 +74,6 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
subscriptionHandler := handler.NewSubscriptionHandler(subscriptionService) subscriptionHandler := handler.NewSubscriptionHandler(subscriptionService)
dashboardService := service.NewDashboardService(usageLogRepository) dashboardService := service.NewDashboardService(usageLogRepository)
dashboardHandler := admin.NewDashboardHandler(dashboardService) dashboardHandler := admin.NewDashboardHandler(dashboardService)
opsRepository := repository.NewOpsRepository(client, db, redisClient)
opsService := service.NewOpsService(opsRepository, db)
opsHandler := admin.NewOpsHandler(opsService)
accountRepository := repository.NewAccountRepository(client, db) accountRepository := repository.NewAccountRepository(client, db)
proxyRepository := repository.NewProxyRepository(client, db) proxyRepository := repository.NewProxyRepository(client, db)
proxyExitInfoProber := repository.NewProxyExitInfoProber() proxyExitInfoProber := repository.NewProxyExitInfoProber()
...@@ -91,16 +88,19 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) { ...@@ -91,16 +88,19 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
geminiCliCodeAssistClient := repository.NewGeminiCliCodeAssistClient() geminiCliCodeAssistClient := repository.NewGeminiCliCodeAssistClient()
geminiOAuthService := service.NewGeminiOAuthService(proxyRepository, geminiOAuthClient, geminiCliCodeAssistClient, configConfig) geminiOAuthService := service.NewGeminiOAuthService(proxyRepository, geminiOAuthClient, geminiCliCodeAssistClient, configConfig)
geminiQuotaService := service.NewGeminiQuotaService(configConfig, settingRepository) geminiQuotaService := service.NewGeminiQuotaService(configConfig, settingRepository)
rateLimitService := service.NewRateLimitService(accountRepository, usageLogRepository, configConfig, geminiQuotaService) tempUnschedCache := repository.NewTempUnschedCache(redisClient)
rateLimitService := service.NewRateLimitService(accountRepository, usageLogRepository, configConfig, geminiQuotaService, tempUnschedCache)
claudeUsageFetcher := repository.NewClaudeUsageFetcher() claudeUsageFetcher := repository.NewClaudeUsageFetcher()
accountUsageService := service.NewAccountUsageService(accountRepository, usageLogRepository, claudeUsageFetcher, geminiQuotaService) antigravityQuotaFetcher := service.NewAntigravityQuotaFetcher(proxyRepository)
usageCache := service.NewUsageCache()
accountUsageService := service.NewAccountUsageService(accountRepository, usageLogRepository, claudeUsageFetcher, geminiQuotaService, antigravityQuotaFetcher, usageCache)
geminiTokenCache := repository.NewGeminiTokenCache(redisClient) geminiTokenCache := repository.NewGeminiTokenCache(redisClient)
geminiTokenProvider := service.NewGeminiTokenProvider(accountRepository, geminiTokenCache, geminiOAuthService) geminiTokenProvider := service.NewGeminiTokenProvider(accountRepository, geminiTokenCache, geminiOAuthService)
gatewayCache := repository.NewGatewayCache(redisClient) gatewayCache := repository.NewGatewayCache(redisClient)
antigravityOAuthService := service.NewAntigravityOAuthService(proxyRepository) antigravityOAuthService := service.NewAntigravityOAuthService(proxyRepository)
antigravityTokenProvider := service.NewAntigravityTokenProvider(accountRepository, geminiTokenCache, antigravityOAuthService) antigravityTokenProvider := service.NewAntigravityTokenProvider(accountRepository, geminiTokenCache, antigravityOAuthService)
httpUpstream := repository.NewHTTPUpstream(configConfig) httpUpstream := repository.NewHTTPUpstream(configConfig)
antigravityGatewayService := service.NewAntigravityGatewayService(accountRepository, gatewayCache, antigravityTokenProvider, rateLimitService, httpUpstream) antigravityGatewayService := service.NewAntigravityGatewayService(accountRepository, gatewayCache, antigravityTokenProvider, rateLimitService, httpUpstream, settingService)
accountTestService := service.NewAccountTestService(accountRepository, oAuthService, openAIOAuthService, geminiTokenProvider, antigravityGatewayService, httpUpstream) accountTestService := service.NewAccountTestService(accountRepository, oAuthService, openAIOAuthService, geminiTokenProvider, antigravityGatewayService, httpUpstream)
concurrencyCache := repository.ProvideConcurrencyCache(redisClient, configConfig) concurrencyCache := repository.ProvideConcurrencyCache(redisClient, configConfig)
concurrencyService := service.ProvideConcurrencyService(concurrencyCache, accountRepository, configConfig) concurrencyService := service.ProvideConcurrencyService(concurrencyCache, accountRepository, configConfig)
...@@ -124,24 +124,7 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) { ...@@ -124,24 +124,7 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
userAttributeValueRepository := repository.NewUserAttributeValueRepository(client) userAttributeValueRepository := repository.NewUserAttributeValueRepository(client)
userAttributeService := service.NewUserAttributeService(userAttributeDefinitionRepository, userAttributeValueRepository) userAttributeService := service.NewUserAttributeService(userAttributeDefinitionRepository, userAttributeValueRepository)
userAttributeHandler := admin.NewUserAttributeHandler(userAttributeService) userAttributeHandler := admin.NewUserAttributeHandler(userAttributeService)
adminHandlers := handler.ProvideAdminHandlers( adminHandlers := handler.ProvideAdminHandlers(dashboardHandler, adminUserHandler, groupHandler, accountHandler, oAuthHandler, openAIOAuthHandler, geminiOAuthHandler, antigravityOAuthHandler, proxyHandler, adminRedeemHandler, settingHandler, systemHandler, adminSubscriptionHandler, adminUsageHandler, userAttributeHandler)
dashboardHandler,
opsHandler,
adminUserHandler,
groupHandler,
accountHandler,
oAuthHandler,
openAIOAuthHandler,
geminiOAuthHandler,
antigravityOAuthHandler,
proxyHandler,
adminRedeemHandler,
settingHandler,
systemHandler,
adminSubscriptionHandler,
adminUsageHandler,
userAttributeHandler,
)
pricingRemoteClient := repository.NewPricingRemoteClient() pricingRemoteClient := repository.NewPricingRemoteClient()
pricingService, err := service.ProvidePricingService(configConfig, pricingRemoteClient) pricingService, err := service.ProvidePricingService(configConfig, pricingRemoteClient)
if err != nil { if err != nil {
...@@ -154,21 +137,18 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) { ...@@ -154,21 +137,18 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
deferredService := service.ProvideDeferredService(accountRepository, timingWheelService) deferredService := service.ProvideDeferredService(accountRepository, timingWheelService)
gatewayService := service.NewGatewayService(accountRepository, groupRepository, usageLogRepository, userRepository, userSubscriptionRepository, gatewayCache, configConfig, concurrencyService, billingService, rateLimitService, billingCacheService, identityService, httpUpstream, deferredService) gatewayService := service.NewGatewayService(accountRepository, groupRepository, usageLogRepository, userRepository, userSubscriptionRepository, gatewayCache, configConfig, concurrencyService, billingService, rateLimitService, billingCacheService, identityService, httpUpstream, deferredService)
geminiMessagesCompatService := service.NewGeminiMessagesCompatService(accountRepository, groupRepository, gatewayCache, geminiTokenProvider, rateLimitService, httpUpstream, antigravityGatewayService) geminiMessagesCompatService := service.NewGeminiMessagesCompatService(accountRepository, groupRepository, gatewayCache, geminiTokenProvider, rateLimitService, httpUpstream, antigravityGatewayService)
gatewayHandler := handler.NewGatewayHandler(gatewayService, geminiMessagesCompatService, antigravityGatewayService, userService, concurrencyService, billingCacheService, opsService) gatewayHandler := handler.NewGatewayHandler(gatewayService, geminiMessagesCompatService, antigravityGatewayService, userService, concurrencyService, billingCacheService)
openAIGatewayService := service.NewOpenAIGatewayService(accountRepository, usageLogRepository, userRepository, userSubscriptionRepository, gatewayCache, configConfig, concurrencyService, billingService, rateLimitService, billingCacheService, httpUpstream, deferredService) openAIGatewayService := service.NewOpenAIGatewayService(accountRepository, usageLogRepository, userRepository, userSubscriptionRepository, gatewayCache, configConfig, concurrencyService, billingService, rateLimitService, billingCacheService, httpUpstream, deferredService)
openAIGatewayHandler := handler.NewOpenAIGatewayHandler(openAIGatewayService, concurrencyService, billingCacheService, opsService) openAIGatewayHandler := handler.NewOpenAIGatewayHandler(openAIGatewayService, concurrencyService, billingCacheService)
handlerSettingHandler := handler.ProvideSettingHandler(settingService, buildInfo) handlerSettingHandler := handler.ProvideSettingHandler(settingService, buildInfo)
handlers := handler.ProvideHandlers(authHandler, userHandler, apiKeyHandler, usageHandler, redeemHandler, subscriptionHandler, adminHandlers, gatewayHandler, openAIGatewayHandler, handlerSettingHandler) handlers := handler.ProvideHandlers(authHandler, userHandler, apiKeyHandler, usageHandler, redeemHandler, subscriptionHandler, adminHandlers, gatewayHandler, openAIGatewayHandler, handlerSettingHandler)
jwtAuthMiddleware := middleware.NewJWTAuthMiddleware(authService, userService) jwtAuthMiddleware := middleware.NewJWTAuthMiddleware(authService, userService)
adminAuthMiddleware := middleware.NewAdminAuthMiddleware(authService, userService, settingService) adminAuthMiddleware := middleware.NewAdminAuthMiddleware(authService, userService, settingService)
apiKeyAuthMiddleware := middleware.NewAPIKeyAuthMiddleware(apiKeyService, subscriptionService, configConfig, opsService) apiKeyAuthMiddleware := middleware.NewApiKeyAuthMiddleware(apiKeyService, subscriptionService, configConfig)
engine := server.ProvideRouter(configConfig, handlers, jwtAuthMiddleware, adminAuthMiddleware, apiKeyAuthMiddleware, apiKeyService, subscriptionService) engine := server.ProvideRouter(configConfig, handlers, jwtAuthMiddleware, adminAuthMiddleware, apiKeyAuthMiddleware, apiKeyService, subscriptionService)
httpServer := server.ProvideHTTPServer(configConfig, engine) httpServer := server.ProvideHTTPServer(configConfig, engine)
tokenRefreshService := service.ProvideTokenRefreshService(accountRepository, oAuthService, openAIOAuthService, geminiOAuthService, antigravityOAuthService, configConfig) tokenRefreshService := service.ProvideTokenRefreshService(accountRepository, oAuthService, openAIOAuthService, geminiOAuthService, antigravityOAuthService, configConfig)
antigravityQuotaRefresher := service.ProvideAntigravityQuotaRefresher(accountRepository, proxyRepository, antigravityOAuthService, configConfig) v := provideCleanup(client, redisClient, tokenRefreshService, pricingService, emailQueueService, billingCacheService, oAuthService, openAIOAuthService, geminiOAuthService, antigravityOAuthService)
opsAlertService := service.ProvideOpsAlertService(opsService, userService, emailService)
opsMetricsCollector := service.ProvideOpsMetricsCollector(opsService, concurrencyService)
v := provideCleanup(client, redisClient, tokenRefreshService, pricingService, emailQueueService, billingCacheService, oAuthService, openAIOAuthService, geminiOAuthService, antigravityOAuthService, antigravityQuotaRefresher, opsMetricsCollector, opsAlertService)
application := &Application{ application := &Application{
Server: httpServer, Server: httpServer,
Cleanup: v, Cleanup: v,
...@@ -201,13 +181,7 @@ func provideCleanup( ...@@ -201,13 +181,7 @@ func provideCleanup(
openaiOAuth *service.OpenAIOAuthService, openaiOAuth *service.OpenAIOAuthService,
geminiOAuth *service.GeminiOAuthService, geminiOAuth *service.GeminiOAuthService,
antigravityOAuth *service.AntigravityOAuthService, antigravityOAuth *service.AntigravityOAuthService,
antigravityQuota *service.AntigravityQuotaRefresher,
opsMetricsCollector *service.OpsMetricsCollector,
opsAlertService *service.OpsAlertService,
) func() { ) func() {
if opsAlertService != nil {
opsAlertService.Start()
}
return func() { return func() {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel() defer cancel()
...@@ -216,14 +190,6 @@ func provideCleanup( ...@@ -216,14 +190,6 @@ func provideCleanup(
name string name string
fn func() error fn func() error
}{ }{
{"OpsMetricsCollector", func() error {
opsMetricsCollector.Stop()
return nil
}},
{"OpsAlertService", func() error {
opsAlertService.Stop()
return nil
}},
{"TokenRefreshService", func() error { {"TokenRefreshService", func() error {
tokenRefresh.Stop() tokenRefresh.Stop()
return nil return nil
...@@ -256,10 +222,6 @@ func provideCleanup( ...@@ -256,10 +222,6 @@ func provideCleanup(
antigravityOAuth.Stop() antigravityOAuth.Stop()
return nil return nil
}}, }},
{"AntigravityQuotaRefresher", func() error {
antigravityQuota.Stop()
return nil
}},
{"Redis", func() error { {"Redis", func() error {
return rdb.Close() return rdb.Close()
}}, }},
......
...@@ -14,8 +14,8 @@ import ( ...@@ -14,8 +14,8 @@ import (
"github.com/Wei-Shaw/sub2api/ent/user" "github.com/Wei-Shaw/sub2api/ent/user"
) )
// APIKey is the model entity for the APIKey schema. // ApiKey is the model entity for the ApiKey schema.
type APIKey struct { type ApiKey struct {
config `json:"-"` config `json:"-"`
// ID of the ent. // ID of the ent.
ID int64 `json:"id,omitempty"` ID int64 `json:"id,omitempty"`
...@@ -36,13 +36,13 @@ type APIKey struct { ...@@ -36,13 +36,13 @@ type APIKey struct {
// Status holds the value of the "status" field. // Status holds the value of the "status" field.
Status string `json:"status,omitempty"` Status string `json:"status,omitempty"`
// Edges holds the relations/edges for other nodes in the graph. // Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the APIKeyQuery when eager-loading is set. // The values are being populated by the ApiKeyQuery when eager-loading is set.
Edges APIKeyEdges `json:"edges"` Edges ApiKeyEdges `json:"edges"`
selectValues sql.SelectValues selectValues sql.SelectValues
} }
// APIKeyEdges holds the relations/edges for other nodes in the graph. // ApiKeyEdges holds the relations/edges for other nodes in the graph.
type APIKeyEdges struct { type ApiKeyEdges 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"`
// Group holds the value of the group edge. // Group holds the value of the group edge.
...@@ -56,7 +56,7 @@ type APIKeyEdges struct { ...@@ -56,7 +56,7 @@ type APIKeyEdges struct {
// UserOrErr returns the User value or an error if the edge // UserOrErr returns the User 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 APIKeyEdges) UserOrErr() (*User, error) { func (e ApiKeyEdges) UserOrErr() (*User, error) {
if e.User != nil { if e.User != nil {
return e.User, nil return e.User, nil
} else if e.loadedTypes[0] { } else if e.loadedTypes[0] {
...@@ -67,7 +67,7 @@ func (e APIKeyEdges) UserOrErr() (*User, error) { ...@@ -67,7 +67,7 @@ func (e APIKeyEdges) UserOrErr() (*User, error) {
// GroupOrErr returns the Group value or an error if the edge // GroupOrErr returns the Group 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 APIKeyEdges) GroupOrErr() (*Group, error) { func (e ApiKeyEdges) GroupOrErr() (*Group, error) {
if e.Group != nil { if e.Group != nil {
return e.Group, nil return e.Group, nil
} else if e.loadedTypes[1] { } else if e.loadedTypes[1] {
...@@ -78,7 +78,7 @@ func (e APIKeyEdges) GroupOrErr() (*Group, error) { ...@@ -78,7 +78,7 @@ func (e APIKeyEdges) GroupOrErr() (*Group, error) {
// UsageLogsOrErr returns the UsageLogs value or an error if the edge // UsageLogsOrErr returns the UsageLogs value or an error if the edge
// was not loaded in eager-loading. // was not loaded in eager-loading.
func (e APIKeyEdges) UsageLogsOrErr() ([]*UsageLog, error) { func (e ApiKeyEdges) UsageLogsOrErr() ([]*UsageLog, error) {
if e.loadedTypes[2] { if e.loadedTypes[2] {
return e.UsageLogs, nil return e.UsageLogs, nil
} }
...@@ -86,7 +86,7 @@ func (e APIKeyEdges) UsageLogsOrErr() ([]*UsageLog, error) { ...@@ -86,7 +86,7 @@ func (e APIKeyEdges) UsageLogsOrErr() ([]*UsageLog, error) {
} }
// scanValues returns the types for scanning values from sql.Rows. // scanValues returns the types for scanning values from sql.Rows.
func (*APIKey) scanValues(columns []string) ([]any, error) { func (*ApiKey) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns)) values := make([]any, len(columns))
for i := range columns { for i := range columns {
switch columns[i] { switch columns[i] {
...@@ -104,8 +104,8 @@ func (*APIKey) scanValues(columns []string) ([]any, error) { ...@@ -104,8 +104,8 @@ func (*APIKey) scanValues(columns []string) ([]any, error) {
} }
// assignValues assigns the values that were returned from sql.Rows (after scanning) // assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the APIKey fields. // to the ApiKey fields.
func (_m *APIKey) assignValues(columns []string, values []any) error { func (_m *ApiKey) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n { if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
} }
...@@ -174,49 +174,49 @@ func (_m *APIKey) assignValues(columns []string, values []any) error { ...@@ -174,49 +174,49 @@ func (_m *APIKey) assignValues(columns []string, values []any) error {
return nil return nil
} }
// Value returns the ent.Value that was dynamically selected and assigned to the APIKey. // Value returns the ent.Value that was dynamically selected and assigned to the ApiKey.
// This includes values selected through modifiers, order, etc. // This includes values selected through modifiers, order, etc.
func (_m *APIKey) Value(name string) (ent.Value, error) { func (_m *ApiKey) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name) return _m.selectValues.Get(name)
} }
// QueryUser queries the "user" edge of the APIKey entity. // QueryUser queries the "user" edge of the ApiKey entity.
func (_m *APIKey) QueryUser() *UserQuery { func (_m *ApiKey) QueryUser() *UserQuery {
return NewAPIKeyClient(_m.config).QueryUser(_m) return NewApiKeyClient(_m.config).QueryUser(_m)
} }
// QueryGroup queries the "group" edge of the APIKey entity. // QueryGroup queries the "group" edge of the ApiKey entity.
func (_m *APIKey) QueryGroup() *GroupQuery { func (_m *ApiKey) QueryGroup() *GroupQuery {
return NewAPIKeyClient(_m.config).QueryGroup(_m) return NewApiKeyClient(_m.config).QueryGroup(_m)
} }
// QueryUsageLogs queries the "usage_logs" edge of the APIKey entity. // QueryUsageLogs queries the "usage_logs" edge of the ApiKey entity.
func (_m *APIKey) QueryUsageLogs() *UsageLogQuery { func (_m *ApiKey) QueryUsageLogs() *UsageLogQuery {
return NewAPIKeyClient(_m.config).QueryUsageLogs(_m) return NewApiKeyClient(_m.config).QueryUsageLogs(_m)
} }
// Update returns a builder for updating this APIKey. // Update returns a builder for updating this ApiKey.
// Note that you need to call APIKey.Unwrap() before calling this method if this APIKey // Note that you need to call ApiKey.Unwrap() before calling this method if this ApiKey
// was returned from a transaction, and the transaction was committed or rolled back. // was returned from a transaction, and the transaction was committed or rolled back.
func (_m *APIKey) Update() *APIKeyUpdateOne { func (_m *ApiKey) Update() *ApiKeyUpdateOne {
return NewAPIKeyClient(_m.config).UpdateOne(_m) return NewApiKeyClient(_m.config).UpdateOne(_m)
} }
// Unwrap unwraps the APIKey entity that was returned from a transaction after it was closed, // Unwrap unwraps the ApiKey entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction. // so that all future queries will be executed through the driver which created the transaction.
func (_m *APIKey) Unwrap() *APIKey { func (_m *ApiKey) Unwrap() *ApiKey {
_tx, ok := _m.config.driver.(*txDriver) _tx, ok := _m.config.driver.(*txDriver)
if !ok { if !ok {
panic("ent: APIKey is not a transactional entity") panic("ent: ApiKey is not a transactional entity")
} }
_m.config.driver = _tx.drv _m.config.driver = _tx.drv
return _m return _m
} }
// String implements the fmt.Stringer. // String implements the fmt.Stringer.
func (_m *APIKey) String() string { func (_m *ApiKey) String() string {
var builder strings.Builder var builder strings.Builder
builder.WriteString("APIKey(") builder.WriteString("ApiKey(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("created_at=") builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
...@@ -249,5 +249,5 @@ func (_m *APIKey) String() string { ...@@ -249,5 +249,5 @@ func (_m *APIKey) String() string {
return builder.String() return builder.String()
} }
// APIKeys is a parsable slice of APIKey. // ApiKeys is a parsable slice of ApiKey.
type APIKeys []*APIKey type ApiKeys []*ApiKey
...@@ -109,7 +109,7 @@ var ( ...@@ -109,7 +109,7 @@ var (
StatusValidator func(string) error StatusValidator func(string) error
) )
// OrderOption defines the ordering options for the APIKey queries. // OrderOption defines the ordering options for the ApiKey queries.
type OrderOption func(*sql.Selector) type OrderOption func(*sql.Selector)
// ByID orders the results by the id field. // ByID orders the results by the id field.
......
This diff is collapsed.
This diff is collapsed.
...@@ -12,26 +12,26 @@ import ( ...@@ -12,26 +12,26 @@ import (
"github.com/Wei-Shaw/sub2api/ent/predicate" "github.com/Wei-Shaw/sub2api/ent/predicate"
) )
// APIKeyDelete is the builder for deleting a APIKey entity. // ApiKeyDelete is the builder for deleting a ApiKey entity.
type APIKeyDelete struct { type ApiKeyDelete struct {
config config
hooks []Hook hooks []Hook
mutation *APIKeyMutation mutation *ApiKeyMutation
} }
// Where appends a list predicates to the APIKeyDelete builder. // Where appends a list predicates to the ApiKeyDelete builder.
func (_d *APIKeyDelete) Where(ps ...predicate.APIKey) *APIKeyDelete { func (_d *ApiKeyDelete) Where(ps ...predicate.ApiKey) *ApiKeyDelete {
_d.mutation.Where(ps...) _d.mutation.Where(ps...)
return _d return _d
} }
// Exec executes the deletion query and returns how many vertices were deleted. // Exec executes the deletion query and returns how many vertices were deleted.
func (_d *APIKeyDelete) Exec(ctx context.Context) (int, error) { func (_d *ApiKeyDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (_d *APIKeyDelete) ExecX(ctx context.Context) int { func (_d *ApiKeyDelete) ExecX(ctx context.Context) int {
n, err := _d.Exec(ctx) n, err := _d.Exec(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
...@@ -39,7 +39,7 @@ func (_d *APIKeyDelete) ExecX(ctx context.Context) int { ...@@ -39,7 +39,7 @@ func (_d *APIKeyDelete) ExecX(ctx context.Context) int {
return n return n
} }
func (_d *APIKeyDelete) sqlExec(ctx context.Context) (int, error) { func (_d *ApiKeyDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(apikey.Table, sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64)) _spec := sqlgraph.NewDeleteSpec(apikey.Table, sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64))
if ps := _d.mutation.predicates; len(ps) > 0 { if ps := _d.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
...@@ -56,19 +56,19 @@ func (_d *APIKeyDelete) sqlExec(ctx context.Context) (int, error) { ...@@ -56,19 +56,19 @@ func (_d *APIKeyDelete) sqlExec(ctx context.Context) (int, error) {
return affected, err return affected, err
} }
// APIKeyDeleteOne is the builder for deleting a single APIKey entity. // ApiKeyDeleteOne is the builder for deleting a single ApiKey entity.
type APIKeyDeleteOne struct { type ApiKeyDeleteOne struct {
_d *APIKeyDelete _d *ApiKeyDelete
} }
// Where appends a list predicates to the APIKeyDelete builder. // Where appends a list predicates to the ApiKeyDelete builder.
func (_d *APIKeyDeleteOne) Where(ps ...predicate.APIKey) *APIKeyDeleteOne { func (_d *ApiKeyDeleteOne) Where(ps ...predicate.ApiKey) *ApiKeyDeleteOne {
_d._d.mutation.Where(ps...) _d._d.mutation.Where(ps...)
return _d return _d
} }
// Exec executes the deletion query. // Exec executes the deletion query.
func (_d *APIKeyDeleteOne) Exec(ctx context.Context) error { func (_d *ApiKeyDeleteOne) Exec(ctx context.Context) error {
n, err := _d._d.Exec(ctx) n, err := _d._d.Exec(ctx)
switch { switch {
case err != nil: case err != nil:
...@@ -81,7 +81,7 @@ func (_d *APIKeyDeleteOne) Exec(ctx context.Context) error { ...@@ -81,7 +81,7 @@ func (_d *APIKeyDeleteOne) Exec(ctx context.Context) error {
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (_d *APIKeyDeleteOne) ExecX(ctx context.Context) { func (_d *ApiKeyDeleteOne) ExecX(ctx context.Context) {
if err := _d.Exec(ctx); err != nil { if err := _d.Exec(ctx); err != nil {
panic(err) panic(err)
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -37,12 +37,12 @@ type Client struct { ...@@ -37,12 +37,12 @@ type Client struct {
config config
// Schema is the client for creating, migrating and dropping schema. // Schema is the client for creating, migrating and dropping schema.
Schema *migrate.Schema Schema *migrate.Schema
// 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.
...@@ -74,9 +74,9 @@ func NewClient(opts ...Option) *Client { ...@@ -74,9 +74,9 @@ func NewClient(opts ...Option) *Client {
func (c *Client) init() { func (c *Client) init() {
c.Schema = migrate.NewSchema(c.driver) c.Schema = migrate.NewSchema(c.driver)
c.APIKey = NewAPIKeyClient(c.config)
c.Account = NewAccountClient(c.config) c.Account = NewAccountClient(c.config)
c.AccountGroup = NewAccountGroupClient(c.config) c.AccountGroup = NewAccountGroupClient(c.config)
c.ApiKey = NewApiKeyClient(c.config)
c.Group = NewGroupClient(c.config) c.Group = NewGroupClient(c.config)
c.Proxy = NewProxyClient(c.config) c.Proxy = NewProxyClient(c.config)
c.RedeemCode = NewRedeemCodeClient(c.config) c.RedeemCode = NewRedeemCodeClient(c.config)
...@@ -179,9 +179,9 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { ...@@ -179,9 +179,9 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
return &Tx{ return &Tx{
ctx: ctx, ctx: ctx,
config: cfg, config: cfg,
APIKey: NewAPIKeyClient(cfg),
Account: NewAccountClient(cfg), Account: NewAccountClient(cfg),
AccountGroup: NewAccountGroupClient(cfg), AccountGroup: NewAccountGroupClient(cfg),
ApiKey: NewApiKeyClient(cfg),
Group: NewGroupClient(cfg), Group: NewGroupClient(cfg),
Proxy: NewProxyClient(cfg), Proxy: NewProxyClient(cfg),
RedeemCode: NewRedeemCodeClient(cfg), RedeemCode: NewRedeemCodeClient(cfg),
...@@ -211,9 +211,9 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) ...@@ -211,9 +211,9 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
return &Tx{ return &Tx{
ctx: ctx, ctx: ctx,
config: cfg, config: cfg,
APIKey: NewAPIKeyClient(cfg),
Account: NewAccountClient(cfg), Account: NewAccountClient(cfg),
AccountGroup: NewAccountGroupClient(cfg), AccountGroup: NewAccountGroupClient(cfg),
ApiKey: NewApiKeyClient(cfg),
Group: NewGroupClient(cfg), Group: NewGroupClient(cfg),
Proxy: NewProxyClient(cfg), Proxy: NewProxyClient(cfg),
RedeemCode: NewRedeemCodeClient(cfg), RedeemCode: NewRedeemCodeClient(cfg),
...@@ -230,7 +230,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) ...@@ -230,7 +230,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
// Debug returns a new debug-client. It's used to get verbose logging on specific operations. // Debug returns a new debug-client. It's used to get verbose logging on specific operations.
// //
// client.Debug(). // client.Debug().
// APIKey. // Account.
// Query(). // Query().
// Count(ctx) // Count(ctx)
func (c *Client) Debug() *Client { func (c *Client) Debug() *Client {
...@@ -253,9 +253,9 @@ func (c *Client) Close() error { ...@@ -253,9 +253,9 @@ func (c *Client) Close() error {
// In order to add hooks to a specific client, call: `client.Node.Use(...)`. // In order to add hooks to a specific client, call: `client.Node.Use(...)`.
func (c *Client) Use(hooks ...Hook) { func (c *Client) Use(hooks ...Hook) {
for _, n := range []interface{ Use(...Hook) }{ for _, n := range []interface{ Use(...Hook) }{
c.APIKey, c.Account, c.AccountGroup, c.Group, c.Proxy, c.RedeemCode, c.Setting, c.Account, c.AccountGroup, c.ApiKey, c.Group, c.Proxy, c.RedeemCode, c.Setting,
c.UsageLog, c.User, c.UserAllowedGroup, c.UserAttributeDefinition, c.UserAttributeValue, c.UsageLog, c.User, c.UserAllowedGroup, c.UserAttributeDefinition,
c.UserSubscription, c.UserAttributeValue, c.UserSubscription,
} { } {
n.Use(hooks...) n.Use(hooks...)
} }
...@@ -265,9 +265,9 @@ func (c *Client) Use(hooks ...Hook) { ...@@ -265,9 +265,9 @@ func (c *Client) Use(hooks ...Hook) {
// In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.
func (c *Client) Intercept(interceptors ...Interceptor) { func (c *Client) Intercept(interceptors ...Interceptor) {
for _, n := range []interface{ Intercept(...Interceptor) }{ for _, n := range []interface{ Intercept(...Interceptor) }{
c.APIKey, c.Account, c.AccountGroup, c.Group, c.Proxy, c.RedeemCode, c.Setting, c.Account, c.AccountGroup, c.ApiKey, c.Group, c.Proxy, c.RedeemCode, c.Setting,
c.UsageLog, c.User, c.UserAllowedGroup, c.UserAttributeDefinition, c.UserAttributeValue, c.UsageLog, c.User, c.UserAllowedGroup, c.UserAttributeDefinition,
c.UserSubscription, c.UserAttributeValue, c.UserSubscription,
} { } {
n.Intercept(interceptors...) n.Intercept(interceptors...)
} }
...@@ -276,12 +276,12 @@ func (c *Client) Intercept(interceptors ...Interceptor) { ...@@ -276,12 +276,12 @@ func (c *Client) Intercept(interceptors ...Interceptor) {
// Mutate implements the ent.Mutator interface. // Mutate implements the ent.Mutator interface.
func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
switch m := m.(type) { switch m := m.(type) {
case *APIKeyMutation:
return c.APIKey.mutate(ctx, m)
case *AccountMutation: case *AccountMutation:
return c.Account.mutate(ctx, m) return c.Account.mutate(ctx, m)
case *AccountGroupMutation: case *AccountGroupMutation:
return c.AccountGroup.mutate(ctx, m) return c.AccountGroup.mutate(ctx, m)
case *ApiKeyMutation:
return c.ApiKey.mutate(ctx, m)
case *GroupMutation: case *GroupMutation:
return c.Group.mutate(ctx, m) return c.Group.mutate(ctx, m)
case *ProxyMutation: case *ProxyMutation:
...@@ -307,189 +307,6 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { ...@@ -307,189 +307,6 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
} }
} }
// APIKeyClient is a client for the APIKey schema.
type APIKeyClient struct {
config
}
// NewAPIKeyClient returns a client for the APIKey from the given config.
func NewAPIKeyClient(c config) *APIKeyClient {
return &APIKeyClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `apikey.Hooks(f(g(h())))`.
func (c *APIKeyClient) Use(hooks ...Hook) {
c.hooks.APIKey = append(c.hooks.APIKey, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `apikey.Intercept(f(g(h())))`.
func (c *APIKeyClient) Intercept(interceptors ...Interceptor) {
c.inters.APIKey = append(c.inters.APIKey, interceptors...)
}
// Create returns a builder for creating a APIKey entity.
func (c *APIKeyClient) Create() *APIKeyCreate {
mutation := newAPIKeyMutation(c.config, OpCreate)
return &APIKeyCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of APIKey entities.
func (c *APIKeyClient) CreateBulk(builders ...*APIKeyCreate) *APIKeyCreateBulk {
return &APIKeyCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *APIKeyClient) MapCreateBulk(slice any, setFunc func(*APIKeyCreate, int)) *APIKeyCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &APIKeyCreateBulk{err: fmt.Errorf("calling to APIKeyClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*APIKeyCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &APIKeyCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for APIKey.
func (c *APIKeyClient) Update() *APIKeyUpdate {
mutation := newAPIKeyMutation(c.config, OpUpdate)
return &APIKeyUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *APIKeyClient) UpdateOne(_m *APIKey) *APIKeyUpdateOne {
mutation := newAPIKeyMutation(c.config, OpUpdateOne, withAPIKey(_m))
return &APIKeyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *APIKeyClient) UpdateOneID(id int64) *APIKeyUpdateOne {
mutation := newAPIKeyMutation(c.config, OpUpdateOne, withAPIKeyID(id))
return &APIKeyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for APIKey.
func (c *APIKeyClient) Delete() *APIKeyDelete {
mutation := newAPIKeyMutation(c.config, OpDelete)
return &APIKeyDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *APIKeyClient) DeleteOne(_m *APIKey) *APIKeyDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *APIKeyClient) DeleteOneID(id int64) *APIKeyDeleteOne {
builder := c.Delete().Where(apikey.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &APIKeyDeleteOne{builder}
}
// Query returns a query builder for APIKey.
func (c *APIKeyClient) Query() *APIKeyQuery {
return &APIKeyQuery{
config: c.config,
ctx: &QueryContext{Type: TypeAPIKey},
inters: c.Interceptors(),
}
}
// Get returns a APIKey entity by its id.
func (c *APIKeyClient) Get(ctx context.Context, id int64) (*APIKey, error) {
return c.Query().Where(apikey.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *APIKeyClient) GetX(ctx context.Context, id int64) *APIKey {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// QueryUser queries the user edge of a APIKey.
func (c *APIKeyClient) QueryUser(_m *APIKey) *UserQuery {
query := (&UserClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID
step := sqlgraph.NewStep(
sqlgraph.From(apikey.Table, apikey.FieldID, id),
sqlgraph.To(user.Table, user.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, apikey.UserTable, apikey.UserColumn),
)
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryGroup queries the group edge of a APIKey.
func (c *APIKeyClient) QueryGroup(_m *APIKey) *GroupQuery {
query := (&GroupClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID
step := sqlgraph.NewStep(
sqlgraph.From(apikey.Table, apikey.FieldID, id),
sqlgraph.To(group.Table, group.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, apikey.GroupTable, apikey.GroupColumn),
)
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryUsageLogs queries the usage_logs edge of a APIKey.
func (c *APIKeyClient) QueryUsageLogs(_m *APIKey) *UsageLogQuery {
query := (&UsageLogClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID
step := sqlgraph.NewStep(
sqlgraph.From(apikey.Table, apikey.FieldID, id),
sqlgraph.To(usagelog.Table, usagelog.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, apikey.UsageLogsTable, apikey.UsageLogsColumn),
)
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *APIKeyClient) Hooks() []Hook {
hooks := c.hooks.APIKey
return append(hooks[:len(hooks):len(hooks)], apikey.Hooks[:]...)
}
// Interceptors returns the client interceptors.
func (c *APIKeyClient) Interceptors() []Interceptor {
inters := c.inters.APIKey
return append(inters[:len(inters):len(inters)], apikey.Interceptors[:]...)
}
func (c *APIKeyClient) mutate(ctx context.Context, m *APIKeyMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&APIKeyCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&APIKeyUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&APIKeyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&APIKeyDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown APIKey mutation op: %q", m.Op())
}
}
// AccountClient is a client for the Account schema. // AccountClient is a client for the Account schema.
type AccountClient struct { type AccountClient struct {
config config
...@@ -805,6 +622,189 @@ func (c *AccountGroupClient) mutate(ctx context.Context, m *AccountGroupMutation ...@@ -805,6 +622,189 @@ func (c *AccountGroupClient) mutate(ctx context.Context, m *AccountGroupMutation
} }
} }
// ApiKeyClient is a client for the ApiKey schema.
type ApiKeyClient struct {
config
}
// NewApiKeyClient returns a client for the ApiKey from the given config.
func NewApiKeyClient(c config) *ApiKeyClient {
return &ApiKeyClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `apikey.Hooks(f(g(h())))`.
func (c *ApiKeyClient) Use(hooks ...Hook) {
c.hooks.ApiKey = append(c.hooks.ApiKey, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `apikey.Intercept(f(g(h())))`.
func (c *ApiKeyClient) Intercept(interceptors ...Interceptor) {
c.inters.ApiKey = append(c.inters.ApiKey, interceptors...)
}
// Create returns a builder for creating a ApiKey entity.
func (c *ApiKeyClient) Create() *ApiKeyCreate {
mutation := newApiKeyMutation(c.config, OpCreate)
return &ApiKeyCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of ApiKey entities.
func (c *ApiKeyClient) CreateBulk(builders ...*ApiKeyCreate) *ApiKeyCreateBulk {
return &ApiKeyCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *ApiKeyClient) MapCreateBulk(slice any, setFunc func(*ApiKeyCreate, int)) *ApiKeyCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &ApiKeyCreateBulk{err: fmt.Errorf("calling to ApiKeyClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*ApiKeyCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &ApiKeyCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for ApiKey.
func (c *ApiKeyClient) Update() *ApiKeyUpdate {
mutation := newApiKeyMutation(c.config, OpUpdate)
return &ApiKeyUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *ApiKeyClient) UpdateOne(_m *ApiKey) *ApiKeyUpdateOne {
mutation := newApiKeyMutation(c.config, OpUpdateOne, withApiKey(_m))
return &ApiKeyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *ApiKeyClient) UpdateOneID(id int64) *ApiKeyUpdateOne {
mutation := newApiKeyMutation(c.config, OpUpdateOne, withApiKeyID(id))
return &ApiKeyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for ApiKey.
func (c *ApiKeyClient) Delete() *ApiKeyDelete {
mutation := newApiKeyMutation(c.config, OpDelete)
return &ApiKeyDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *ApiKeyClient) DeleteOne(_m *ApiKey) *ApiKeyDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *ApiKeyClient) DeleteOneID(id int64) *ApiKeyDeleteOne {
builder := c.Delete().Where(apikey.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &ApiKeyDeleteOne{builder}
}
// Query returns a query builder for ApiKey.
func (c *ApiKeyClient) Query() *ApiKeyQuery {
return &ApiKeyQuery{
config: c.config,
ctx: &QueryContext{Type: TypeApiKey},
inters: c.Interceptors(),
}
}
// Get returns a ApiKey entity by its id.
func (c *ApiKeyClient) Get(ctx context.Context, id int64) (*ApiKey, error) {
return c.Query().Where(apikey.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *ApiKeyClient) GetX(ctx context.Context, id int64) *ApiKey {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// QueryUser queries the user edge of a ApiKey.
func (c *ApiKeyClient) QueryUser(_m *ApiKey) *UserQuery {
query := (&UserClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID
step := sqlgraph.NewStep(
sqlgraph.From(apikey.Table, apikey.FieldID, id),
sqlgraph.To(user.Table, user.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, apikey.UserTable, apikey.UserColumn),
)
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryGroup queries the group edge of a ApiKey.
func (c *ApiKeyClient) QueryGroup(_m *ApiKey) *GroupQuery {
query := (&GroupClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID
step := sqlgraph.NewStep(
sqlgraph.From(apikey.Table, apikey.FieldID, id),
sqlgraph.To(group.Table, group.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, apikey.GroupTable, apikey.GroupColumn),
)
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryUsageLogs queries the usage_logs edge of a ApiKey.
func (c *ApiKeyClient) QueryUsageLogs(_m *ApiKey) *UsageLogQuery {
query := (&UsageLogClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID
step := sqlgraph.NewStep(
sqlgraph.From(apikey.Table, apikey.FieldID, id),
sqlgraph.To(usagelog.Table, usagelog.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, apikey.UsageLogsTable, apikey.UsageLogsColumn),
)
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *ApiKeyClient) Hooks() []Hook {
hooks := c.hooks.ApiKey
return append(hooks[:len(hooks):len(hooks)], apikey.Hooks[:]...)
}
// Interceptors returns the client interceptors.
func (c *ApiKeyClient) Interceptors() []Interceptor {
inters := c.inters.ApiKey
return append(inters[:len(inters):len(inters)], apikey.Interceptors[:]...)
}
func (c *ApiKeyClient) mutate(ctx context.Context, m *ApiKeyMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&ApiKeyCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&ApiKeyUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&ApiKeyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&ApiKeyDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown ApiKey mutation op: %q", m.Op())
}
}
// GroupClient is a client for the Group schema. // GroupClient is a client for the Group schema.
type GroupClient struct { type GroupClient struct {
config config
...@@ -914,8 +914,8 @@ func (c *GroupClient) GetX(ctx context.Context, id int64) *Group { ...@@ -914,8 +914,8 @@ func (c *GroupClient) GetX(ctx context.Context, id int64) *Group {
} }
// QueryAPIKeys queries the api_keys edge of a Group. // QueryAPIKeys queries the api_keys edge of a Group.
func (c *GroupClient) QueryAPIKeys(_m *Group) *APIKeyQuery { func (c *GroupClient) QueryAPIKeys(_m *Group) *ApiKeyQuery {
query := (&APIKeyClient{config: c.config}).Query() query := (&ApiKeyClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID id := _m.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
...@@ -1642,8 +1642,8 @@ func (c *UsageLogClient) QueryUser(_m *UsageLog) *UserQuery { ...@@ -1642,8 +1642,8 @@ func (c *UsageLogClient) QueryUser(_m *UsageLog) *UserQuery {
} }
// QueryAPIKey queries the api_key edge of a UsageLog. // QueryAPIKey queries the api_key edge of a UsageLog.
func (c *UsageLogClient) QueryAPIKey(_m *UsageLog) *APIKeyQuery { func (c *UsageLogClient) QueryAPIKey(_m *UsageLog) *ApiKeyQuery {
query := (&APIKeyClient{config: c.config}).Query() query := (&ApiKeyClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID id := _m.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
...@@ -1839,8 +1839,8 @@ func (c *UserClient) GetX(ctx context.Context, id int64) *User { ...@@ -1839,8 +1839,8 @@ func (c *UserClient) GetX(ctx context.Context, id int64) *User {
} }
// QueryAPIKeys queries the api_keys edge of a User. // QueryAPIKeys queries the api_keys edge of a User.
func (c *UserClient) QueryAPIKeys(_m *User) *APIKeyQuery { func (c *UserClient) QueryAPIKeys(_m *User) *ApiKeyQuery {
query := (&APIKeyClient{config: c.config}).Query() query := (&ApiKeyClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID id := _m.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
...@@ -2627,12 +2627,12 @@ func (c *UserSubscriptionClient) mutate(ctx context.Context, m *UserSubscription ...@@ -2627,12 +2627,12 @@ func (c *UserSubscriptionClient) mutate(ctx context.Context, m *UserSubscription
// hooks and interceptors per client, for fast access. // hooks and interceptors per client, for fast access.
type ( type (
hooks struct { hooks struct {
APIKey, Account, AccountGroup, Group, Proxy, RedeemCode, Setting, UsageLog, Account, AccountGroup, ApiKey, Group, Proxy, RedeemCode, Setting, UsageLog,
User, UserAllowedGroup, UserAttributeDefinition, UserAttributeValue, User, UserAllowedGroup, UserAttributeDefinition, UserAttributeValue,
UserSubscription []ent.Hook UserSubscription []ent.Hook
} }
inters struct { inters struct {
APIKey, Account, AccountGroup, Group, Proxy, RedeemCode, Setting, UsageLog, Account, AccountGroup, ApiKey, Group, Proxy, RedeemCode, Setting, UsageLog,
User, UserAllowedGroup, UserAttributeDefinition, UserAttributeValue, User, UserAllowedGroup, UserAttributeDefinition, UserAttributeValue,
UserSubscription []ent.Interceptor UserSubscription []ent.Interceptor
} }
......
// Package ent provides database entity definitions and operations.
package ent package ent
import "entgo.io/ent/dialect" import "entgo.io/ent/dialect"
......
...@@ -54,7 +54,7 @@ type Group struct { ...@@ -54,7 +54,7 @@ type Group struct {
// GroupEdges holds the relations/edges for other nodes in the graph. // GroupEdges holds the relations/edges for other nodes in the graph.
type GroupEdges struct { type GroupEdges 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.
...@@ -76,7 +76,7 @@ type GroupEdges struct { ...@@ -76,7 +76,7 @@ type GroupEdges 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 GroupEdges) APIKeysOrErr() ([]*APIKey, error) { func (e GroupEdges) APIKeysOrErr() ([]*ApiKey, error) {
if e.loadedTypes[0] { if e.loadedTypes[0] {
return e.APIKeys, nil return e.APIKeys, nil
} }
...@@ -285,7 +285,7 @@ func (_m *Group) Value(name string) (ent.Value, error) { ...@@ -285,7 +285,7 @@ func (_m *Group) Value(name string) (ent.Value, error) {
} }
// QueryAPIKeys queries the "api_keys" edge of the Group entity. // QueryAPIKeys queries the "api_keys" edge of the Group entity.
func (_m *Group) QueryAPIKeys() *APIKeyQuery { func (_m *Group) QueryAPIKeys() *ApiKeyQuery {
return NewGroupClient(_m.config).QueryAPIKeys(_m) return NewGroupClient(_m.config).QueryAPIKeys(_m)
} }
......
...@@ -63,7 +63,7 @@ const ( ...@@ -63,7 +63,7 @@ const (
Table = "groups" Table = "groups"
// 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.
......
...@@ -842,7 +842,7 @@ func HasAPIKeys() predicate.Group { ...@@ -842,7 +842,7 @@ func HasAPIKeys() predicate.Group {
} }
// HasAPIKeysWith applies the HasEdge predicate on the "api_keys" edge with a given conditions (other predicates). // HasAPIKeysWith applies the HasEdge predicate on the "api_keys" edge with a given conditions (other predicates).
func HasAPIKeysWith(preds ...predicate.APIKey) predicate.Group { func HasAPIKeysWith(preds ...predicate.ApiKey) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(func(s *sql.Selector) {
step := newAPIKeysStep() step := newAPIKeysStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
......
...@@ -216,14 +216,14 @@ func (_c *GroupCreate) SetNillableDefaultValidityDays(v *int) *GroupCreate { ...@@ -216,14 +216,14 @@ func (_c *GroupCreate) SetNillableDefaultValidityDays(v *int) *GroupCreate {
return _c return _c
} }
// 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 (_c *GroupCreate) AddAPIKeyIDs(ids ...int64) *GroupCreate { func (_c *GroupCreate) AddAPIKeyIDs(ids ...int64) *GroupCreate {
_c.mutation.AddAPIKeyIDs(ids...) _c.mutation.AddAPIKeyIDs(ids...)
return _c return _c
} }
// AddAPIKeys adds the "api_keys" edges to the APIKey entity. // AddAPIKeys adds the "api_keys" edges to the ApiKey entity.
func (_c *GroupCreate) AddAPIKeys(v ...*APIKey) *GroupCreate { func (_c *GroupCreate) AddAPIKeys(v ...*ApiKey) *GroupCreate {
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
......
...@@ -31,7 +31,7 @@ type GroupQuery struct { ...@@ -31,7 +31,7 @@ type GroupQuery struct {
order []group.OrderOption order []group.OrderOption
inters []Interceptor inters []Interceptor
predicates []predicate.Group predicates []predicate.Group
withAPIKeys *APIKeyQuery withAPIKeys *ApiKeyQuery
withRedeemCodes *RedeemCodeQuery withRedeemCodes *RedeemCodeQuery
withSubscriptions *UserSubscriptionQuery withSubscriptions *UserSubscriptionQuery
withUsageLogs *UsageLogQuery withUsageLogs *UsageLogQuery
...@@ -76,8 +76,8 @@ func (_q *GroupQuery) Order(o ...group.OrderOption) *GroupQuery { ...@@ -76,8 +76,8 @@ func (_q *GroupQuery) Order(o ...group.OrderOption) *GroupQuery {
} }
// QueryAPIKeys chains the current query on the "api_keys" edge. // QueryAPIKeys chains the current query on the "api_keys" edge.
func (_q *GroupQuery) QueryAPIKeys() *APIKeyQuery { func (_q *GroupQuery) QueryAPIKeys() *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
...@@ -459,8 +459,8 @@ func (_q *GroupQuery) Clone() *GroupQuery { ...@@ -459,8 +459,8 @@ func (_q *GroupQuery) Clone() *GroupQuery {
// WithAPIKeys tells the query-builder to eager-load the nodes that are connected to // WithAPIKeys tells the query-builder to eager-load the nodes that are connected to
// the "api_keys" edge. The optional arguments are used to configure the query builder of the edge. // the "api_keys" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *GroupQuery) WithAPIKeys(opts ...func(*APIKeyQuery)) *GroupQuery { func (_q *GroupQuery) WithAPIKeys(opts ...func(*ApiKeyQuery)) *GroupQuery {
query := (&APIKeyClient{config: _q.config}).Query() query := (&ApiKeyClient{config: _q.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
...@@ -654,8 +654,8 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group, ...@@ -654,8 +654,8 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group,
} }
if query := _q.withAPIKeys; query != nil { if query := _q.withAPIKeys; query != nil {
if err := _q.loadAPIKeys(ctx, query, nodes, if err := _q.loadAPIKeys(ctx, query, nodes,
func(n *Group) { n.Edges.APIKeys = []*APIKey{} }, func(n *Group) { n.Edges.APIKeys = []*ApiKey{} },
func(n *Group, e *APIKey) { n.Edges.APIKeys = append(n.Edges.APIKeys, e) }); err != nil { func(n *Group, e *ApiKey) { n.Edges.APIKeys = append(n.Edges.APIKeys, e) }); err != nil {
return nil, err return nil, err
} }
} }
...@@ -711,7 +711,7 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group, ...@@ -711,7 +711,7 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group,
return nodes, nil return nodes, nil
} }
func (_q *GroupQuery) loadAPIKeys(ctx context.Context, query *APIKeyQuery, nodes []*Group, init func(*Group), assign func(*Group, *APIKey)) error { func (_q *GroupQuery) loadAPIKeys(ctx context.Context, query *ApiKeyQuery, nodes []*Group, init func(*Group), assign func(*Group, *ApiKey)) error {
fks := make([]driver.Value, 0, len(nodes)) fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[int64]*Group) nodeids := make(map[int64]*Group)
for i := range nodes { for i := range nodes {
...@@ -724,7 +724,7 @@ func (_q *GroupQuery) loadAPIKeys(ctx context.Context, query *APIKeyQuery, nodes ...@@ -724,7 +724,7 @@ func (_q *GroupQuery) loadAPIKeys(ctx context.Context, query *APIKeyQuery, nodes
if len(query.ctx.Fields) > 0 { if len(query.ctx.Fields) > 0 {
query.ctx.AppendFieldOnce(apikey.FieldGroupID) query.ctx.AppendFieldOnce(apikey.FieldGroupID)
} }
query.Where(predicate.APIKey(func(s *sql.Selector) { query.Where(predicate.ApiKey(func(s *sql.Selector) {
s.Where(sql.InValues(s.C(group.APIKeysColumn), fks...)) s.Where(sql.InValues(s.C(group.APIKeysColumn), fks...))
})) }))
neighbors, err := query.All(ctx) neighbors, err := query.All(ctx)
......
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