Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
994da655
Commit
994da655
authored
Apr 24, 2026
by
陈曦
Browse files
收集req和resp的相关更改
parent
8f7ac1ea
Changes
37
Expand all
Hide whitespace changes
Inline
Side-by-side
backend/cmd/server/wire_gen.go
View file @
994da655
...
@@ -223,10 +223,12 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
...
@@ -223,10 +223,12 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
paymentHandler
:=
admin
.
NewPaymentHandler
(
paymentService
,
paymentConfigService
)
paymentHandler
:=
admin
.
NewPaymentHandler
(
paymentService
,
paymentConfigService
)
adminHandlers
:=
handler
.
ProvideAdminHandlers
(
dashboardHandler
,
adminUserHandler
,
groupHandler
,
accountHandler
,
adminAnnouncementHandler
,
dataManagementHandler
,
backupHandler
,
oAuthHandler
,
openAIOAuthHandler
,
geminiOAuthHandler
,
antigravityOAuthHandler
,
proxyHandler
,
adminRedeemHandler
,
promoHandler
,
settingHandler
,
opsHandler
,
systemHandler
,
adminSubscriptionHandler
,
adminUsageHandler
,
userAttributeHandler
,
errorPassthroughHandler
,
tlsFingerprintProfileHandler
,
adminAPIKeyHandler
,
scheduledTestHandler
,
channelHandler
,
paymentHandler
)
adminHandlers
:=
handler
.
ProvideAdminHandlers
(
dashboardHandler
,
adminUserHandler
,
groupHandler
,
accountHandler
,
adminAnnouncementHandler
,
dataManagementHandler
,
backupHandler
,
oAuthHandler
,
openAIOAuthHandler
,
geminiOAuthHandler
,
antigravityOAuthHandler
,
proxyHandler
,
adminRedeemHandler
,
promoHandler
,
settingHandler
,
opsHandler
,
systemHandler
,
adminSubscriptionHandler
,
adminUsageHandler
,
userAttributeHandler
,
errorPassthroughHandler
,
tlsFingerprintProfileHandler
,
adminAPIKeyHandler
,
scheduledTestHandler
,
channelHandler
,
paymentHandler
)
usageRecordWorkerPool
:=
service
.
NewUsageRecordWorkerPool
(
configConfig
)
usageRecordWorkerPool
:=
service
.
NewUsageRecordWorkerPool
(
configConfig
)
requestCaptureLogRepository
:=
repository
.
NewRequestCaptureLogRepository
(
client
)
requestCaptureService
:=
service
.
NewRequestCaptureService
(
requestCaptureLogRepository
,
configConfig
)
userMsgQueueCache
:=
repository
.
NewUserMsgQueueCache
(
redisClient
)
userMsgQueueCache
:=
repository
.
NewUserMsgQueueCache
(
redisClient
)
userMessageQueueService
:=
service
.
ProvideUserMessageQueueService
(
userMsgQueueCache
,
rpmCache
,
configConfig
)
userMessageQueueService
:=
service
.
ProvideUserMessageQueueService
(
userMsgQueueCache
,
rpmCache
,
configConfig
)
gatewayHandler
:=
handler
.
NewGatewayHandler
(
gatewayService
,
geminiMessagesCompatService
,
antigravityGatewayService
,
userService
,
concurrencyService
,
billingCacheService
,
usageService
,
apiKeyService
,
usageRecordWorkerPool
,
errorPassthroughService
,
userMessageQueueService
,
configConfig
,
settingService
)
gatewayHandler
:=
handler
.
NewGatewayHandler
(
gatewayService
,
geminiMessagesCompatService
,
antigravityGatewayService
,
userService
,
concurrencyService
,
billingCacheService
,
usageService
,
apiKeyService
,
usageRecordWorkerPool
,
errorPassthroughService
,
requestCaptureService
,
userMessageQueueService
,
configConfig
,
settingService
)
openAIGatewayHandler
:=
handler
.
NewOpenAIGatewayHandler
(
openAIGatewayService
,
concurrencyService
,
billingCacheService
,
apiKeyService
,
usageRecordWorkerPool
,
errorPassthroughService
,
configConfig
)
openAIGatewayHandler
:=
handler
.
NewOpenAIGatewayHandler
(
openAIGatewayService
,
concurrencyService
,
billingCacheService
,
apiKeyService
,
usageRecordWorkerPool
,
errorPassthroughService
,
requestCaptureService
,
configConfig
)
handlerSettingHandler
:=
handler
.
ProvideSettingHandler
(
settingService
,
buildInfo
)
handlerSettingHandler
:=
handler
.
ProvideSettingHandler
(
settingService
,
buildInfo
)
totpHandler
:=
handler
.
NewTotpHandler
(
totpService
)
totpHandler
:=
handler
.
NewTotpHandler
(
totpService
)
handlerPaymentHandler
:=
handler
.
NewPaymentHandler
(
paymentService
,
paymentConfigService
,
channelService
)
handlerPaymentHandler
:=
handler
.
NewPaymentHandler
(
paymentService
,
paymentConfigService
,
channelService
)
...
...
backend/ent/apikey.go
View file @
994da655
...
@@ -66,6 +66,8 @@ type APIKey struct {
...
@@ -66,6 +66,8 @@ type APIKey struct {
Window1dStart
*
time
.
Time
`json:"window_1d_start,omitempty"`
Window1dStart
*
time
.
Time
`json:"window_1d_start,omitempty"`
// Start time of the current 7d rate limit window
// Start time of the current 7d rate limit window
Window7dStart
*
time
.
Time
`json:"window_7d_start,omitempty"`
Window7dStart
*
time
.
Time
`json:"window_7d_start,omitempty"`
// 是否对该 API Key 的请求体进行存储捕获
CaptureRequests
bool
`json:"capture_requests,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"`
...
@@ -123,6 +125,8 @@ func (*APIKey) scanValues(columns []string) ([]any, error) {
...
@@ -123,6 +125,8 @@ func (*APIKey) scanValues(columns []string) ([]any, error) {
switch
columns
[
i
]
{
switch
columns
[
i
]
{
case
apikey
.
FieldIPWhitelist
,
apikey
.
FieldIPBlacklist
:
case
apikey
.
FieldIPWhitelist
,
apikey
.
FieldIPBlacklist
:
values
[
i
]
=
new
([]
byte
)
values
[
i
]
=
new
([]
byte
)
case
apikey
.
FieldCaptureRequests
:
values
[
i
]
=
new
(
sql
.
NullBool
)
case
apikey
.
FieldQuota
,
apikey
.
FieldQuotaUsed
,
apikey
.
FieldRateLimit5h
,
apikey
.
FieldRateLimit1d
,
apikey
.
FieldRateLimit7d
,
apikey
.
FieldUsage5h
,
apikey
.
FieldUsage1d
,
apikey
.
FieldUsage7d
:
case
apikey
.
FieldQuota
,
apikey
.
FieldQuotaUsed
,
apikey
.
FieldRateLimit5h
,
apikey
.
FieldRateLimit1d
,
apikey
.
FieldRateLimit7d
,
apikey
.
FieldUsage5h
,
apikey
.
FieldUsage1d
,
apikey
.
FieldUsage7d
:
values
[
i
]
=
new
(
sql
.
NullFloat64
)
values
[
i
]
=
new
(
sql
.
NullFloat64
)
case
apikey
.
FieldID
,
apikey
.
FieldUserID
,
apikey
.
FieldGroupID
:
case
apikey
.
FieldID
,
apikey
.
FieldUserID
,
apikey
.
FieldGroupID
:
...
@@ -301,6 +305,12 @@ func (_m *APIKey) assignValues(columns []string, values []any) error {
...
@@ -301,6 +305,12 @@ func (_m *APIKey) assignValues(columns []string, values []any) error {
_m
.
Window7dStart
=
new
(
time
.
Time
)
_m
.
Window7dStart
=
new
(
time
.
Time
)
*
_m
.
Window7dStart
=
value
.
Time
*
_m
.
Window7dStart
=
value
.
Time
}
}
case
apikey
.
FieldCaptureRequests
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullBool
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field capture_requests"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
CaptureRequests
=
value
.
Bool
}
default
:
default
:
_m
.
selectValues
.
Set
(
columns
[
i
],
values
[
i
])
_m
.
selectValues
.
Set
(
columns
[
i
],
values
[
i
])
}
}
...
@@ -434,6 +444,9 @@ func (_m *APIKey) String() string {
...
@@ -434,6 +444,9 @@ func (_m *APIKey) String() string {
builder
.
WriteString
(
"window_7d_start="
)
builder
.
WriteString
(
"window_7d_start="
)
builder
.
WriteString
(
v
.
Format
(
time
.
ANSIC
))
builder
.
WriteString
(
v
.
Format
(
time
.
ANSIC
))
}
}
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"capture_requests="
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"%v"
,
_m
.
CaptureRequests
))
builder
.
WriteByte
(
')'
)
builder
.
WriteByte
(
')'
)
return
builder
.
String
()
return
builder
.
String
()
}
}
...
...
backend/ent/apikey/apikey.go
View file @
994da655
...
@@ -61,6 +61,8 @@ const (
...
@@ -61,6 +61,8 @@ const (
FieldWindow1dStart
=
"window_1d_start"
FieldWindow1dStart
=
"window_1d_start"
// FieldWindow7dStart holds the string denoting the window_7d_start field in the database.
// FieldWindow7dStart holds the string denoting the window_7d_start field in the database.
FieldWindow7dStart
=
"window_7d_start"
FieldWindow7dStart
=
"window_7d_start"
// FieldCaptureRequests holds the string denoting the capture_requests field in the database.
FieldCaptureRequests
=
"capture_requests"
// EdgeUser holds the string denoting the user edge name in mutations.
// EdgeUser holds the string denoting the user edge name in mutations.
EdgeUser
=
"user"
EdgeUser
=
"user"
// EdgeGroup holds the string denoting the group edge name in mutations.
// EdgeGroup holds the string denoting the group edge name in mutations.
...
@@ -118,6 +120,7 @@ var Columns = []string{
...
@@ -118,6 +120,7 @@ var Columns = []string{
FieldWindow5hStart
,
FieldWindow5hStart
,
FieldWindow1dStart
,
FieldWindow1dStart
,
FieldWindow7dStart
,
FieldWindow7dStart
,
FieldCaptureRequests
,
}
}
// ValidColumn reports if the column name is valid (part of the table columns).
// ValidColumn reports if the column name is valid (part of the table columns).
...
@@ -168,6 +171,8 @@ var (
...
@@ -168,6 +171,8 @@ var (
DefaultUsage1d
float64
DefaultUsage1d
float64
// DefaultUsage7d holds the default value on creation for the "usage_7d" field.
// DefaultUsage7d holds the default value on creation for the "usage_7d" field.
DefaultUsage7d
float64
DefaultUsage7d
float64
// DefaultCaptureRequests holds the default value on creation for the "capture_requests" field.
DefaultCaptureRequests
bool
)
)
// OrderOption defines the ordering options for the APIKey queries.
// OrderOption defines the ordering options for the APIKey queries.
...
@@ -283,6 +288,11 @@ func ByWindow7dStart(opts ...sql.OrderTermOption) OrderOption {
...
@@ -283,6 +288,11 @@ func ByWindow7dStart(opts ...sql.OrderTermOption) OrderOption {
return
sql
.
OrderByField
(
FieldWindow7dStart
,
opts
...
)
.
ToFunc
()
return
sql
.
OrderByField
(
FieldWindow7dStart
,
opts
...
)
.
ToFunc
()
}
}
// ByCaptureRequests orders the results by the capture_requests field.
func
ByCaptureRequests
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldCaptureRequests
,
opts
...
)
.
ToFunc
()
}
// ByUserField orders the results by user field.
// ByUserField orders the results by user field.
func
ByUserField
(
field
string
,
opts
...
sql
.
OrderTermOption
)
OrderOption
{
func
ByUserField
(
field
string
,
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
func
(
s
*
sql
.
Selector
)
{
return
func
(
s
*
sql
.
Selector
)
{
...
...
backend/ent/apikey/where.go
View file @
994da655
...
@@ -160,6 +160,11 @@ func Window7dStart(v time.Time) predicate.APIKey {
...
@@ -160,6 +160,11 @@ func Window7dStart(v time.Time) predicate.APIKey {
return
predicate
.
APIKey
(
sql
.
FieldEQ
(
FieldWindow7dStart
,
v
))
return
predicate
.
APIKey
(
sql
.
FieldEQ
(
FieldWindow7dStart
,
v
))
}
}
// CaptureRequests applies equality check predicate on the "capture_requests" field. It's identical to CaptureRequestsEQ.
func
CaptureRequests
(
v
bool
)
predicate
.
APIKey
{
return
predicate
.
APIKey
(
sql
.
FieldEQ
(
FieldCaptureRequests
,
v
))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func
CreatedAtEQ
(
v
time
.
Time
)
predicate
.
APIKey
{
func
CreatedAtEQ
(
v
time
.
Time
)
predicate
.
APIKey
{
return
predicate
.
APIKey
(
sql
.
FieldEQ
(
FieldCreatedAt
,
v
))
return
predicate
.
APIKey
(
sql
.
FieldEQ
(
FieldCreatedAt
,
v
))
...
@@ -1125,6 +1130,16 @@ func Window7dStartNotNil() predicate.APIKey {
...
@@ -1125,6 +1130,16 @@ func Window7dStartNotNil() predicate.APIKey {
return
predicate
.
APIKey
(
sql
.
FieldNotNull
(
FieldWindow7dStart
))
return
predicate
.
APIKey
(
sql
.
FieldNotNull
(
FieldWindow7dStart
))
}
}
// CaptureRequestsEQ applies the EQ predicate on the "capture_requests" field.
func
CaptureRequestsEQ
(
v
bool
)
predicate
.
APIKey
{
return
predicate
.
APIKey
(
sql
.
FieldEQ
(
FieldCaptureRequests
,
v
))
}
// CaptureRequestsNEQ applies the NEQ predicate on the "capture_requests" field.
func
CaptureRequestsNEQ
(
v
bool
)
predicate
.
APIKey
{
return
predicate
.
APIKey
(
sql
.
FieldNEQ
(
FieldCaptureRequests
,
v
))
}
// HasUser applies the HasEdge predicate on the "user" edge.
// HasUser applies the HasEdge predicate on the "user" edge.
func
HasUser
()
predicate
.
APIKey
{
func
HasUser
()
predicate
.
APIKey
{
return
predicate
.
APIKey
(
func
(
s
*
sql
.
Selector
)
{
return
predicate
.
APIKey
(
func
(
s
*
sql
.
Selector
)
{
...
...
backend/ent/apikey_create.go
View file @
994da655
...
@@ -307,6 +307,20 @@ func (_c *APIKeyCreate) SetNillableWindow7dStart(v *time.Time) *APIKeyCreate {
...
@@ -307,6 +307,20 @@ func (_c *APIKeyCreate) SetNillableWindow7dStart(v *time.Time) *APIKeyCreate {
return
_c
return
_c
}
}
// SetCaptureRequests sets the "capture_requests" field.
func
(
_c
*
APIKeyCreate
)
SetCaptureRequests
(
v
bool
)
*
APIKeyCreate
{
_c
.
mutation
.
SetCaptureRequests
(
v
)
return
_c
}
// SetNillableCaptureRequests sets the "capture_requests" field if the given value is not nil.
func
(
_c
*
APIKeyCreate
)
SetNillableCaptureRequests
(
v
*
bool
)
*
APIKeyCreate
{
if
v
!=
nil
{
_c
.
SetCaptureRequests
(
*
v
)
}
return
_c
}
// SetUser sets the "user" edge to the User entity.
// SetUser sets the "user" edge to the User entity.
func
(
_c
*
APIKeyCreate
)
SetUser
(
v
*
User
)
*
APIKeyCreate
{
func
(
_c
*
APIKeyCreate
)
SetUser
(
v
*
User
)
*
APIKeyCreate
{
return
_c
.
SetUserID
(
v
.
ID
)
return
_c
.
SetUserID
(
v
.
ID
)
...
@@ -419,6 +433,10 @@ func (_c *APIKeyCreate) defaults() error {
...
@@ -419,6 +433,10 @@ func (_c *APIKeyCreate) defaults() error {
v
:=
apikey
.
DefaultUsage7d
v
:=
apikey
.
DefaultUsage7d
_c
.
mutation
.
SetUsage7d
(
v
)
_c
.
mutation
.
SetUsage7d
(
v
)
}
}
if
_
,
ok
:=
_c
.
mutation
.
CaptureRequests
();
!
ok
{
v
:=
apikey
.
DefaultCaptureRequests
_c
.
mutation
.
SetCaptureRequests
(
v
)
}
return
nil
return
nil
}
}
...
@@ -481,6 +499,9 @@ func (_c *APIKeyCreate) check() error {
...
@@ -481,6 +499,9 @@ func (_c *APIKeyCreate) check() error {
if
_
,
ok
:=
_c
.
mutation
.
Usage7d
();
!
ok
{
if
_
,
ok
:=
_c
.
mutation
.
Usage7d
();
!
ok
{
return
&
ValidationError
{
Name
:
"usage_7d"
,
err
:
errors
.
New
(
`ent: missing required field "APIKey.usage_7d"`
)}
return
&
ValidationError
{
Name
:
"usage_7d"
,
err
:
errors
.
New
(
`ent: missing required field "APIKey.usage_7d"`
)}
}
}
if
_
,
ok
:=
_c
.
mutation
.
CaptureRequests
();
!
ok
{
return
&
ValidationError
{
Name
:
"capture_requests"
,
err
:
errors
.
New
(
`ent: missing required field "APIKey.capture_requests"`
)}
}
if
len
(
_c
.
mutation
.
UserIDs
())
==
0
{
if
len
(
_c
.
mutation
.
UserIDs
())
==
0
{
return
&
ValidationError
{
Name
:
"user"
,
err
:
errors
.
New
(
`ent: missing required edge "APIKey.user"`
)}
return
&
ValidationError
{
Name
:
"user"
,
err
:
errors
.
New
(
`ent: missing required edge "APIKey.user"`
)}
}
}
...
@@ -595,6 +616,10 @@ func (_c *APIKeyCreate) createSpec() (*APIKey, *sqlgraph.CreateSpec) {
...
@@ -595,6 +616,10 @@ func (_c *APIKeyCreate) createSpec() (*APIKey, *sqlgraph.CreateSpec) {
_spec
.
SetField
(
apikey
.
FieldWindow7dStart
,
field
.
TypeTime
,
value
)
_spec
.
SetField
(
apikey
.
FieldWindow7dStart
,
field
.
TypeTime
,
value
)
_node
.
Window7dStart
=
&
value
_node
.
Window7dStart
=
&
value
}
}
if
value
,
ok
:=
_c
.
mutation
.
CaptureRequests
();
ok
{
_spec
.
SetField
(
apikey
.
FieldCaptureRequests
,
field
.
TypeBool
,
value
)
_node
.
CaptureRequests
=
value
}
if
nodes
:=
_c
.
mutation
.
UserIDs
();
len
(
nodes
)
>
0
{
if
nodes
:=
_c
.
mutation
.
UserIDs
();
len
(
nodes
)
>
0
{
edge
:=
&
sqlgraph
.
EdgeSpec
{
edge
:=
&
sqlgraph
.
EdgeSpec
{
Rel
:
sqlgraph
.
M2O
,
Rel
:
sqlgraph
.
M2O
,
...
@@ -1063,6 +1088,18 @@ func (u *APIKeyUpsert) ClearWindow7dStart() *APIKeyUpsert {
...
@@ -1063,6 +1088,18 @@ func (u *APIKeyUpsert) ClearWindow7dStart() *APIKeyUpsert {
return
u
return
u
}
}
// SetCaptureRequests sets the "capture_requests" field.
func
(
u
*
APIKeyUpsert
)
SetCaptureRequests
(
v
bool
)
*
APIKeyUpsert
{
u
.
Set
(
apikey
.
FieldCaptureRequests
,
v
)
return
u
}
// UpdateCaptureRequests sets the "capture_requests" field to the value that was provided on create.
func
(
u
*
APIKeyUpsert
)
UpdateCaptureRequests
()
*
APIKeyUpsert
{
u
.
SetExcluded
(
apikey
.
FieldCaptureRequests
)
return
u
}
// UpdateNewValues updates the mutable fields using the new values that were set on create.
// UpdateNewValues updates the mutable fields using the new values that were set on create.
// Using this option is equivalent to using:
// Using this option is equivalent to using:
//
//
...
@@ -1535,6 +1572,20 @@ func (u *APIKeyUpsertOne) ClearWindow7dStart() *APIKeyUpsertOne {
...
@@ -1535,6 +1572,20 @@ func (u *APIKeyUpsertOne) ClearWindow7dStart() *APIKeyUpsertOne {
})
})
}
}
// SetCaptureRequests sets the "capture_requests" field.
func
(
u
*
APIKeyUpsertOne
)
SetCaptureRequests
(
v
bool
)
*
APIKeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
APIKeyUpsert
)
{
s
.
SetCaptureRequests
(
v
)
})
}
// UpdateCaptureRequests sets the "capture_requests" field to the value that was provided on create.
func
(
u
*
APIKeyUpsertOne
)
UpdateCaptureRequests
()
*
APIKeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
APIKeyUpsert
)
{
s
.
UpdateCaptureRequests
()
})
}
// Exec executes the query.
// Exec executes the query.
func
(
u
*
APIKeyUpsertOne
)
Exec
(
ctx
context
.
Context
)
error
{
func
(
u
*
APIKeyUpsertOne
)
Exec
(
ctx
context
.
Context
)
error
{
if
len
(
u
.
create
.
conflict
)
==
0
{
if
len
(
u
.
create
.
conflict
)
==
0
{
...
@@ -2173,6 +2224,20 @@ func (u *APIKeyUpsertBulk) ClearWindow7dStart() *APIKeyUpsertBulk {
...
@@ -2173,6 +2224,20 @@ func (u *APIKeyUpsertBulk) ClearWindow7dStart() *APIKeyUpsertBulk {
})
})
}
}
// SetCaptureRequests sets the "capture_requests" field.
func
(
u
*
APIKeyUpsertBulk
)
SetCaptureRequests
(
v
bool
)
*
APIKeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
APIKeyUpsert
)
{
s
.
SetCaptureRequests
(
v
)
})
}
// UpdateCaptureRequests sets the "capture_requests" field to the value that was provided on create.
func
(
u
*
APIKeyUpsertBulk
)
UpdateCaptureRequests
()
*
APIKeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
APIKeyUpsert
)
{
s
.
UpdateCaptureRequests
()
})
}
// Exec executes the query.
// Exec executes the query.
func
(
u
*
APIKeyUpsertBulk
)
Exec
(
ctx
context
.
Context
)
error
{
func
(
u
*
APIKeyUpsertBulk
)
Exec
(
ctx
context
.
Context
)
error
{
if
u
.
create
.
err
!=
nil
{
if
u
.
create
.
err
!=
nil
{
...
...
backend/ent/apikey_update.go
View file @
994da655
...
@@ -438,6 +438,20 @@ func (_u *APIKeyUpdate) ClearWindow7dStart() *APIKeyUpdate {
...
@@ -438,6 +438,20 @@ func (_u *APIKeyUpdate) ClearWindow7dStart() *APIKeyUpdate {
return
_u
return
_u
}
}
// SetCaptureRequests sets the "capture_requests" field.
func
(
_u
*
APIKeyUpdate
)
SetCaptureRequests
(
v
bool
)
*
APIKeyUpdate
{
_u
.
mutation
.
SetCaptureRequests
(
v
)
return
_u
}
// SetNillableCaptureRequests sets the "capture_requests" field if the given value is not nil.
func
(
_u
*
APIKeyUpdate
)
SetNillableCaptureRequests
(
v
*
bool
)
*
APIKeyUpdate
{
if
v
!=
nil
{
_u
.
SetCaptureRequests
(
*
v
)
}
return
_u
}
// SetUser sets the "user" edge to the User entity.
// SetUser sets the "user" edge to the User entity.
func
(
_u
*
APIKeyUpdate
)
SetUser
(
v
*
User
)
*
APIKeyUpdate
{
func
(
_u
*
APIKeyUpdate
)
SetUser
(
v
*
User
)
*
APIKeyUpdate
{
return
_u
.
SetUserID
(
v
.
ID
)
return
_u
.
SetUserID
(
v
.
ID
)
...
@@ -696,6 +710,9 @@ func (_u *APIKeyUpdate) sqlSave(ctx context.Context) (_node int, err error) {
...
@@ -696,6 +710,9 @@ func (_u *APIKeyUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if
_u
.
mutation
.
Window7dStartCleared
()
{
if
_u
.
mutation
.
Window7dStartCleared
()
{
_spec
.
ClearField
(
apikey
.
FieldWindow7dStart
,
field
.
TypeTime
)
_spec
.
ClearField
(
apikey
.
FieldWindow7dStart
,
field
.
TypeTime
)
}
}
if
value
,
ok
:=
_u
.
mutation
.
CaptureRequests
();
ok
{
_spec
.
SetField
(
apikey
.
FieldCaptureRequests
,
field
.
TypeBool
,
value
)
}
if
_u
.
mutation
.
UserCleared
()
{
if
_u
.
mutation
.
UserCleared
()
{
edge
:=
&
sqlgraph
.
EdgeSpec
{
edge
:=
&
sqlgraph
.
EdgeSpec
{
Rel
:
sqlgraph
.
M2O
,
Rel
:
sqlgraph
.
M2O
,
...
@@ -1225,6 +1242,20 @@ func (_u *APIKeyUpdateOne) ClearWindow7dStart() *APIKeyUpdateOne {
...
@@ -1225,6 +1242,20 @@ func (_u *APIKeyUpdateOne) ClearWindow7dStart() *APIKeyUpdateOne {
return
_u
return
_u
}
}
// SetCaptureRequests sets the "capture_requests" field.
func
(
_u
*
APIKeyUpdateOne
)
SetCaptureRequests
(
v
bool
)
*
APIKeyUpdateOne
{
_u
.
mutation
.
SetCaptureRequests
(
v
)
return
_u
}
// SetNillableCaptureRequests sets the "capture_requests" field if the given value is not nil.
func
(
_u
*
APIKeyUpdateOne
)
SetNillableCaptureRequests
(
v
*
bool
)
*
APIKeyUpdateOne
{
if
v
!=
nil
{
_u
.
SetCaptureRequests
(
*
v
)
}
return
_u
}
// SetUser sets the "user" edge to the User entity.
// SetUser sets the "user" edge to the User entity.
func
(
_u
*
APIKeyUpdateOne
)
SetUser
(
v
*
User
)
*
APIKeyUpdateOne
{
func
(
_u
*
APIKeyUpdateOne
)
SetUser
(
v
*
User
)
*
APIKeyUpdateOne
{
return
_u
.
SetUserID
(
v
.
ID
)
return
_u
.
SetUserID
(
v
.
ID
)
...
@@ -1513,6 +1544,9 @@ func (_u *APIKeyUpdateOne) sqlSave(ctx context.Context) (_node *APIKey, err erro
...
@@ -1513,6 +1544,9 @@ func (_u *APIKeyUpdateOne) sqlSave(ctx context.Context) (_node *APIKey, err erro
if
_u
.
mutation
.
Window7dStartCleared
()
{
if
_u
.
mutation
.
Window7dStartCleared
()
{
_spec
.
ClearField
(
apikey
.
FieldWindow7dStart
,
field
.
TypeTime
)
_spec
.
ClearField
(
apikey
.
FieldWindow7dStart
,
field
.
TypeTime
)
}
}
if
value
,
ok
:=
_u
.
mutation
.
CaptureRequests
();
ok
{
_spec
.
SetField
(
apikey
.
FieldCaptureRequests
,
field
.
TypeBool
,
value
)
}
if
_u
.
mutation
.
UserCleared
()
{
if
_u
.
mutation
.
UserCleared
()
{
edge
:=
&
sqlgraph
.
EdgeSpec
{
edge
:=
&
sqlgraph
.
EdgeSpec
{
Rel
:
sqlgraph
.
M2O
,
Rel
:
sqlgraph
.
M2O
,
...
...
backend/ent/client.go
View file @
994da655
...
@@ -30,6 +30,7 @@ import (
...
@@ -30,6 +30,7 @@ import (
"github.com/Wei-Shaw/sub2api/ent/promocodeusage"
"github.com/Wei-Shaw/sub2api/ent/promocodeusage"
"github.com/Wei-Shaw/sub2api/ent/proxy"
"github.com/Wei-Shaw/sub2api/ent/proxy"
"github.com/Wei-Shaw/sub2api/ent/redeemcode"
"github.com/Wei-Shaw/sub2api/ent/redeemcode"
"github.com/Wei-Shaw/sub2api/ent/requestcapturelog"
"github.com/Wei-Shaw/sub2api/ent/securitysecret"
"github.com/Wei-Shaw/sub2api/ent/securitysecret"
"github.com/Wei-Shaw/sub2api/ent/setting"
"github.com/Wei-Shaw/sub2api/ent/setting"
"github.com/Wei-Shaw/sub2api/ent/subscriptionplan"
"github.com/Wei-Shaw/sub2api/ent/subscriptionplan"
...
@@ -80,6 +81,8 @@ type Client struct {
...
@@ -80,6 +81,8 @@ type Client struct {
Proxy
*
ProxyClient
Proxy
*
ProxyClient
// RedeemCode is the client for interacting with the RedeemCode builders.
// RedeemCode is the client for interacting with the RedeemCode builders.
RedeemCode
*
RedeemCodeClient
RedeemCode
*
RedeemCodeClient
// RequestCaptureLog is the client for interacting with the RequestCaptureLog builders.
RequestCaptureLog
*
RequestCaptureLogClient
// SecuritySecret is the client for interacting with the SecuritySecret builders.
// SecuritySecret is the client for interacting with the SecuritySecret builders.
SecuritySecret
*
SecuritySecretClient
SecuritySecret
*
SecuritySecretClient
// Setting is the client for interacting with the Setting builders.
// Setting is the client for interacting with the Setting builders.
...
@@ -128,6 +131,7 @@ func (c *Client) init() {
...
@@ -128,6 +131,7 @@ func (c *Client) init() {
c
.
PromoCodeUsage
=
NewPromoCodeUsageClient
(
c
.
config
)
c
.
PromoCodeUsage
=
NewPromoCodeUsageClient
(
c
.
config
)
c
.
Proxy
=
NewProxyClient
(
c
.
config
)
c
.
Proxy
=
NewProxyClient
(
c
.
config
)
c
.
RedeemCode
=
NewRedeemCodeClient
(
c
.
config
)
c
.
RedeemCode
=
NewRedeemCodeClient
(
c
.
config
)
c
.
RequestCaptureLog
=
NewRequestCaptureLogClient
(
c
.
config
)
c
.
SecuritySecret
=
NewSecuritySecretClient
(
c
.
config
)
c
.
SecuritySecret
=
NewSecuritySecretClient
(
c
.
config
)
c
.
Setting
=
NewSettingClient
(
c
.
config
)
c
.
Setting
=
NewSettingClient
(
c
.
config
)
c
.
SubscriptionPlan
=
NewSubscriptionPlanClient
(
c
.
config
)
c
.
SubscriptionPlan
=
NewSubscriptionPlanClient
(
c
.
config
)
...
@@ -246,6 +250,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
...
@@ -246,6 +250,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
PromoCodeUsage
:
NewPromoCodeUsageClient
(
cfg
),
PromoCodeUsage
:
NewPromoCodeUsageClient
(
cfg
),
Proxy
:
NewProxyClient
(
cfg
),
Proxy
:
NewProxyClient
(
cfg
),
RedeemCode
:
NewRedeemCodeClient
(
cfg
),
RedeemCode
:
NewRedeemCodeClient
(
cfg
),
RequestCaptureLog
:
NewRequestCaptureLogClient
(
cfg
),
SecuritySecret
:
NewSecuritySecretClient
(
cfg
),
SecuritySecret
:
NewSecuritySecretClient
(
cfg
),
Setting
:
NewSettingClient
(
cfg
),
Setting
:
NewSettingClient
(
cfg
),
SubscriptionPlan
:
NewSubscriptionPlanClient
(
cfg
),
SubscriptionPlan
:
NewSubscriptionPlanClient
(
cfg
),
...
@@ -291,6 +296,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
...
@@ -291,6 +296,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
PromoCodeUsage
:
NewPromoCodeUsageClient
(
cfg
),
PromoCodeUsage
:
NewPromoCodeUsageClient
(
cfg
),
Proxy
:
NewProxyClient
(
cfg
),
Proxy
:
NewProxyClient
(
cfg
),
RedeemCode
:
NewRedeemCodeClient
(
cfg
),
RedeemCode
:
NewRedeemCodeClient
(
cfg
),
RequestCaptureLog
:
NewRequestCaptureLogClient
(
cfg
),
SecuritySecret
:
NewSecuritySecretClient
(
cfg
),
SecuritySecret
:
NewSecuritySecretClient
(
cfg
),
Setting
:
NewSettingClient
(
cfg
),
Setting
:
NewSettingClient
(
cfg
),
SubscriptionPlan
:
NewSubscriptionPlanClient
(
cfg
),
SubscriptionPlan
:
NewSubscriptionPlanClient
(
cfg
),
...
@@ -334,9 +340,9 @@ func (c *Client) Use(hooks ...Hook) {
...
@@ -334,9 +340,9 @@ func (c *Client) Use(hooks ...Hook) {
c
.
APIKey
,
c
.
Account
,
c
.
AccountGroup
,
c
.
Announcement
,
c
.
AnnouncementRead
,
c
.
APIKey
,
c
.
Account
,
c
.
AccountGroup
,
c
.
Announcement
,
c
.
AnnouncementRead
,
c
.
ErrorPassthroughRule
,
c
.
Group
,
c
.
IdempotencyRecord
,
c
.
PaymentAuditLog
,
c
.
ErrorPassthroughRule
,
c
.
Group
,
c
.
IdempotencyRecord
,
c
.
PaymentAuditLog
,
c
.
PaymentOrder
,
c
.
PaymentProviderInstance
,
c
.
PromoCode
,
c
.
PromoCodeUsage
,
c
.
PaymentOrder
,
c
.
PaymentProviderInstance
,
c
.
PromoCode
,
c
.
PromoCodeUsage
,
c
.
Proxy
,
c
.
RedeemCode
,
c
.
SecuritySecret
,
c
.
Setting
,
c
.
SubscriptionPlan
,
c
.
Proxy
,
c
.
RedeemCode
,
c
.
RequestCaptureLog
,
c
.
SecuritySecret
,
c
.
Setting
,
c
.
TLSFingerprintProfile
,
c
.
UsageCleanupTask
,
c
.
UsageLog
,
c
.
User
,
c
.
SubscriptionPlan
,
c
.
TLSFingerprintProfile
,
c
.
UsageCleanupTask
,
c
.
UsageLog
,
c
.
UserAllowedGroup
,
c
.
UserAttributeDefinition
,
c
.
UserAttributeValue
,
c
.
User
,
c
.
UserAllowedGroup
,
c
.
UserAttributeDefinition
,
c
.
UserAttributeValue
,
c
.
UserSubscription
,
c
.
UserSubscription
,
}
{
}
{
n
.
Use
(
hooks
...
)
n
.
Use
(
hooks
...
)
...
@@ -350,9 +356,9 @@ func (c *Client) Intercept(interceptors ...Interceptor) {
...
@@ -350,9 +356,9 @@ func (c *Client) Intercept(interceptors ...Interceptor) {
c
.
APIKey
,
c
.
Account
,
c
.
AccountGroup
,
c
.
Announcement
,
c
.
AnnouncementRead
,
c
.
APIKey
,
c
.
Account
,
c
.
AccountGroup
,
c
.
Announcement
,
c
.
AnnouncementRead
,
c
.
ErrorPassthroughRule
,
c
.
Group
,
c
.
IdempotencyRecord
,
c
.
PaymentAuditLog
,
c
.
ErrorPassthroughRule
,
c
.
Group
,
c
.
IdempotencyRecord
,
c
.
PaymentAuditLog
,
c
.
PaymentOrder
,
c
.
PaymentProviderInstance
,
c
.
PromoCode
,
c
.
PromoCodeUsage
,
c
.
PaymentOrder
,
c
.
PaymentProviderInstance
,
c
.
PromoCode
,
c
.
PromoCodeUsage
,
c
.
Proxy
,
c
.
RedeemCode
,
c
.
SecuritySecret
,
c
.
Setting
,
c
.
SubscriptionPlan
,
c
.
Proxy
,
c
.
RedeemCode
,
c
.
RequestCaptureLog
,
c
.
SecuritySecret
,
c
.
Setting
,
c
.
TLSFingerprintProfile
,
c
.
UsageCleanupTask
,
c
.
UsageLog
,
c
.
User
,
c
.
SubscriptionPlan
,
c
.
TLSFingerprintProfile
,
c
.
UsageCleanupTask
,
c
.
UsageLog
,
c
.
UserAllowedGroup
,
c
.
UserAttributeDefinition
,
c
.
UserAttributeValue
,
c
.
User
,
c
.
UserAllowedGroup
,
c
.
UserAttributeDefinition
,
c
.
UserAttributeValue
,
c
.
UserSubscription
,
c
.
UserSubscription
,
}
{
}
{
n
.
Intercept
(
interceptors
...
)
n
.
Intercept
(
interceptors
...
)
...
@@ -392,6 +398,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
...
@@ -392,6 +398,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
return
c
.
Proxy
.
mutate
(
ctx
,
m
)
return
c
.
Proxy
.
mutate
(
ctx
,
m
)
case
*
RedeemCodeMutation
:
case
*
RedeemCodeMutation
:
return
c
.
RedeemCode
.
mutate
(
ctx
,
m
)
return
c
.
RedeemCode
.
mutate
(
ctx
,
m
)
case
*
RequestCaptureLogMutation
:
return
c
.
RequestCaptureLog
.
mutate
(
ctx
,
m
)
case
*
SecuritySecretMutation
:
case
*
SecuritySecretMutation
:
return
c
.
SecuritySecret
.
mutate
(
ctx
,
m
)
return
c
.
SecuritySecret
.
mutate
(
ctx
,
m
)
case
*
SettingMutation
:
case
*
SettingMutation
:
...
@@ -2805,6 +2813,139 @@ func (c *RedeemCodeClient) mutate(ctx context.Context, m *RedeemCodeMutation) (V
...
@@ -2805,6 +2813,139 @@ func (c *RedeemCodeClient) mutate(ctx context.Context, m *RedeemCodeMutation) (V
}
}
}
}
// RequestCaptureLogClient is a client for the RequestCaptureLog schema.
type
RequestCaptureLogClient
struct
{
config
}
// NewRequestCaptureLogClient returns a client for the RequestCaptureLog from the given config.
func
NewRequestCaptureLogClient
(
c
config
)
*
RequestCaptureLogClient
{
return
&
RequestCaptureLogClient
{
config
:
c
}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `requestcapturelog.Hooks(f(g(h())))`.
func
(
c
*
RequestCaptureLogClient
)
Use
(
hooks
...
Hook
)
{
c
.
hooks
.
RequestCaptureLog
=
append
(
c
.
hooks
.
RequestCaptureLog
,
hooks
...
)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `requestcapturelog.Intercept(f(g(h())))`.
func
(
c
*
RequestCaptureLogClient
)
Intercept
(
interceptors
...
Interceptor
)
{
c
.
inters
.
RequestCaptureLog
=
append
(
c
.
inters
.
RequestCaptureLog
,
interceptors
...
)
}
// Create returns a builder for creating a RequestCaptureLog entity.
func
(
c
*
RequestCaptureLogClient
)
Create
()
*
RequestCaptureLogCreate
{
mutation
:=
newRequestCaptureLogMutation
(
c
.
config
,
OpCreate
)
return
&
RequestCaptureLogCreate
{
config
:
c
.
config
,
hooks
:
c
.
Hooks
(),
mutation
:
mutation
}
}
// CreateBulk returns a builder for creating a bulk of RequestCaptureLog entities.
func
(
c
*
RequestCaptureLogClient
)
CreateBulk
(
builders
...*
RequestCaptureLogCreate
)
*
RequestCaptureLogCreateBulk
{
return
&
RequestCaptureLogCreateBulk
{
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
*
RequestCaptureLogClient
)
MapCreateBulk
(
slice
any
,
setFunc
func
(
*
RequestCaptureLogCreate
,
int
))
*
RequestCaptureLogCreateBulk
{
rv
:=
reflect
.
ValueOf
(
slice
)
if
rv
.
Kind
()
!=
reflect
.
Slice
{
return
&
RequestCaptureLogCreateBulk
{
err
:
fmt
.
Errorf
(
"calling to RequestCaptureLogClient.MapCreateBulk with wrong type %T, need slice"
,
slice
)}
}
builders
:=
make
([]
*
RequestCaptureLogCreate
,
rv
.
Len
())
for
i
:=
0
;
i
<
rv
.
Len
();
i
++
{
builders
[
i
]
=
c
.
Create
()
setFunc
(
builders
[
i
],
i
)
}
return
&
RequestCaptureLogCreateBulk
{
config
:
c
.
config
,
builders
:
builders
}
}
// Update returns an update builder for RequestCaptureLog.
func
(
c
*
RequestCaptureLogClient
)
Update
()
*
RequestCaptureLogUpdate
{
mutation
:=
newRequestCaptureLogMutation
(
c
.
config
,
OpUpdate
)
return
&
RequestCaptureLogUpdate
{
config
:
c
.
config
,
hooks
:
c
.
Hooks
(),
mutation
:
mutation
}
}
// UpdateOne returns an update builder for the given entity.
func
(
c
*
RequestCaptureLogClient
)
UpdateOne
(
_m
*
RequestCaptureLog
)
*
RequestCaptureLogUpdateOne
{
mutation
:=
newRequestCaptureLogMutation
(
c
.
config
,
OpUpdateOne
,
withRequestCaptureLog
(
_m
))
return
&
RequestCaptureLogUpdateOne
{
config
:
c
.
config
,
hooks
:
c
.
Hooks
(),
mutation
:
mutation
}
}
// UpdateOneID returns an update builder for the given id.
func
(
c
*
RequestCaptureLogClient
)
UpdateOneID
(
id
int64
)
*
RequestCaptureLogUpdateOne
{
mutation
:=
newRequestCaptureLogMutation
(
c
.
config
,
OpUpdateOne
,
withRequestCaptureLogID
(
id
))
return
&
RequestCaptureLogUpdateOne
{
config
:
c
.
config
,
hooks
:
c
.
Hooks
(),
mutation
:
mutation
}
}
// Delete returns a delete builder for RequestCaptureLog.
func
(
c
*
RequestCaptureLogClient
)
Delete
()
*
RequestCaptureLogDelete
{
mutation
:=
newRequestCaptureLogMutation
(
c
.
config
,
OpDelete
)
return
&
RequestCaptureLogDelete
{
config
:
c
.
config
,
hooks
:
c
.
Hooks
(),
mutation
:
mutation
}
}
// DeleteOne returns a builder for deleting the given entity.
func
(
c
*
RequestCaptureLogClient
)
DeleteOne
(
_m
*
RequestCaptureLog
)
*
RequestCaptureLogDeleteOne
{
return
c
.
DeleteOneID
(
_m
.
ID
)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func
(
c
*
RequestCaptureLogClient
)
DeleteOneID
(
id
int64
)
*
RequestCaptureLogDeleteOne
{
builder
:=
c
.
Delete
()
.
Where
(
requestcapturelog
.
ID
(
id
))
builder
.
mutation
.
id
=
&
id
builder
.
mutation
.
op
=
OpDeleteOne
return
&
RequestCaptureLogDeleteOne
{
builder
}
}
// Query returns a query builder for RequestCaptureLog.
func
(
c
*
RequestCaptureLogClient
)
Query
()
*
RequestCaptureLogQuery
{
return
&
RequestCaptureLogQuery
{
config
:
c
.
config
,
ctx
:
&
QueryContext
{
Type
:
TypeRequestCaptureLog
},
inters
:
c
.
Interceptors
(),
}
}
// Get returns a RequestCaptureLog entity by its id.
func
(
c
*
RequestCaptureLogClient
)
Get
(
ctx
context
.
Context
,
id
int64
)
(
*
RequestCaptureLog
,
error
)
{
return
c
.
Query
()
.
Where
(
requestcapturelog
.
ID
(
id
))
.
Only
(
ctx
)
}
// GetX is like Get, but panics if an error occurs.
func
(
c
*
RequestCaptureLogClient
)
GetX
(
ctx
context
.
Context
,
id
int64
)
*
RequestCaptureLog
{
obj
,
err
:=
c
.
Get
(
ctx
,
id
)
if
err
!=
nil
{
panic
(
err
)
}
return
obj
}
// Hooks returns the client hooks.
func
(
c
*
RequestCaptureLogClient
)
Hooks
()
[]
Hook
{
return
c
.
hooks
.
RequestCaptureLog
}
// Interceptors returns the client interceptors.
func
(
c
*
RequestCaptureLogClient
)
Interceptors
()
[]
Interceptor
{
return
c
.
inters
.
RequestCaptureLog
}
func
(
c
*
RequestCaptureLogClient
)
mutate
(
ctx
context
.
Context
,
m
*
RequestCaptureLogMutation
)
(
Value
,
error
)
{
switch
m
.
Op
()
{
case
OpCreate
:
return
(
&
RequestCaptureLogCreate
{
config
:
c
.
config
,
hooks
:
c
.
Hooks
(),
mutation
:
m
})
.
Save
(
ctx
)
case
OpUpdate
:
return
(
&
RequestCaptureLogUpdate
{
config
:
c
.
config
,
hooks
:
c
.
Hooks
(),
mutation
:
m
})
.
Save
(
ctx
)
case
OpUpdateOne
:
return
(
&
RequestCaptureLogUpdateOne
{
config
:
c
.
config
,
hooks
:
c
.
Hooks
(),
mutation
:
m
})
.
Save
(
ctx
)
case
OpDelete
,
OpDeleteOne
:
return
(
&
RequestCaptureLogDelete
{
config
:
c
.
config
,
hooks
:
c
.
Hooks
(),
mutation
:
m
})
.
Exec
(
ctx
)
default
:
return
nil
,
fmt
.
Errorf
(
"ent: unknown RequestCaptureLog mutation op: %q"
,
m
.
Op
())
}
}
// SecuritySecretClient is a client for the SecuritySecret schema.
// SecuritySecretClient is a client for the SecuritySecret schema.
type
SecuritySecretClient
struct
{
type
SecuritySecretClient
struct
{
config
config
...
@@ -4631,17 +4772,17 @@ type (
...
@@ -4631,17 +4772,17 @@ type (
APIKey
,
Account
,
AccountGroup
,
Announcement
,
AnnouncementRead
,
APIKey
,
Account
,
AccountGroup
,
Announcement
,
AnnouncementRead
,
ErrorPassthroughRule
,
Group
,
IdempotencyRecord
,
PaymentAuditLog
,
PaymentOrder
,
ErrorPassthroughRule
,
Group
,
IdempotencyRecord
,
PaymentAuditLog
,
PaymentOrder
,
PaymentProviderInstance
,
PromoCode
,
PromoCodeUsage
,
Proxy
,
RedeemCode
,
PaymentProviderInstance
,
PromoCode
,
PromoCodeUsage
,
Proxy
,
RedeemCode
,
SecuritySecret
,
Setting
,
SubscriptionPlan
,
TLSFingerprintProfile
,
RequestCaptureLog
,
SecuritySecret
,
Setting
,
SubscriptionPlan
,
UsageCleanupTask
,
UsageLog
,
User
,
UserAllowedGroup
,
UserAttributeDefinition
,
TLSFingerprintProfile
,
UsageCleanupTask
,
UsageLog
,
User
,
UserAllowedGroup
,
UserAttributeValue
,
UserSubscription
[]
ent
.
Hook
UserAttributeDefinition
,
UserAttributeValue
,
UserSubscription
[]
ent
.
Hook
}
}
inters
struct
{
inters
struct
{
APIKey
,
Account
,
AccountGroup
,
Announcement
,
AnnouncementRead
,
APIKey
,
Account
,
AccountGroup
,
Announcement
,
AnnouncementRead
,
ErrorPassthroughRule
,
Group
,
IdempotencyRecord
,
PaymentAuditLog
,
PaymentOrder
,
ErrorPassthroughRule
,
Group
,
IdempotencyRecord
,
PaymentAuditLog
,
PaymentOrder
,
PaymentProviderInstance
,
PromoCode
,
PromoCodeUsage
,
Proxy
,
RedeemCode
,
PaymentProviderInstance
,
PromoCode
,
PromoCodeUsage
,
Proxy
,
RedeemCode
,
SecuritySecret
,
Setting
,
SubscriptionPlan
,
TLSFingerprintProfile
,
RequestCaptureLog
,
SecuritySecret
,
Setting
,
SubscriptionPlan
,
UsageCleanupTask
,
UsageLog
,
User
,
UserAllowedGroup
,
UserAttributeDefinition
,
TLSFingerprintProfile
,
UsageCleanupTask
,
UsageLog
,
User
,
UserAllowedGroup
,
UserAttributeValue
,
UserSubscription
[]
ent
.
Interceptor
UserAttributeDefinition
,
UserAttributeValue
,
UserSubscription
[]
ent
.
Interceptor
}
}
)
)
...
...
backend/ent/ent.go
View file @
994da655
...
@@ -27,6 +27,7 @@ import (
...
@@ -27,6 +27,7 @@ import (
"github.com/Wei-Shaw/sub2api/ent/promocodeusage"
"github.com/Wei-Shaw/sub2api/ent/promocodeusage"
"github.com/Wei-Shaw/sub2api/ent/proxy"
"github.com/Wei-Shaw/sub2api/ent/proxy"
"github.com/Wei-Shaw/sub2api/ent/redeemcode"
"github.com/Wei-Shaw/sub2api/ent/redeemcode"
"github.com/Wei-Shaw/sub2api/ent/requestcapturelog"
"github.com/Wei-Shaw/sub2api/ent/securitysecret"
"github.com/Wei-Shaw/sub2api/ent/securitysecret"
"github.com/Wei-Shaw/sub2api/ent/setting"
"github.com/Wei-Shaw/sub2api/ent/setting"
"github.com/Wei-Shaw/sub2api/ent/subscriptionplan"
"github.com/Wei-Shaw/sub2api/ent/subscriptionplan"
...
@@ -113,6 +114,7 @@ func checkColumn(t, c string) error {
...
@@ -113,6 +114,7 @@ func checkColumn(t, c string) error {
promocodeusage
.
Table
:
promocodeusage
.
ValidColumn
,
promocodeusage
.
Table
:
promocodeusage
.
ValidColumn
,
proxy
.
Table
:
proxy
.
ValidColumn
,
proxy
.
Table
:
proxy
.
ValidColumn
,
redeemcode
.
Table
:
redeemcode
.
ValidColumn
,
redeemcode
.
Table
:
redeemcode
.
ValidColumn
,
requestcapturelog
.
Table
:
requestcapturelog
.
ValidColumn
,
securitysecret
.
Table
:
securitysecret
.
ValidColumn
,
securitysecret
.
Table
:
securitysecret
.
ValidColumn
,
setting
.
Table
:
setting
.
ValidColumn
,
setting
.
Table
:
setting
.
ValidColumn
,
subscriptionplan
.
Table
:
subscriptionplan
.
ValidColumn
,
subscriptionplan
.
Table
:
subscriptionplan
.
ValidColumn
,
...
...
backend/ent/hook/hook.go
View file @
994da655
...
@@ -189,6 +189,18 @@ func (f RedeemCodeFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value,
...
@@ -189,6 +189,18 @@ func (f RedeemCodeFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value,
return
nil
,
fmt
.
Errorf
(
"unexpected mutation type %T. expect *ent.RedeemCodeMutation"
,
m
)
return
nil
,
fmt
.
Errorf
(
"unexpected mutation type %T. expect *ent.RedeemCodeMutation"
,
m
)
}
}
// The RequestCaptureLogFunc type is an adapter to allow the use of ordinary
// function as RequestCaptureLog mutator.
type
RequestCaptureLogFunc
func
(
context
.
Context
,
*
ent
.
RequestCaptureLogMutation
)
(
ent
.
Value
,
error
)
// Mutate calls f(ctx, m).
func
(
f
RequestCaptureLogFunc
)
Mutate
(
ctx
context
.
Context
,
m
ent
.
Mutation
)
(
ent
.
Value
,
error
)
{
if
mv
,
ok
:=
m
.
(
*
ent
.
RequestCaptureLogMutation
);
ok
{
return
f
(
ctx
,
mv
)
}
return
nil
,
fmt
.
Errorf
(
"unexpected mutation type %T. expect *ent.RequestCaptureLogMutation"
,
m
)
}
// The SecuritySecretFunc type is an adapter to allow the use of ordinary
// The SecuritySecretFunc type is an adapter to allow the use of ordinary
// function as SecuritySecret mutator.
// function as SecuritySecret mutator.
type
SecuritySecretFunc
func
(
context
.
Context
,
*
ent
.
SecuritySecretMutation
)
(
ent
.
Value
,
error
)
type
SecuritySecretFunc
func
(
context
.
Context
,
*
ent
.
SecuritySecretMutation
)
(
ent
.
Value
,
error
)
...
...
backend/ent/intercept/intercept.go
View file @
994da655
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"github.com/Wei-Shaw/sub2api/ent/promocodeusage"
"github.com/Wei-Shaw/sub2api/ent/promocodeusage"
"github.com/Wei-Shaw/sub2api/ent/proxy"
"github.com/Wei-Shaw/sub2api/ent/proxy"
"github.com/Wei-Shaw/sub2api/ent/redeemcode"
"github.com/Wei-Shaw/sub2api/ent/redeemcode"
"github.com/Wei-Shaw/sub2api/ent/requestcapturelog"
"github.com/Wei-Shaw/sub2api/ent/securitysecret"
"github.com/Wei-Shaw/sub2api/ent/securitysecret"
"github.com/Wei-Shaw/sub2api/ent/setting"
"github.com/Wei-Shaw/sub2api/ent/setting"
"github.com/Wei-Shaw/sub2api/ent/subscriptionplan"
"github.com/Wei-Shaw/sub2api/ent/subscriptionplan"
...
@@ -498,6 +499,33 @@ func (f TraverseRedeemCode) Traverse(ctx context.Context, q ent.Query) error {
...
@@ -498,6 +499,33 @@ func (f TraverseRedeemCode) Traverse(ctx context.Context, q ent.Query) error {
return
fmt
.
Errorf
(
"unexpected query type %T. expect *ent.RedeemCodeQuery"
,
q
)
return
fmt
.
Errorf
(
"unexpected query type %T. expect *ent.RedeemCodeQuery"
,
q
)
}
}
// The RequestCaptureLogFunc type is an adapter to allow the use of ordinary function as a Querier.
type
RequestCaptureLogFunc
func
(
context
.
Context
,
*
ent
.
RequestCaptureLogQuery
)
(
ent
.
Value
,
error
)
// Query calls f(ctx, q).
func
(
f
RequestCaptureLogFunc
)
Query
(
ctx
context
.
Context
,
q
ent
.
Query
)
(
ent
.
Value
,
error
)
{
if
q
,
ok
:=
q
.
(
*
ent
.
RequestCaptureLogQuery
);
ok
{
return
f
(
ctx
,
q
)
}
return
nil
,
fmt
.
Errorf
(
"unexpected query type %T. expect *ent.RequestCaptureLogQuery"
,
q
)
}
// The TraverseRequestCaptureLog type is an adapter to allow the use of ordinary function as Traverser.
type
TraverseRequestCaptureLog
func
(
context
.
Context
,
*
ent
.
RequestCaptureLogQuery
)
error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func
(
f
TraverseRequestCaptureLog
)
Intercept
(
next
ent
.
Querier
)
ent
.
Querier
{
return
next
}
// Traverse calls f(ctx, q).
func
(
f
TraverseRequestCaptureLog
)
Traverse
(
ctx
context
.
Context
,
q
ent
.
Query
)
error
{
if
q
,
ok
:=
q
.
(
*
ent
.
RequestCaptureLogQuery
);
ok
{
return
f
(
ctx
,
q
)
}
return
fmt
.
Errorf
(
"unexpected query type %T. expect *ent.RequestCaptureLogQuery"
,
q
)
}
// The SecuritySecretFunc type is an adapter to allow the use of ordinary function as a Querier.
// The SecuritySecretFunc type is an adapter to allow the use of ordinary function as a Querier.
type
SecuritySecretFunc
func
(
context
.
Context
,
*
ent
.
SecuritySecretQuery
)
(
ent
.
Value
,
error
)
type
SecuritySecretFunc
func
(
context
.
Context
,
*
ent
.
SecuritySecretQuery
)
(
ent
.
Value
,
error
)
...
@@ -828,6 +856,8 @@ func NewQuery(q ent.Query) (Query, error) {
...
@@ -828,6 +856,8 @@ func NewQuery(q ent.Query) (Query, error) {
return
&
query
[
*
ent
.
ProxyQuery
,
predicate
.
Proxy
,
proxy
.
OrderOption
]{
typ
:
ent
.
TypeProxy
,
tq
:
q
},
nil
return
&
query
[
*
ent
.
ProxyQuery
,
predicate
.
Proxy
,
proxy
.
OrderOption
]{
typ
:
ent
.
TypeProxy
,
tq
:
q
},
nil
case
*
ent
.
RedeemCodeQuery
:
case
*
ent
.
RedeemCodeQuery
:
return
&
query
[
*
ent
.
RedeemCodeQuery
,
predicate
.
RedeemCode
,
redeemcode
.
OrderOption
]{
typ
:
ent
.
TypeRedeemCode
,
tq
:
q
},
nil
return
&
query
[
*
ent
.
RedeemCodeQuery
,
predicate
.
RedeemCode
,
redeemcode
.
OrderOption
]{
typ
:
ent
.
TypeRedeemCode
,
tq
:
q
},
nil
case
*
ent
.
RequestCaptureLogQuery
:
return
&
query
[
*
ent
.
RequestCaptureLogQuery
,
predicate
.
RequestCaptureLog
,
requestcapturelog
.
OrderOption
]{
typ
:
ent
.
TypeRequestCaptureLog
,
tq
:
q
},
nil
case
*
ent
.
SecuritySecretQuery
:
case
*
ent
.
SecuritySecretQuery
:
return
&
query
[
*
ent
.
SecuritySecretQuery
,
predicate
.
SecuritySecret
,
securitysecret
.
OrderOption
]{
typ
:
ent
.
TypeSecuritySecret
,
tq
:
q
},
nil
return
&
query
[
*
ent
.
SecuritySecretQuery
,
predicate
.
SecuritySecret
,
securitysecret
.
OrderOption
]{
typ
:
ent
.
TypeSecuritySecret
,
tq
:
q
},
nil
case
*
ent
.
SettingQuery
:
case
*
ent
.
SettingQuery
:
...
...
backend/ent/migrate/schema.go
View file @
994da655
...
@@ -33,6 +33,7 @@ var (
...
@@ -33,6 +33,7 @@ var (
{
Name
:
"window_5h_start"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
},
{
Name
:
"window_5h_start"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
},
{
Name
:
"window_1d_start"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
},
{
Name
:
"window_1d_start"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
},
{
Name
:
"window_7d_start"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
},
{
Name
:
"window_7d_start"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
},
{
Name
:
"capture_requests"
,
Type
:
field
.
TypeBool
,
Default
:
false
},
{
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
},
}
}
...
@@ -44,13 +45,13 @@ var (
...
@@ -44,13 +45,13 @@ var (
ForeignKeys
:
[]
*
schema
.
ForeignKey
{
ForeignKeys
:
[]
*
schema
.
ForeignKey
{
{
{
Symbol
:
"api_keys_groups_api_keys"
,
Symbol
:
"api_keys_groups_api_keys"
,
Columns
:
[]
*
schema
.
Column
{
APIKeysColumns
[
2
2
]},
Columns
:
[]
*
schema
.
Column
{
APIKeysColumns
[
2
3
]},
RefColumns
:
[]
*
schema
.
Column
{
GroupsColumns
[
0
]},
RefColumns
:
[]
*
schema
.
Column
{
GroupsColumns
[
0
]},
OnDelete
:
schema
.
SetNull
,
OnDelete
:
schema
.
SetNull
,
},
},
{
{
Symbol
:
"api_keys_users_api_keys"
,
Symbol
:
"api_keys_users_api_keys"
,
Columns
:
[]
*
schema
.
Column
{
APIKeysColumns
[
2
3
]},
Columns
:
[]
*
schema
.
Column
{
APIKeysColumns
[
2
4
]},
RefColumns
:
[]
*
schema
.
Column
{
UsersColumns
[
0
]},
RefColumns
:
[]
*
schema
.
Column
{
UsersColumns
[
0
]},
OnDelete
:
schema
.
NoAction
,
OnDelete
:
schema
.
NoAction
,
},
},
...
@@ -59,12 +60,12 @@ var (
...
@@ -59,12 +60,12 @@ var (
{
{
Name
:
"apikey_user_id"
,
Name
:
"apikey_user_id"
,
Unique
:
false
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
APIKeysColumns
[
2
3
]},
Columns
:
[]
*
schema
.
Column
{
APIKeysColumns
[
2
4
]},
},
},
{
{
Name
:
"apikey_group_id"
,
Name
:
"apikey_group_id"
,
Unique
:
false
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
APIKeysColumns
[
2
2
]},
Columns
:
[]
*
schema
.
Column
{
APIKeysColumns
[
2
3
]},
},
},
{
{
Name
:
"apikey_status"
,
Name
:
"apikey_status"
,
...
@@ -797,6 +798,38 @@ var (
...
@@ -797,6 +798,38 @@ var (
},
},
},
},
}
}
// RequestCaptureLogsColumns holds the columns for the "request_capture_logs" table.
RequestCaptureLogsColumns
=
[]
*
schema
.
Column
{
{
Name
:
"id"
,
Type
:
field
.
TypeInt64
,
Increment
:
true
},
{
Name
:
"api_key_id"
,
Type
:
field
.
TypeInt64
},
{
Name
:
"user_id"
,
Type
:
field
.
TypeInt64
},
{
Name
:
"request_id"
,
Type
:
field
.
TypeString
,
Nullable
:
true
,
Size
:
64
},
{
Name
:
"path"
,
Type
:
field
.
TypeString
,
Nullable
:
true
,
Size
:
100
},
{
Name
:
"method"
,
Type
:
field
.
TypeString
,
Nullable
:
true
,
Size
:
10
},
{
Name
:
"ip_address"
,
Type
:
field
.
TypeString
,
Nullable
:
true
,
Size
:
45
},
{
Name
:
"request_body"
,
Type
:
field
.
TypeString
,
Nullable
:
true
,
Size
:
2147483647
},
{
Name
:
"response_body"
,
Type
:
field
.
TypeString
,
Nullable
:
true
,
Size
:
2147483647
},
{
Name
:
"nfs_file_path"
,
Type
:
field
.
TypeString
,
Nullable
:
true
,
Size
:
500
},
{
Name
:
"created_at"
,
Type
:
field
.
TypeTime
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"timestamptz"
}},
}
// RequestCaptureLogsTable holds the schema information for the "request_capture_logs" table.
RequestCaptureLogsTable
=
&
schema
.
Table
{
Name
:
"request_capture_logs"
,
Columns
:
RequestCaptureLogsColumns
,
PrimaryKey
:
[]
*
schema
.
Column
{
RequestCaptureLogsColumns
[
0
]},
Indexes
:
[]
*
schema
.
Index
{
{
Name
:
"requestcapturelog_api_key_id_created_at"
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
RequestCaptureLogsColumns
[
1
],
RequestCaptureLogsColumns
[
10
]},
},
{
Name
:
"requestcapturelog_user_id"
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
RequestCaptureLogsColumns
[
2
]},
},
},
}
// SecuritySecretsColumns holds the columns for the "security_secrets" table.
// SecuritySecretsColumns holds the columns for the "security_secrets" table.
SecuritySecretsColumns
=
[]
*
schema
.
Column
{
SecuritySecretsColumns
=
[]
*
schema
.
Column
{
{
Name
:
"id"
,
Type
:
field
.
TypeInt64
,
Increment
:
true
},
{
Name
:
"id"
,
Type
:
field
.
TypeInt64
,
Increment
:
true
},
...
@@ -1328,6 +1361,7 @@ var (
...
@@ -1328,6 +1361,7 @@ var (
PromoCodeUsagesTable
,
PromoCodeUsagesTable
,
ProxiesTable
,
ProxiesTable
,
RedeemCodesTable
,
RedeemCodesTable
,
RequestCaptureLogsTable
,
SecuritySecretsTable
,
SecuritySecretsTable
,
SettingsTable
,
SettingsTable
,
SubscriptionPlansTable
,
SubscriptionPlansTable
,
...
@@ -1400,6 +1434,9 @@ func init() {
...
@@ -1400,6 +1434,9 @@ func init() {
RedeemCodesTable
.
Annotation
=
&
entsql
.
Annotation
{
RedeemCodesTable
.
Annotation
=
&
entsql
.
Annotation
{
Table
:
"redeem_codes"
,
Table
:
"redeem_codes"
,
}
}
RequestCaptureLogsTable
.
Annotation
=
&
entsql
.
Annotation
{
Table
:
"request_capture_logs"
,
}
SecuritySecretsTable
.
Annotation
=
&
entsql
.
Annotation
{
SecuritySecretsTable
.
Annotation
=
&
entsql
.
Annotation
{
Table
:
"security_secrets"
,
Table
:
"security_secrets"
,
}
}
...
...
backend/ent/mutation.go
View file @
994da655
This diff is collapsed.
Click to expand it.
backend/ent/predicate/predicate.go
View file @
994da655
...
@@ -51,6 +51,9 @@ type Proxy func(*sql.Selector)
...
@@ -51,6 +51,9 @@ type Proxy func(*sql.Selector)
// RedeemCode is the predicate function for redeemcode builders.
// RedeemCode is the predicate function for redeemcode builders.
type
RedeemCode
func
(
*
sql
.
Selector
)
type
RedeemCode
func
(
*
sql
.
Selector
)
// RequestCaptureLog is the predicate function for requestcapturelog builders.
type
RequestCaptureLog
func
(
*
sql
.
Selector
)
// SecuritySecret is the predicate function for securitysecret builders.
// SecuritySecret is the predicate function for securitysecret builders.
type
SecuritySecret
func
(
*
sql
.
Selector
)
type
SecuritySecret
func
(
*
sql
.
Selector
)
...
...
backend/ent/requestcapturelog.go
0 → 100644
View file @
994da655
// Code generated by ent, DO NOT EDIT.
package
ent
import
(
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/Wei-Shaw/sub2api/ent/requestcapturelog"
)
// RequestCaptureLog is the model entity for the RequestCaptureLog schema.
type
RequestCaptureLog
struct
{
config
`json:"-"`
// ID of the ent.
ID
int64
`json:"id,omitempty"`
// APIKeyID holds the value of the "api_key_id" field.
APIKeyID
int64
`json:"api_key_id,omitempty"`
// UserID holds the value of the "user_id" field.
UserID
int64
`json:"user_id,omitempty"`
// RequestID holds the value of the "request_id" field.
RequestID
*
string
`json:"request_id,omitempty"`
// Path holds the value of the "path" field.
Path
*
string
`json:"path,omitempty"`
// Method holds the value of the "method" field.
Method
*
string
`json:"method,omitempty"`
// IPAddress holds the value of the "ip_address" field.
IPAddress
*
string
`json:"ip_address,omitempty"`
// RequestBody holds the value of the "request_body" field.
RequestBody
*
string
`json:"request_body,omitempty"`
// ResponseBody holds the value of the "response_body" field.
ResponseBody
*
string
`json:"response_body,omitempty"`
// NfsFilePath holds the value of the "nfs_file_path" field.
NfsFilePath
*
string
`json:"nfs_file_path,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt
time
.
Time
`json:"created_at,omitempty"`
selectValues
sql
.
SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func
(
*
RequestCaptureLog
)
scanValues
(
columns
[]
string
)
([]
any
,
error
)
{
values
:=
make
([]
any
,
len
(
columns
))
for
i
:=
range
columns
{
switch
columns
[
i
]
{
case
requestcapturelog
.
FieldID
,
requestcapturelog
.
FieldAPIKeyID
,
requestcapturelog
.
FieldUserID
:
values
[
i
]
=
new
(
sql
.
NullInt64
)
case
requestcapturelog
.
FieldRequestID
,
requestcapturelog
.
FieldPath
,
requestcapturelog
.
FieldMethod
,
requestcapturelog
.
FieldIPAddress
,
requestcapturelog
.
FieldRequestBody
,
requestcapturelog
.
FieldResponseBody
,
requestcapturelog
.
FieldNfsFilePath
:
values
[
i
]
=
new
(
sql
.
NullString
)
case
requestcapturelog
.
FieldCreatedAt
:
values
[
i
]
=
new
(
sql
.
NullTime
)
default
:
values
[
i
]
=
new
(
sql
.
UnknownType
)
}
}
return
values
,
nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the RequestCaptureLog fields.
func
(
_m
*
RequestCaptureLog
)
assignValues
(
columns
[]
string
,
values
[]
any
)
error
{
if
m
,
n
:=
len
(
values
),
len
(
columns
);
m
<
n
{
return
fmt
.
Errorf
(
"mismatch number of scan values: %d != %d"
,
m
,
n
)
}
for
i
:=
range
columns
{
switch
columns
[
i
]
{
case
requestcapturelog
.
FieldID
:
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullInt64
)
if
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field id"
,
value
)
}
_m
.
ID
=
int64
(
value
.
Int64
)
case
requestcapturelog
.
FieldAPIKeyID
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullInt64
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field api_key_id"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
APIKeyID
=
value
.
Int64
}
case
requestcapturelog
.
FieldUserID
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullInt64
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field user_id"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
UserID
=
value
.
Int64
}
case
requestcapturelog
.
FieldRequestID
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field request_id"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
RequestID
=
new
(
string
)
*
_m
.
RequestID
=
value
.
String
}
case
requestcapturelog
.
FieldPath
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field path"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
Path
=
new
(
string
)
*
_m
.
Path
=
value
.
String
}
case
requestcapturelog
.
FieldMethod
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field method"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
Method
=
new
(
string
)
*
_m
.
Method
=
value
.
String
}
case
requestcapturelog
.
FieldIPAddress
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field ip_address"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
IPAddress
=
new
(
string
)
*
_m
.
IPAddress
=
value
.
String
}
case
requestcapturelog
.
FieldRequestBody
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field request_body"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
RequestBody
=
new
(
string
)
*
_m
.
RequestBody
=
value
.
String
}
case
requestcapturelog
.
FieldResponseBody
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field response_body"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
ResponseBody
=
new
(
string
)
*
_m
.
ResponseBody
=
value
.
String
}
case
requestcapturelog
.
FieldNfsFilePath
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field nfs_file_path"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
NfsFilePath
=
new
(
string
)
*
_m
.
NfsFilePath
=
value
.
String
}
case
requestcapturelog
.
FieldCreatedAt
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullTime
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field created_at"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
CreatedAt
=
value
.
Time
}
default
:
_m
.
selectValues
.
Set
(
columns
[
i
],
values
[
i
])
}
}
return
nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the RequestCaptureLog.
// This includes values selected through modifiers, order, etc.
func
(
_m
*
RequestCaptureLog
)
Value
(
name
string
)
(
ent
.
Value
,
error
)
{
return
_m
.
selectValues
.
Get
(
name
)
}
// Update returns a builder for updating this RequestCaptureLog.
// Note that you need to call RequestCaptureLog.Unwrap() before calling this method if this RequestCaptureLog
// was returned from a transaction, and the transaction was committed or rolled back.
func
(
_m
*
RequestCaptureLog
)
Update
()
*
RequestCaptureLogUpdateOne
{
return
NewRequestCaptureLogClient
(
_m
.
config
)
.
UpdateOne
(
_m
)
}
// Unwrap unwraps the RequestCaptureLog 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.
func
(
_m
*
RequestCaptureLog
)
Unwrap
()
*
RequestCaptureLog
{
_tx
,
ok
:=
_m
.
config
.
driver
.
(
*
txDriver
)
if
!
ok
{
panic
(
"ent: RequestCaptureLog is not a transactional entity"
)
}
_m
.
config
.
driver
=
_tx
.
drv
return
_m
}
// String implements the fmt.Stringer.
func
(
_m
*
RequestCaptureLog
)
String
()
string
{
var
builder
strings
.
Builder
builder
.
WriteString
(
"RequestCaptureLog("
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"id=%v, "
,
_m
.
ID
))
builder
.
WriteString
(
"api_key_id="
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"%v"
,
_m
.
APIKeyID
))
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"user_id="
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"%v"
,
_m
.
UserID
))
builder
.
WriteString
(
", "
)
if
v
:=
_m
.
RequestID
;
v
!=
nil
{
builder
.
WriteString
(
"request_id="
)
builder
.
WriteString
(
*
v
)
}
builder
.
WriteString
(
", "
)
if
v
:=
_m
.
Path
;
v
!=
nil
{
builder
.
WriteString
(
"path="
)
builder
.
WriteString
(
*
v
)
}
builder
.
WriteString
(
", "
)
if
v
:=
_m
.
Method
;
v
!=
nil
{
builder
.
WriteString
(
"method="
)
builder
.
WriteString
(
*
v
)
}
builder
.
WriteString
(
", "
)
if
v
:=
_m
.
IPAddress
;
v
!=
nil
{
builder
.
WriteString
(
"ip_address="
)
builder
.
WriteString
(
*
v
)
}
builder
.
WriteString
(
", "
)
if
v
:=
_m
.
RequestBody
;
v
!=
nil
{
builder
.
WriteString
(
"request_body="
)
builder
.
WriteString
(
*
v
)
}
builder
.
WriteString
(
", "
)
if
v
:=
_m
.
ResponseBody
;
v
!=
nil
{
builder
.
WriteString
(
"response_body="
)
builder
.
WriteString
(
*
v
)
}
builder
.
WriteString
(
", "
)
if
v
:=
_m
.
NfsFilePath
;
v
!=
nil
{
builder
.
WriteString
(
"nfs_file_path="
)
builder
.
WriteString
(
*
v
)
}
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"created_at="
)
builder
.
WriteString
(
_m
.
CreatedAt
.
Format
(
time
.
ANSIC
))
builder
.
WriteByte
(
')'
)
return
builder
.
String
()
}
// RequestCaptureLogs is a parsable slice of RequestCaptureLog.
type
RequestCaptureLogs
[]
*
RequestCaptureLog
backend/ent/requestcapturelog/requestcapturelog.go
0 → 100644
View file @
994da655
// Code generated by ent, DO NOT EDIT.
package
requestcapturelog
import
(
"time"
"entgo.io/ent/dialect/sql"
)
const
(
// Label holds the string label denoting the requestcapturelog type in the database.
Label
=
"request_capture_log"
// FieldID holds the string denoting the id field in the database.
FieldID
=
"id"
// FieldAPIKeyID holds the string denoting the api_key_id field in the database.
FieldAPIKeyID
=
"api_key_id"
// FieldUserID holds the string denoting the user_id field in the database.
FieldUserID
=
"user_id"
// FieldRequestID holds the string denoting the request_id field in the database.
FieldRequestID
=
"request_id"
// FieldPath holds the string denoting the path field in the database.
FieldPath
=
"path"
// FieldMethod holds the string denoting the method field in the database.
FieldMethod
=
"method"
// FieldIPAddress holds the string denoting the ip_address field in the database.
FieldIPAddress
=
"ip_address"
// FieldRequestBody holds the string denoting the request_body field in the database.
FieldRequestBody
=
"request_body"
// FieldResponseBody holds the string denoting the response_body field in the database.
FieldResponseBody
=
"response_body"
// FieldNfsFilePath holds the string denoting the nfs_file_path field in the database.
FieldNfsFilePath
=
"nfs_file_path"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt
=
"created_at"
// Table holds the table name of the requestcapturelog in the database.
Table
=
"request_capture_logs"
)
// Columns holds all SQL columns for requestcapturelog fields.
var
Columns
=
[]
string
{
FieldID
,
FieldAPIKeyID
,
FieldUserID
,
FieldRequestID
,
FieldPath
,
FieldMethod
,
FieldIPAddress
,
FieldRequestBody
,
FieldResponseBody
,
FieldNfsFilePath
,
FieldCreatedAt
,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func
ValidColumn
(
column
string
)
bool
{
for
i
:=
range
Columns
{
if
column
==
Columns
[
i
]
{
return
true
}
}
return
false
}
var
(
// RequestIDValidator is a validator for the "request_id" field. It is called by the builders before save.
RequestIDValidator
func
(
string
)
error
// PathValidator is a validator for the "path" field. It is called by the builders before save.
PathValidator
func
(
string
)
error
// MethodValidator is a validator for the "method" field. It is called by the builders before save.
MethodValidator
func
(
string
)
error
// IPAddressValidator is a validator for the "ip_address" field. It is called by the builders before save.
IPAddressValidator
func
(
string
)
error
// NfsFilePathValidator is a validator for the "nfs_file_path" field. It is called by the builders before save.
NfsFilePathValidator
func
(
string
)
error
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt
func
()
time
.
Time
)
// OrderOption defines the ordering options for the RequestCaptureLog queries.
type
OrderOption
func
(
*
sql
.
Selector
)
// ByID orders the results by the id field.
func
ByID
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldID
,
opts
...
)
.
ToFunc
()
}
// ByAPIKeyID orders the results by the api_key_id field.
func
ByAPIKeyID
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldAPIKeyID
,
opts
...
)
.
ToFunc
()
}
// ByUserID orders the results by the user_id field.
func
ByUserID
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldUserID
,
opts
...
)
.
ToFunc
()
}
// ByRequestID orders the results by the request_id field.
func
ByRequestID
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldRequestID
,
opts
...
)
.
ToFunc
()
}
// ByPath orders the results by the path field.
func
ByPath
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldPath
,
opts
...
)
.
ToFunc
()
}
// ByMethod orders the results by the method field.
func
ByMethod
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldMethod
,
opts
...
)
.
ToFunc
()
}
// ByIPAddress orders the results by the ip_address field.
func
ByIPAddress
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldIPAddress
,
opts
...
)
.
ToFunc
()
}
// ByRequestBody orders the results by the request_body field.
func
ByRequestBody
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldRequestBody
,
opts
...
)
.
ToFunc
()
}
// ByResponseBody orders the results by the response_body field.
func
ByResponseBody
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldResponseBody
,
opts
...
)
.
ToFunc
()
}
// ByNfsFilePath orders the results by the nfs_file_path field.
func
ByNfsFilePath
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldNfsFilePath
,
opts
...
)
.
ToFunc
()
}
// ByCreatedAt orders the results by the created_at field.
func
ByCreatedAt
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldCreatedAt
,
opts
...
)
.
ToFunc
()
}
backend/ent/requestcapturelog/where.go
0 → 100644
View file @
994da655
This diff is collapsed.
Click to expand it.
backend/ent/requestcapturelog_create.go
0 → 100644
View file @
994da655
This diff is collapsed.
Click to expand it.
backend/ent/requestcapturelog_delete.go
0 → 100644
View file @
994da655
// Code generated by ent, DO NOT EDIT.
package
ent
import
(
"context"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/predicate"
"github.com/Wei-Shaw/sub2api/ent/requestcapturelog"
)
// RequestCaptureLogDelete is the builder for deleting a RequestCaptureLog entity.
type
RequestCaptureLogDelete
struct
{
config
hooks
[]
Hook
mutation
*
RequestCaptureLogMutation
}
// Where appends a list predicates to the RequestCaptureLogDelete builder.
func
(
_d
*
RequestCaptureLogDelete
)
Where
(
ps
...
predicate
.
RequestCaptureLog
)
*
RequestCaptureLogDelete
{
_d
.
mutation
.
Where
(
ps
...
)
return
_d
}
// Exec executes the deletion query and returns how many vertices were deleted.
func
(
_d
*
RequestCaptureLogDelete
)
Exec
(
ctx
context
.
Context
)
(
int
,
error
)
{
return
withHooks
(
ctx
,
_d
.
sqlExec
,
_d
.
mutation
,
_d
.
hooks
)
}
// ExecX is like Exec, but panics if an error occurs.
func
(
_d
*
RequestCaptureLogDelete
)
ExecX
(
ctx
context
.
Context
)
int
{
n
,
err
:=
_d
.
Exec
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
n
}
func
(
_d
*
RequestCaptureLogDelete
)
sqlExec
(
ctx
context
.
Context
)
(
int
,
error
)
{
_spec
:=
sqlgraph
.
NewDeleteSpec
(
requestcapturelog
.
Table
,
sqlgraph
.
NewFieldSpec
(
requestcapturelog
.
FieldID
,
field
.
TypeInt64
))
if
ps
:=
_d
.
mutation
.
predicates
;
len
(
ps
)
>
0
{
_spec
.
Predicate
=
func
(
selector
*
sql
.
Selector
)
{
for
i
:=
range
ps
{
ps
[
i
](
selector
)
}
}
}
affected
,
err
:=
sqlgraph
.
DeleteNodes
(
ctx
,
_d
.
driver
,
_spec
)
if
err
!=
nil
&&
sqlgraph
.
IsConstraintError
(
err
)
{
err
=
&
ConstraintError
{
msg
:
err
.
Error
(),
wrap
:
err
}
}
_d
.
mutation
.
done
=
true
return
affected
,
err
}
// RequestCaptureLogDeleteOne is the builder for deleting a single RequestCaptureLog entity.
type
RequestCaptureLogDeleteOne
struct
{
_d
*
RequestCaptureLogDelete
}
// Where appends a list predicates to the RequestCaptureLogDelete builder.
func
(
_d
*
RequestCaptureLogDeleteOne
)
Where
(
ps
...
predicate
.
RequestCaptureLog
)
*
RequestCaptureLogDeleteOne
{
_d
.
_d
.
mutation
.
Where
(
ps
...
)
return
_d
}
// Exec executes the deletion query.
func
(
_d
*
RequestCaptureLogDeleteOne
)
Exec
(
ctx
context
.
Context
)
error
{
n
,
err
:=
_d
.
_d
.
Exec
(
ctx
)
switch
{
case
err
!=
nil
:
return
err
case
n
==
0
:
return
&
NotFoundError
{
requestcapturelog
.
Label
}
default
:
return
nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func
(
_d
*
RequestCaptureLogDeleteOne
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
_d
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
}
backend/ent/requestcapturelog_query.go
0 → 100644
View file @
994da655
// Code generated by ent, DO NOT EDIT.
package
ent
import
(
"context"
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/predicate"
"github.com/Wei-Shaw/sub2api/ent/requestcapturelog"
)
// RequestCaptureLogQuery is the builder for querying RequestCaptureLog entities.
type
RequestCaptureLogQuery
struct
{
config
ctx
*
QueryContext
order
[]
requestcapturelog
.
OrderOption
inters
[]
Interceptor
predicates
[]
predicate
.
RequestCaptureLog
modifiers
[]
func
(
*
sql
.
Selector
)
// intermediate query (i.e. traversal path).
sql
*
sql
.
Selector
path
func
(
context
.
Context
)
(
*
sql
.
Selector
,
error
)
}
// Where adds a new predicate for the RequestCaptureLogQuery builder.
func
(
_q
*
RequestCaptureLogQuery
)
Where
(
ps
...
predicate
.
RequestCaptureLog
)
*
RequestCaptureLogQuery
{
_q
.
predicates
=
append
(
_q
.
predicates
,
ps
...
)
return
_q
}
// Limit the number of records to be returned by this query.
func
(
_q
*
RequestCaptureLogQuery
)
Limit
(
limit
int
)
*
RequestCaptureLogQuery
{
_q
.
ctx
.
Limit
=
&
limit
return
_q
}
// Offset to start from.
func
(
_q
*
RequestCaptureLogQuery
)
Offset
(
offset
int
)
*
RequestCaptureLogQuery
{
_q
.
ctx
.
Offset
=
&
offset
return
_q
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func
(
_q
*
RequestCaptureLogQuery
)
Unique
(
unique
bool
)
*
RequestCaptureLogQuery
{
_q
.
ctx
.
Unique
=
&
unique
return
_q
}
// Order specifies how the records should be ordered.
func
(
_q
*
RequestCaptureLogQuery
)
Order
(
o
...
requestcapturelog
.
OrderOption
)
*
RequestCaptureLogQuery
{
_q
.
order
=
append
(
_q
.
order
,
o
...
)
return
_q
}
// First returns the first RequestCaptureLog entity from the query.
// Returns a *NotFoundError when no RequestCaptureLog was found.
func
(
_q
*
RequestCaptureLogQuery
)
First
(
ctx
context
.
Context
)
(
*
RequestCaptureLog
,
error
)
{
nodes
,
err
:=
_q
.
Limit
(
1
)
.
All
(
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryFirst
))
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
nodes
)
==
0
{
return
nil
,
&
NotFoundError
{
requestcapturelog
.
Label
}
}
return
nodes
[
0
],
nil
}
// FirstX is like First, but panics if an error occurs.
func
(
_q
*
RequestCaptureLogQuery
)
FirstX
(
ctx
context
.
Context
)
*
RequestCaptureLog
{
node
,
err
:=
_q
.
First
(
ctx
)
if
err
!=
nil
&&
!
IsNotFound
(
err
)
{
panic
(
err
)
}
return
node
}
// FirstID returns the first RequestCaptureLog ID from the query.
// Returns a *NotFoundError when no RequestCaptureLog ID was found.
func
(
_q
*
RequestCaptureLogQuery
)
FirstID
(
ctx
context
.
Context
)
(
id
int64
,
err
error
)
{
var
ids
[]
int64
if
ids
,
err
=
_q
.
Limit
(
1
)
.
IDs
(
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryFirstID
));
err
!=
nil
{
return
}
if
len
(
ids
)
==
0
{
err
=
&
NotFoundError
{
requestcapturelog
.
Label
}
return
}
return
ids
[
0
],
nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func
(
_q
*
RequestCaptureLogQuery
)
FirstIDX
(
ctx
context
.
Context
)
int64
{
id
,
err
:=
_q
.
FirstID
(
ctx
)
if
err
!=
nil
&&
!
IsNotFound
(
err
)
{
panic
(
err
)
}
return
id
}
// Only returns a single RequestCaptureLog entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one RequestCaptureLog entity is found.
// Returns a *NotFoundError when no RequestCaptureLog entities are found.
func
(
_q
*
RequestCaptureLogQuery
)
Only
(
ctx
context
.
Context
)
(
*
RequestCaptureLog
,
error
)
{
nodes
,
err
:=
_q
.
Limit
(
2
)
.
All
(
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryOnly
))
if
err
!=
nil
{
return
nil
,
err
}
switch
len
(
nodes
)
{
case
1
:
return
nodes
[
0
],
nil
case
0
:
return
nil
,
&
NotFoundError
{
requestcapturelog
.
Label
}
default
:
return
nil
,
&
NotSingularError
{
requestcapturelog
.
Label
}
}
}
// OnlyX is like Only, but panics if an error occurs.
func
(
_q
*
RequestCaptureLogQuery
)
OnlyX
(
ctx
context
.
Context
)
*
RequestCaptureLog
{
node
,
err
:=
_q
.
Only
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
node
}
// OnlyID is like Only, but returns the only RequestCaptureLog ID in the query.
// Returns a *NotSingularError when more than one RequestCaptureLog ID is found.
// Returns a *NotFoundError when no entities are found.
func
(
_q
*
RequestCaptureLogQuery
)
OnlyID
(
ctx
context
.
Context
)
(
id
int64
,
err
error
)
{
var
ids
[]
int64
if
ids
,
err
=
_q
.
Limit
(
2
)
.
IDs
(
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryOnlyID
));
err
!=
nil
{
return
}
switch
len
(
ids
)
{
case
1
:
id
=
ids
[
0
]
case
0
:
err
=
&
NotFoundError
{
requestcapturelog
.
Label
}
default
:
err
=
&
NotSingularError
{
requestcapturelog
.
Label
}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func
(
_q
*
RequestCaptureLogQuery
)
OnlyIDX
(
ctx
context
.
Context
)
int64
{
id
,
err
:=
_q
.
OnlyID
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
id
}
// All executes the query and returns a list of RequestCaptureLogs.
func
(
_q
*
RequestCaptureLogQuery
)
All
(
ctx
context
.
Context
)
([]
*
RequestCaptureLog
,
error
)
{
ctx
=
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryAll
)
if
err
:=
_q
.
prepareQuery
(
ctx
);
err
!=
nil
{
return
nil
,
err
}
qr
:=
querierAll
[[]
*
RequestCaptureLog
,
*
RequestCaptureLogQuery
]()
return
withInterceptors
[[]
*
RequestCaptureLog
](
ctx
,
_q
,
qr
,
_q
.
inters
)
}
// AllX is like All, but panics if an error occurs.
func
(
_q
*
RequestCaptureLogQuery
)
AllX
(
ctx
context
.
Context
)
[]
*
RequestCaptureLog
{
nodes
,
err
:=
_q
.
All
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
nodes
}
// IDs executes the query and returns a list of RequestCaptureLog IDs.
func
(
_q
*
RequestCaptureLogQuery
)
IDs
(
ctx
context
.
Context
)
(
ids
[]
int64
,
err
error
)
{
if
_q
.
ctx
.
Unique
==
nil
&&
_q
.
path
!=
nil
{
_q
.
Unique
(
true
)
}
ctx
=
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryIDs
)
if
err
=
_q
.
Select
(
requestcapturelog
.
FieldID
)
.
Scan
(
ctx
,
&
ids
);
err
!=
nil
{
return
nil
,
err
}
return
ids
,
nil
}
// IDsX is like IDs, but panics if an error occurs.
func
(
_q
*
RequestCaptureLogQuery
)
IDsX
(
ctx
context
.
Context
)
[]
int64
{
ids
,
err
:=
_q
.
IDs
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
ids
}
// Count returns the count of the given query.
func
(
_q
*
RequestCaptureLogQuery
)
Count
(
ctx
context
.
Context
)
(
int
,
error
)
{
ctx
=
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryCount
)
if
err
:=
_q
.
prepareQuery
(
ctx
);
err
!=
nil
{
return
0
,
err
}
return
withInterceptors
[
int
](
ctx
,
_q
,
querierCount
[
*
RequestCaptureLogQuery
](),
_q
.
inters
)
}
// CountX is like Count, but panics if an error occurs.
func
(
_q
*
RequestCaptureLogQuery
)
CountX
(
ctx
context
.
Context
)
int
{
count
,
err
:=
_q
.
Count
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
count
}
// Exist returns true if the query has elements in the graph.
func
(
_q
*
RequestCaptureLogQuery
)
Exist
(
ctx
context
.
Context
)
(
bool
,
error
)
{
ctx
=
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryExist
)
switch
_
,
err
:=
_q
.
FirstID
(
ctx
);
{
case
IsNotFound
(
err
)
:
return
false
,
nil
case
err
!=
nil
:
return
false
,
fmt
.
Errorf
(
"ent: check existence: %w"
,
err
)
default
:
return
true
,
nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func
(
_q
*
RequestCaptureLogQuery
)
ExistX
(
ctx
context
.
Context
)
bool
{
exist
,
err
:=
_q
.
Exist
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
exist
}
// Clone returns a duplicate of the RequestCaptureLogQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func
(
_q
*
RequestCaptureLogQuery
)
Clone
()
*
RequestCaptureLogQuery
{
if
_q
==
nil
{
return
nil
}
return
&
RequestCaptureLogQuery
{
config
:
_q
.
config
,
ctx
:
_q
.
ctx
.
Clone
(),
order
:
append
([]
requestcapturelog
.
OrderOption
{},
_q
.
order
...
),
inters
:
append
([]
Interceptor
{},
_q
.
inters
...
),
predicates
:
append
([]
predicate
.
RequestCaptureLog
{},
_q
.
predicates
...
),
// clone intermediate query.
sql
:
_q
.
sql
.
Clone
(),
path
:
_q
.
path
,
}
}
// GroupBy is used to group vertices by one or more fields/columns.
// It is often used with aggregate functions, like: count, max, mean, min, sum.
//
// Example:
//
// var v []struct {
// APIKeyID int64 `json:"api_key_id,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.RequestCaptureLog.Query().
// GroupBy(requestcapturelog.FieldAPIKeyID).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func
(
_q
*
RequestCaptureLogQuery
)
GroupBy
(
field
string
,
fields
...
string
)
*
RequestCaptureLogGroupBy
{
_q
.
ctx
.
Fields
=
append
([]
string
{
field
},
fields
...
)
grbuild
:=
&
RequestCaptureLogGroupBy
{
build
:
_q
}
grbuild
.
flds
=
&
_q
.
ctx
.
Fields
grbuild
.
label
=
requestcapturelog
.
Label
grbuild
.
scan
=
grbuild
.
Scan
return
grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// APIKeyID int64 `json:"api_key_id,omitempty"`
// }
//
// client.RequestCaptureLog.Query().
// Select(requestcapturelog.FieldAPIKeyID).
// Scan(ctx, &v)
func
(
_q
*
RequestCaptureLogQuery
)
Select
(
fields
...
string
)
*
RequestCaptureLogSelect
{
_q
.
ctx
.
Fields
=
append
(
_q
.
ctx
.
Fields
,
fields
...
)
sbuild
:=
&
RequestCaptureLogSelect
{
RequestCaptureLogQuery
:
_q
}
sbuild
.
label
=
requestcapturelog
.
Label
sbuild
.
flds
,
sbuild
.
scan
=
&
_q
.
ctx
.
Fields
,
sbuild
.
Scan
return
sbuild
}
// Aggregate returns a RequestCaptureLogSelect configured with the given aggregations.
func
(
_q
*
RequestCaptureLogQuery
)
Aggregate
(
fns
...
AggregateFunc
)
*
RequestCaptureLogSelect
{
return
_q
.
Select
()
.
Aggregate
(
fns
...
)
}
func
(
_q
*
RequestCaptureLogQuery
)
prepareQuery
(
ctx
context
.
Context
)
error
{
for
_
,
inter
:=
range
_q
.
inters
{
if
inter
==
nil
{
return
fmt
.
Errorf
(
"ent: uninitialized interceptor (forgotten import ent/runtime?)"
)
}
if
trv
,
ok
:=
inter
.
(
Traverser
);
ok
{
if
err
:=
trv
.
Traverse
(
ctx
,
_q
);
err
!=
nil
{
return
err
}
}
}
for
_
,
f
:=
range
_q
.
ctx
.
Fields
{
if
!
requestcapturelog
.
ValidColumn
(
f
)
{
return
&
ValidationError
{
Name
:
f
,
err
:
fmt
.
Errorf
(
"ent: invalid field %q for query"
,
f
)}
}
}
if
_q
.
path
!=
nil
{
prev
,
err
:=
_q
.
path
(
ctx
)
if
err
!=
nil
{
return
err
}
_q
.
sql
=
prev
}
return
nil
}
func
(
_q
*
RequestCaptureLogQuery
)
sqlAll
(
ctx
context
.
Context
,
hooks
...
queryHook
)
([]
*
RequestCaptureLog
,
error
)
{
var
(
nodes
=
[]
*
RequestCaptureLog
{}
_spec
=
_q
.
querySpec
()
)
_spec
.
ScanValues
=
func
(
columns
[]
string
)
([]
any
,
error
)
{
return
(
*
RequestCaptureLog
)
.
scanValues
(
nil
,
columns
)
}
_spec
.
Assign
=
func
(
columns
[]
string
,
values
[]
any
)
error
{
node
:=
&
RequestCaptureLog
{
config
:
_q
.
config
}
nodes
=
append
(
nodes
,
node
)
return
node
.
assignValues
(
columns
,
values
)
}
if
len
(
_q
.
modifiers
)
>
0
{
_spec
.
Modifiers
=
_q
.
modifiers
}
for
i
:=
range
hooks
{
hooks
[
i
](
ctx
,
_spec
)
}
if
err
:=
sqlgraph
.
QueryNodes
(
ctx
,
_q
.
driver
,
_spec
);
err
!=
nil
{
return
nil
,
err
}
if
len
(
nodes
)
==
0
{
return
nodes
,
nil
}
return
nodes
,
nil
}
func
(
_q
*
RequestCaptureLogQuery
)
sqlCount
(
ctx
context
.
Context
)
(
int
,
error
)
{
_spec
:=
_q
.
querySpec
()
if
len
(
_q
.
modifiers
)
>
0
{
_spec
.
Modifiers
=
_q
.
modifiers
}
_spec
.
Node
.
Columns
=
_q
.
ctx
.
Fields
if
len
(
_q
.
ctx
.
Fields
)
>
0
{
_spec
.
Unique
=
_q
.
ctx
.
Unique
!=
nil
&&
*
_q
.
ctx
.
Unique
}
return
sqlgraph
.
CountNodes
(
ctx
,
_q
.
driver
,
_spec
)
}
func
(
_q
*
RequestCaptureLogQuery
)
querySpec
()
*
sqlgraph
.
QuerySpec
{
_spec
:=
sqlgraph
.
NewQuerySpec
(
requestcapturelog
.
Table
,
requestcapturelog
.
Columns
,
sqlgraph
.
NewFieldSpec
(
requestcapturelog
.
FieldID
,
field
.
TypeInt64
))
_spec
.
From
=
_q
.
sql
if
unique
:=
_q
.
ctx
.
Unique
;
unique
!=
nil
{
_spec
.
Unique
=
*
unique
}
else
if
_q
.
path
!=
nil
{
_spec
.
Unique
=
true
}
if
fields
:=
_q
.
ctx
.
Fields
;
len
(
fields
)
>
0
{
_spec
.
Node
.
Columns
=
make
([]
string
,
0
,
len
(
fields
))
_spec
.
Node
.
Columns
=
append
(
_spec
.
Node
.
Columns
,
requestcapturelog
.
FieldID
)
for
i
:=
range
fields
{
if
fields
[
i
]
!=
requestcapturelog
.
FieldID
{
_spec
.
Node
.
Columns
=
append
(
_spec
.
Node
.
Columns
,
fields
[
i
])
}
}
}
if
ps
:=
_q
.
predicates
;
len
(
ps
)
>
0
{
_spec
.
Predicate
=
func
(
selector
*
sql
.
Selector
)
{
for
i
:=
range
ps
{
ps
[
i
](
selector
)
}
}
}
if
limit
:=
_q
.
ctx
.
Limit
;
limit
!=
nil
{
_spec
.
Limit
=
*
limit
}
if
offset
:=
_q
.
ctx
.
Offset
;
offset
!=
nil
{
_spec
.
Offset
=
*
offset
}
if
ps
:=
_q
.
order
;
len
(
ps
)
>
0
{
_spec
.
Order
=
func
(
selector
*
sql
.
Selector
)
{
for
i
:=
range
ps
{
ps
[
i
](
selector
)
}
}
}
return
_spec
}
func
(
_q
*
RequestCaptureLogQuery
)
sqlQuery
(
ctx
context
.
Context
)
*
sql
.
Selector
{
builder
:=
sql
.
Dialect
(
_q
.
driver
.
Dialect
())
t1
:=
builder
.
Table
(
requestcapturelog
.
Table
)
columns
:=
_q
.
ctx
.
Fields
if
len
(
columns
)
==
0
{
columns
=
requestcapturelog
.
Columns
}
selector
:=
builder
.
Select
(
t1
.
Columns
(
columns
...
)
...
)
.
From
(
t1
)
if
_q
.
sql
!=
nil
{
selector
=
_q
.
sql
selector
.
Select
(
selector
.
Columns
(
columns
...
)
...
)
}
if
_q
.
ctx
.
Unique
!=
nil
&&
*
_q
.
ctx
.
Unique
{
selector
.
Distinct
()
}
for
_
,
m
:=
range
_q
.
modifiers
{
m
(
selector
)
}
for
_
,
p
:=
range
_q
.
predicates
{
p
(
selector
)
}
for
_
,
p
:=
range
_q
.
order
{
p
(
selector
)
}
if
offset
:=
_q
.
ctx
.
Offset
;
offset
!=
nil
{
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector
.
Offset
(
*
offset
)
.
Limit
(
math
.
MaxInt32
)
}
if
limit
:=
_q
.
ctx
.
Limit
;
limit
!=
nil
{
selector
.
Limit
(
*
limit
)
}
return
selector
}
// ForUpdate locks the selected rows against concurrent updates, and prevent them from being
// updated, deleted or "selected ... for update" by other sessions, until the transaction is
// either committed or rolled-back.
func
(
_q
*
RequestCaptureLogQuery
)
ForUpdate
(
opts
...
sql
.
LockOption
)
*
RequestCaptureLogQuery
{
if
_q
.
driver
.
Dialect
()
==
dialect
.
Postgres
{
_q
.
Unique
(
false
)
}
_q
.
modifiers
=
append
(
_q
.
modifiers
,
func
(
s
*
sql
.
Selector
)
{
s
.
ForUpdate
(
opts
...
)
})
return
_q
}
// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock
// on any rows that are read. Other sessions can read the rows, but cannot modify them
// until your transaction commits.
func
(
_q
*
RequestCaptureLogQuery
)
ForShare
(
opts
...
sql
.
LockOption
)
*
RequestCaptureLogQuery
{
if
_q
.
driver
.
Dialect
()
==
dialect
.
Postgres
{
_q
.
Unique
(
false
)
}
_q
.
modifiers
=
append
(
_q
.
modifiers
,
func
(
s
*
sql
.
Selector
)
{
s
.
ForShare
(
opts
...
)
})
return
_q
}
// RequestCaptureLogGroupBy is the group-by builder for RequestCaptureLog entities.
type
RequestCaptureLogGroupBy
struct
{
selector
build
*
RequestCaptureLogQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func
(
_g
*
RequestCaptureLogGroupBy
)
Aggregate
(
fns
...
AggregateFunc
)
*
RequestCaptureLogGroupBy
{
_g
.
fns
=
append
(
_g
.
fns
,
fns
...
)
return
_g
}
// Scan applies the selector query and scans the result into the given value.
func
(
_g
*
RequestCaptureLogGroupBy
)
Scan
(
ctx
context
.
Context
,
v
any
)
error
{
ctx
=
setContextOp
(
ctx
,
_g
.
build
.
ctx
,
ent
.
OpQueryGroupBy
)
if
err
:=
_g
.
build
.
prepareQuery
(
ctx
);
err
!=
nil
{
return
err
}
return
scanWithInterceptors
[
*
RequestCaptureLogQuery
,
*
RequestCaptureLogGroupBy
](
ctx
,
_g
.
build
,
_g
,
_g
.
build
.
inters
,
v
)
}
func
(
_g
*
RequestCaptureLogGroupBy
)
sqlScan
(
ctx
context
.
Context
,
root
*
RequestCaptureLogQuery
,
v
any
)
error
{
selector
:=
root
.
sqlQuery
(
ctx
)
.
Select
()
aggregation
:=
make
([]
string
,
0
,
len
(
_g
.
fns
))
for
_
,
fn
:=
range
_g
.
fns
{
aggregation
=
append
(
aggregation
,
fn
(
selector
))
}
if
len
(
selector
.
SelectedColumns
())
==
0
{
columns
:=
make
([]
string
,
0
,
len
(
*
_g
.
flds
)
+
len
(
_g
.
fns
))
for
_
,
f
:=
range
*
_g
.
flds
{
columns
=
append
(
columns
,
selector
.
C
(
f
))
}
columns
=
append
(
columns
,
aggregation
...
)
selector
.
Select
(
columns
...
)
}
selector
.
GroupBy
(
selector
.
Columns
(
*
_g
.
flds
...
)
...
)
if
err
:=
selector
.
Err
();
err
!=
nil
{
return
err
}
rows
:=
&
sql
.
Rows
{}
query
,
args
:=
selector
.
Query
()
if
err
:=
_g
.
build
.
driver
.
Query
(
ctx
,
query
,
args
,
rows
);
err
!=
nil
{
return
err
}
defer
rows
.
Close
()
return
sql
.
ScanSlice
(
rows
,
v
)
}
// RequestCaptureLogSelect is the builder for selecting fields of RequestCaptureLog entities.
type
RequestCaptureLogSelect
struct
{
*
RequestCaptureLogQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func
(
_s
*
RequestCaptureLogSelect
)
Aggregate
(
fns
...
AggregateFunc
)
*
RequestCaptureLogSelect
{
_s
.
fns
=
append
(
_s
.
fns
,
fns
...
)
return
_s
}
// Scan applies the selector query and scans the result into the given value.
func
(
_s
*
RequestCaptureLogSelect
)
Scan
(
ctx
context
.
Context
,
v
any
)
error
{
ctx
=
setContextOp
(
ctx
,
_s
.
ctx
,
ent
.
OpQuerySelect
)
if
err
:=
_s
.
prepareQuery
(
ctx
);
err
!=
nil
{
return
err
}
return
scanWithInterceptors
[
*
RequestCaptureLogQuery
,
*
RequestCaptureLogSelect
](
ctx
,
_s
.
RequestCaptureLogQuery
,
_s
,
_s
.
inters
,
v
)
}
func
(
_s
*
RequestCaptureLogSelect
)
sqlScan
(
ctx
context
.
Context
,
root
*
RequestCaptureLogQuery
,
v
any
)
error
{
selector
:=
root
.
sqlQuery
(
ctx
)
aggregation
:=
make
([]
string
,
0
,
len
(
_s
.
fns
))
for
_
,
fn
:=
range
_s
.
fns
{
aggregation
=
append
(
aggregation
,
fn
(
selector
))
}
switch
n
:=
len
(
*
_s
.
selector
.
flds
);
{
case
n
==
0
&&
len
(
aggregation
)
>
0
:
selector
.
Select
(
aggregation
...
)
case
n
!=
0
&&
len
(
aggregation
)
>
0
:
selector
.
AppendSelect
(
aggregation
...
)
}
rows
:=
&
sql
.
Rows
{}
query
,
args
:=
selector
.
Query
()
if
err
:=
_s
.
driver
.
Query
(
ctx
,
query
,
args
,
rows
);
err
!=
nil
{
return
err
}
defer
rows
.
Close
()
return
sql
.
ScanSlice
(
rows
,
v
)
}
backend/ent/requestcapturelog_update.go
0 → 100644
View file @
994da655
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment