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
bb664d9b
Commit
bb664d9b
authored
Feb 28, 2026
by
yangjianbo
Browse files
feat(sync): full code sync from release
parent
bfc7b339
Changes
244
Hide whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
244 of 244+
files are displayed.
Plain diff
Email patch
backend/ent/group/group.go
View file @
bb664d9b
...
@@ -57,6 +57,8 @@ const (
...
@@ -57,6 +57,8 @@ const (
FieldSoraVideoPricePerRequest
=
"sora_video_price_per_request"
FieldSoraVideoPricePerRequest
=
"sora_video_price_per_request"
// FieldSoraVideoPricePerRequestHd holds the string denoting the sora_video_price_per_request_hd field in the database.
// FieldSoraVideoPricePerRequestHd holds the string denoting the sora_video_price_per_request_hd field in the database.
FieldSoraVideoPricePerRequestHd
=
"sora_video_price_per_request_hd"
FieldSoraVideoPricePerRequestHd
=
"sora_video_price_per_request_hd"
// FieldSoraStorageQuotaBytes holds the string denoting the sora_storage_quota_bytes field in the database.
FieldSoraStorageQuotaBytes
=
"sora_storage_quota_bytes"
// FieldClaudeCodeOnly holds the string denoting the claude_code_only field in the database.
// FieldClaudeCodeOnly holds the string denoting the claude_code_only field in the database.
FieldClaudeCodeOnly
=
"claude_code_only"
FieldClaudeCodeOnly
=
"claude_code_only"
// FieldFallbackGroupID holds the string denoting the fallback_group_id field in the database.
// FieldFallbackGroupID holds the string denoting the fallback_group_id field in the database.
...
@@ -169,6 +171,7 @@ var Columns = []string{
...
@@ -169,6 +171,7 @@ var Columns = []string{
FieldSoraImagePrice540
,
FieldSoraImagePrice540
,
FieldSoraVideoPricePerRequest
,
FieldSoraVideoPricePerRequest
,
FieldSoraVideoPricePerRequestHd
,
FieldSoraVideoPricePerRequestHd
,
FieldSoraStorageQuotaBytes
,
FieldClaudeCodeOnly
,
FieldClaudeCodeOnly
,
FieldFallbackGroupID
,
FieldFallbackGroupID
,
FieldFallbackGroupIDOnInvalidRequest
,
FieldFallbackGroupIDOnInvalidRequest
,
...
@@ -232,6 +235,8 @@ var (
...
@@ -232,6 +235,8 @@ var (
SubscriptionTypeValidator
func
(
string
)
error
SubscriptionTypeValidator
func
(
string
)
error
// DefaultDefaultValidityDays holds the default value on creation for the "default_validity_days" field.
// DefaultDefaultValidityDays holds the default value on creation for the "default_validity_days" field.
DefaultDefaultValidityDays
int
DefaultDefaultValidityDays
int
// DefaultSoraStorageQuotaBytes holds the default value on creation for the "sora_storage_quota_bytes" field.
DefaultSoraStorageQuotaBytes
int64
// DefaultClaudeCodeOnly holds the default value on creation for the "claude_code_only" field.
// DefaultClaudeCodeOnly holds the default value on creation for the "claude_code_only" field.
DefaultClaudeCodeOnly
bool
DefaultClaudeCodeOnly
bool
// DefaultModelRoutingEnabled holds the default value on creation for the "model_routing_enabled" field.
// DefaultModelRoutingEnabled holds the default value on creation for the "model_routing_enabled" field.
...
@@ -357,6 +362,11 @@ func BySoraVideoPricePerRequestHd(opts ...sql.OrderTermOption) OrderOption {
...
@@ -357,6 +362,11 @@ func BySoraVideoPricePerRequestHd(opts ...sql.OrderTermOption) OrderOption {
return
sql
.
OrderByField
(
FieldSoraVideoPricePerRequestHd
,
opts
...
)
.
ToFunc
()
return
sql
.
OrderByField
(
FieldSoraVideoPricePerRequestHd
,
opts
...
)
.
ToFunc
()
}
}
// BySoraStorageQuotaBytes orders the results by the sora_storage_quota_bytes field.
func
BySoraStorageQuotaBytes
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldSoraStorageQuotaBytes
,
opts
...
)
.
ToFunc
()
}
// ByClaudeCodeOnly orders the results by the claude_code_only field.
// ByClaudeCodeOnly orders the results by the claude_code_only field.
func
ByClaudeCodeOnly
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
func
ByClaudeCodeOnly
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldClaudeCodeOnly
,
opts
...
)
.
ToFunc
()
return
sql
.
OrderByField
(
FieldClaudeCodeOnly
,
opts
...
)
.
ToFunc
()
...
...
backend/ent/group/where.go
View file @
bb664d9b
...
@@ -160,6 +160,11 @@ func SoraVideoPricePerRequestHd(v float64) predicate.Group {
...
@@ -160,6 +160,11 @@ func SoraVideoPricePerRequestHd(v float64) predicate.Group {
return
predicate
.
Group
(
sql
.
FieldEQ
(
FieldSoraVideoPricePerRequestHd
,
v
))
return
predicate
.
Group
(
sql
.
FieldEQ
(
FieldSoraVideoPricePerRequestHd
,
v
))
}
}
// SoraStorageQuotaBytes applies equality check predicate on the "sora_storage_quota_bytes" field. It's identical to SoraStorageQuotaBytesEQ.
func
SoraStorageQuotaBytes
(
v
int64
)
predicate
.
Group
{
return
predicate
.
Group
(
sql
.
FieldEQ
(
FieldSoraStorageQuotaBytes
,
v
))
}
// ClaudeCodeOnly applies equality check predicate on the "claude_code_only" field. It's identical to ClaudeCodeOnlyEQ.
// ClaudeCodeOnly applies equality check predicate on the "claude_code_only" field. It's identical to ClaudeCodeOnlyEQ.
func
ClaudeCodeOnly
(
v
bool
)
predicate
.
Group
{
func
ClaudeCodeOnly
(
v
bool
)
predicate
.
Group
{
return
predicate
.
Group
(
sql
.
FieldEQ
(
FieldClaudeCodeOnly
,
v
))
return
predicate
.
Group
(
sql
.
FieldEQ
(
FieldClaudeCodeOnly
,
v
))
...
@@ -1245,6 +1250,46 @@ func SoraVideoPricePerRequestHdNotNil() predicate.Group {
...
@@ -1245,6 +1250,46 @@ func SoraVideoPricePerRequestHdNotNil() predicate.Group {
return
predicate
.
Group
(
sql
.
FieldNotNull
(
FieldSoraVideoPricePerRequestHd
))
return
predicate
.
Group
(
sql
.
FieldNotNull
(
FieldSoraVideoPricePerRequestHd
))
}
}
// SoraStorageQuotaBytesEQ applies the EQ predicate on the "sora_storage_quota_bytes" field.
func
SoraStorageQuotaBytesEQ
(
v
int64
)
predicate
.
Group
{
return
predicate
.
Group
(
sql
.
FieldEQ
(
FieldSoraStorageQuotaBytes
,
v
))
}
// SoraStorageQuotaBytesNEQ applies the NEQ predicate on the "sora_storage_quota_bytes" field.
func
SoraStorageQuotaBytesNEQ
(
v
int64
)
predicate
.
Group
{
return
predicate
.
Group
(
sql
.
FieldNEQ
(
FieldSoraStorageQuotaBytes
,
v
))
}
// SoraStorageQuotaBytesIn applies the In predicate on the "sora_storage_quota_bytes" field.
func
SoraStorageQuotaBytesIn
(
vs
...
int64
)
predicate
.
Group
{
return
predicate
.
Group
(
sql
.
FieldIn
(
FieldSoraStorageQuotaBytes
,
vs
...
))
}
// SoraStorageQuotaBytesNotIn applies the NotIn predicate on the "sora_storage_quota_bytes" field.
func
SoraStorageQuotaBytesNotIn
(
vs
...
int64
)
predicate
.
Group
{
return
predicate
.
Group
(
sql
.
FieldNotIn
(
FieldSoraStorageQuotaBytes
,
vs
...
))
}
// SoraStorageQuotaBytesGT applies the GT predicate on the "sora_storage_quota_bytes" field.
func
SoraStorageQuotaBytesGT
(
v
int64
)
predicate
.
Group
{
return
predicate
.
Group
(
sql
.
FieldGT
(
FieldSoraStorageQuotaBytes
,
v
))
}
// SoraStorageQuotaBytesGTE applies the GTE predicate on the "sora_storage_quota_bytes" field.
func
SoraStorageQuotaBytesGTE
(
v
int64
)
predicate
.
Group
{
return
predicate
.
Group
(
sql
.
FieldGTE
(
FieldSoraStorageQuotaBytes
,
v
))
}
// SoraStorageQuotaBytesLT applies the LT predicate on the "sora_storage_quota_bytes" field.
func
SoraStorageQuotaBytesLT
(
v
int64
)
predicate
.
Group
{
return
predicate
.
Group
(
sql
.
FieldLT
(
FieldSoraStorageQuotaBytes
,
v
))
}
// SoraStorageQuotaBytesLTE applies the LTE predicate on the "sora_storage_quota_bytes" field.
func
SoraStorageQuotaBytesLTE
(
v
int64
)
predicate
.
Group
{
return
predicate
.
Group
(
sql
.
FieldLTE
(
FieldSoraStorageQuotaBytes
,
v
))
}
// ClaudeCodeOnlyEQ applies the EQ predicate on the "claude_code_only" field.
// ClaudeCodeOnlyEQ applies the EQ predicate on the "claude_code_only" field.
func
ClaudeCodeOnlyEQ
(
v
bool
)
predicate
.
Group
{
func
ClaudeCodeOnlyEQ
(
v
bool
)
predicate
.
Group
{
return
predicate
.
Group
(
sql
.
FieldEQ
(
FieldClaudeCodeOnly
,
v
))
return
predicate
.
Group
(
sql
.
FieldEQ
(
FieldClaudeCodeOnly
,
v
))
...
...
backend/ent/group_create.go
View file @
bb664d9b
...
@@ -314,6 +314,20 @@ func (_c *GroupCreate) SetNillableSoraVideoPricePerRequestHd(v *float64) *GroupC
...
@@ -314,6 +314,20 @@ func (_c *GroupCreate) SetNillableSoraVideoPricePerRequestHd(v *float64) *GroupC
return
_c
return
_c
}
}
// SetSoraStorageQuotaBytes sets the "sora_storage_quota_bytes" field.
func
(
_c
*
GroupCreate
)
SetSoraStorageQuotaBytes
(
v
int64
)
*
GroupCreate
{
_c
.
mutation
.
SetSoraStorageQuotaBytes
(
v
)
return
_c
}
// SetNillableSoraStorageQuotaBytes sets the "sora_storage_quota_bytes" field if the given value is not nil.
func
(
_c
*
GroupCreate
)
SetNillableSoraStorageQuotaBytes
(
v
*
int64
)
*
GroupCreate
{
if
v
!=
nil
{
_c
.
SetSoraStorageQuotaBytes
(
*
v
)
}
return
_c
}
// SetClaudeCodeOnly sets the "claude_code_only" field.
// SetClaudeCodeOnly sets the "claude_code_only" field.
func
(
_c
*
GroupCreate
)
SetClaudeCodeOnly
(
v
bool
)
*
GroupCreate
{
func
(
_c
*
GroupCreate
)
SetClaudeCodeOnly
(
v
bool
)
*
GroupCreate
{
_c
.
mutation
.
SetClaudeCodeOnly
(
v
)
_c
.
mutation
.
SetClaudeCodeOnly
(
v
)
...
@@ -575,6 +589,10 @@ func (_c *GroupCreate) defaults() error {
...
@@ -575,6 +589,10 @@ func (_c *GroupCreate) defaults() error {
v
:=
group
.
DefaultDefaultValidityDays
v
:=
group
.
DefaultDefaultValidityDays
_c
.
mutation
.
SetDefaultValidityDays
(
v
)
_c
.
mutation
.
SetDefaultValidityDays
(
v
)
}
}
if
_
,
ok
:=
_c
.
mutation
.
SoraStorageQuotaBytes
();
!
ok
{
v
:=
group
.
DefaultSoraStorageQuotaBytes
_c
.
mutation
.
SetSoraStorageQuotaBytes
(
v
)
}
if
_
,
ok
:=
_c
.
mutation
.
ClaudeCodeOnly
();
!
ok
{
if
_
,
ok
:=
_c
.
mutation
.
ClaudeCodeOnly
();
!
ok
{
v
:=
group
.
DefaultClaudeCodeOnly
v
:=
group
.
DefaultClaudeCodeOnly
_c
.
mutation
.
SetClaudeCodeOnly
(
v
)
_c
.
mutation
.
SetClaudeCodeOnly
(
v
)
...
@@ -647,6 +665,9 @@ func (_c *GroupCreate) check() error {
...
@@ -647,6 +665,9 @@ func (_c *GroupCreate) check() error {
if
_
,
ok
:=
_c
.
mutation
.
DefaultValidityDays
();
!
ok
{
if
_
,
ok
:=
_c
.
mutation
.
DefaultValidityDays
();
!
ok
{
return
&
ValidationError
{
Name
:
"default_validity_days"
,
err
:
errors
.
New
(
`ent: missing required field "Group.default_validity_days"`
)}
return
&
ValidationError
{
Name
:
"default_validity_days"
,
err
:
errors
.
New
(
`ent: missing required field "Group.default_validity_days"`
)}
}
}
if
_
,
ok
:=
_c
.
mutation
.
SoraStorageQuotaBytes
();
!
ok
{
return
&
ValidationError
{
Name
:
"sora_storage_quota_bytes"
,
err
:
errors
.
New
(
`ent: missing required field "Group.sora_storage_quota_bytes"`
)}
}
if
_
,
ok
:=
_c
.
mutation
.
ClaudeCodeOnly
();
!
ok
{
if
_
,
ok
:=
_c
.
mutation
.
ClaudeCodeOnly
();
!
ok
{
return
&
ValidationError
{
Name
:
"claude_code_only"
,
err
:
errors
.
New
(
`ent: missing required field "Group.claude_code_only"`
)}
return
&
ValidationError
{
Name
:
"claude_code_only"
,
err
:
errors
.
New
(
`ent: missing required field "Group.claude_code_only"`
)}
}
}
...
@@ -773,6 +794,10 @@ func (_c *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) {
...
@@ -773,6 +794,10 @@ func (_c *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) {
_spec
.
SetField
(
group
.
FieldSoraVideoPricePerRequestHd
,
field
.
TypeFloat64
,
value
)
_spec
.
SetField
(
group
.
FieldSoraVideoPricePerRequestHd
,
field
.
TypeFloat64
,
value
)
_node
.
SoraVideoPricePerRequestHd
=
&
value
_node
.
SoraVideoPricePerRequestHd
=
&
value
}
}
if
value
,
ok
:=
_c
.
mutation
.
SoraStorageQuotaBytes
();
ok
{
_spec
.
SetField
(
group
.
FieldSoraStorageQuotaBytes
,
field
.
TypeInt64
,
value
)
_node
.
SoraStorageQuotaBytes
=
value
}
if
value
,
ok
:=
_c
.
mutation
.
ClaudeCodeOnly
();
ok
{
if
value
,
ok
:=
_c
.
mutation
.
ClaudeCodeOnly
();
ok
{
_spec
.
SetField
(
group
.
FieldClaudeCodeOnly
,
field
.
TypeBool
,
value
)
_spec
.
SetField
(
group
.
FieldClaudeCodeOnly
,
field
.
TypeBool
,
value
)
_node
.
ClaudeCodeOnly
=
value
_node
.
ClaudeCodeOnly
=
value
...
@@ -1345,6 +1370,24 @@ func (u *GroupUpsert) ClearSoraVideoPricePerRequestHd() *GroupUpsert {
...
@@ -1345,6 +1370,24 @@ func (u *GroupUpsert) ClearSoraVideoPricePerRequestHd() *GroupUpsert {
return
u
return
u
}
}
// SetSoraStorageQuotaBytes sets the "sora_storage_quota_bytes" field.
func
(
u
*
GroupUpsert
)
SetSoraStorageQuotaBytes
(
v
int64
)
*
GroupUpsert
{
u
.
Set
(
group
.
FieldSoraStorageQuotaBytes
,
v
)
return
u
}
// UpdateSoraStorageQuotaBytes sets the "sora_storage_quota_bytes" field to the value that was provided on create.
func
(
u
*
GroupUpsert
)
UpdateSoraStorageQuotaBytes
()
*
GroupUpsert
{
u
.
SetExcluded
(
group
.
FieldSoraStorageQuotaBytes
)
return
u
}
// AddSoraStorageQuotaBytes adds v to the "sora_storage_quota_bytes" field.
func
(
u
*
GroupUpsert
)
AddSoraStorageQuotaBytes
(
v
int64
)
*
GroupUpsert
{
u
.
Add
(
group
.
FieldSoraStorageQuotaBytes
,
v
)
return
u
}
// SetClaudeCodeOnly sets the "claude_code_only" field.
// SetClaudeCodeOnly sets the "claude_code_only" field.
func
(
u
*
GroupUpsert
)
SetClaudeCodeOnly
(
v
bool
)
*
GroupUpsert
{
func
(
u
*
GroupUpsert
)
SetClaudeCodeOnly
(
v
bool
)
*
GroupUpsert
{
u
.
Set
(
group
.
FieldClaudeCodeOnly
,
v
)
u
.
Set
(
group
.
FieldClaudeCodeOnly
,
v
)
...
@@ -1970,6 +2013,27 @@ func (u *GroupUpsertOne) ClearSoraVideoPricePerRequestHd() *GroupUpsertOne {
...
@@ -1970,6 +2013,27 @@ func (u *GroupUpsertOne) ClearSoraVideoPricePerRequestHd() *GroupUpsertOne {
})
})
}
}
// SetSoraStorageQuotaBytes sets the "sora_storage_quota_bytes" field.
func
(
u
*
GroupUpsertOne
)
SetSoraStorageQuotaBytes
(
v
int64
)
*
GroupUpsertOne
{
return
u
.
Update
(
func
(
s
*
GroupUpsert
)
{
s
.
SetSoraStorageQuotaBytes
(
v
)
})
}
// AddSoraStorageQuotaBytes adds v to the "sora_storage_quota_bytes" field.
func
(
u
*
GroupUpsertOne
)
AddSoraStorageQuotaBytes
(
v
int64
)
*
GroupUpsertOne
{
return
u
.
Update
(
func
(
s
*
GroupUpsert
)
{
s
.
AddSoraStorageQuotaBytes
(
v
)
})
}
// UpdateSoraStorageQuotaBytes sets the "sora_storage_quota_bytes" field to the value that was provided on create.
func
(
u
*
GroupUpsertOne
)
UpdateSoraStorageQuotaBytes
()
*
GroupUpsertOne
{
return
u
.
Update
(
func
(
s
*
GroupUpsert
)
{
s
.
UpdateSoraStorageQuotaBytes
()
})
}
// SetClaudeCodeOnly sets the "claude_code_only" field.
// SetClaudeCodeOnly sets the "claude_code_only" field.
func
(
u
*
GroupUpsertOne
)
SetClaudeCodeOnly
(
v
bool
)
*
GroupUpsertOne
{
func
(
u
*
GroupUpsertOne
)
SetClaudeCodeOnly
(
v
bool
)
*
GroupUpsertOne
{
return
u
.
Update
(
func
(
s
*
GroupUpsert
)
{
return
u
.
Update
(
func
(
s
*
GroupUpsert
)
{
...
@@ -2783,6 +2847,27 @@ func (u *GroupUpsertBulk) ClearSoraVideoPricePerRequestHd() *GroupUpsertBulk {
...
@@ -2783,6 +2847,27 @@ func (u *GroupUpsertBulk) ClearSoraVideoPricePerRequestHd() *GroupUpsertBulk {
})
})
}
}
// SetSoraStorageQuotaBytes sets the "sora_storage_quota_bytes" field.
func
(
u
*
GroupUpsertBulk
)
SetSoraStorageQuotaBytes
(
v
int64
)
*
GroupUpsertBulk
{
return
u
.
Update
(
func
(
s
*
GroupUpsert
)
{
s
.
SetSoraStorageQuotaBytes
(
v
)
})
}
// AddSoraStorageQuotaBytes adds v to the "sora_storage_quota_bytes" field.
func
(
u
*
GroupUpsertBulk
)
AddSoraStorageQuotaBytes
(
v
int64
)
*
GroupUpsertBulk
{
return
u
.
Update
(
func
(
s
*
GroupUpsert
)
{
s
.
AddSoraStorageQuotaBytes
(
v
)
})
}
// UpdateSoraStorageQuotaBytes sets the "sora_storage_quota_bytes" field to the value that was provided on create.
func
(
u
*
GroupUpsertBulk
)
UpdateSoraStorageQuotaBytes
()
*
GroupUpsertBulk
{
return
u
.
Update
(
func
(
s
*
GroupUpsert
)
{
s
.
UpdateSoraStorageQuotaBytes
()
})
}
// SetClaudeCodeOnly sets the "claude_code_only" field.
// SetClaudeCodeOnly sets the "claude_code_only" field.
func
(
u
*
GroupUpsertBulk
)
SetClaudeCodeOnly
(
v
bool
)
*
GroupUpsertBulk
{
func
(
u
*
GroupUpsertBulk
)
SetClaudeCodeOnly
(
v
bool
)
*
GroupUpsertBulk
{
return
u
.
Update
(
func
(
s
*
GroupUpsert
)
{
return
u
.
Update
(
func
(
s
*
GroupUpsert
)
{
...
...
backend/ent/group_update.go
View file @
bb664d9b
...
@@ -463,6 +463,27 @@ func (_u *GroupUpdate) ClearSoraVideoPricePerRequestHd() *GroupUpdate {
...
@@ -463,6 +463,27 @@ func (_u *GroupUpdate) ClearSoraVideoPricePerRequestHd() *GroupUpdate {
return
_u
return
_u
}
}
// SetSoraStorageQuotaBytes sets the "sora_storage_quota_bytes" field.
func
(
_u
*
GroupUpdate
)
SetSoraStorageQuotaBytes
(
v
int64
)
*
GroupUpdate
{
_u
.
mutation
.
ResetSoraStorageQuotaBytes
()
_u
.
mutation
.
SetSoraStorageQuotaBytes
(
v
)
return
_u
}
// SetNillableSoraStorageQuotaBytes sets the "sora_storage_quota_bytes" field if the given value is not nil.
func
(
_u
*
GroupUpdate
)
SetNillableSoraStorageQuotaBytes
(
v
*
int64
)
*
GroupUpdate
{
if
v
!=
nil
{
_u
.
SetSoraStorageQuotaBytes
(
*
v
)
}
return
_u
}
// AddSoraStorageQuotaBytes adds value to the "sora_storage_quota_bytes" field.
func
(
_u
*
GroupUpdate
)
AddSoraStorageQuotaBytes
(
v
int64
)
*
GroupUpdate
{
_u
.
mutation
.
AddSoraStorageQuotaBytes
(
v
)
return
_u
}
// SetClaudeCodeOnly sets the "claude_code_only" field.
// SetClaudeCodeOnly sets the "claude_code_only" field.
func
(
_u
*
GroupUpdate
)
SetClaudeCodeOnly
(
v
bool
)
*
GroupUpdate
{
func
(
_u
*
GroupUpdate
)
SetClaudeCodeOnly
(
v
bool
)
*
GroupUpdate
{
_u
.
mutation
.
SetClaudeCodeOnly
(
v
)
_u
.
mutation
.
SetClaudeCodeOnly
(
v
)
...
@@ -1036,6 +1057,12 @@ func (_u *GroupUpdate) sqlSave(ctx context.Context) (_node int, err error) {
...
@@ -1036,6 +1057,12 @@ func (_u *GroupUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if
_u
.
mutation
.
SoraVideoPricePerRequestHdCleared
()
{
if
_u
.
mutation
.
SoraVideoPricePerRequestHdCleared
()
{
_spec
.
ClearField
(
group
.
FieldSoraVideoPricePerRequestHd
,
field
.
TypeFloat64
)
_spec
.
ClearField
(
group
.
FieldSoraVideoPricePerRequestHd
,
field
.
TypeFloat64
)
}
}
if
value
,
ok
:=
_u
.
mutation
.
SoraStorageQuotaBytes
();
ok
{
_spec
.
SetField
(
group
.
FieldSoraStorageQuotaBytes
,
field
.
TypeInt64
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
AddedSoraStorageQuotaBytes
();
ok
{
_spec
.
AddField
(
group
.
FieldSoraStorageQuotaBytes
,
field
.
TypeInt64
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
ClaudeCodeOnly
();
ok
{
if
value
,
ok
:=
_u
.
mutation
.
ClaudeCodeOnly
();
ok
{
_spec
.
SetField
(
group
.
FieldClaudeCodeOnly
,
field
.
TypeBool
,
value
)
_spec
.
SetField
(
group
.
FieldClaudeCodeOnly
,
field
.
TypeBool
,
value
)
}
}
...
@@ -1825,6 +1852,27 @@ func (_u *GroupUpdateOne) ClearSoraVideoPricePerRequestHd() *GroupUpdateOne {
...
@@ -1825,6 +1852,27 @@ func (_u *GroupUpdateOne) ClearSoraVideoPricePerRequestHd() *GroupUpdateOne {
return
_u
return
_u
}
}
// SetSoraStorageQuotaBytes sets the "sora_storage_quota_bytes" field.
func
(
_u
*
GroupUpdateOne
)
SetSoraStorageQuotaBytes
(
v
int64
)
*
GroupUpdateOne
{
_u
.
mutation
.
ResetSoraStorageQuotaBytes
()
_u
.
mutation
.
SetSoraStorageQuotaBytes
(
v
)
return
_u
}
// SetNillableSoraStorageQuotaBytes sets the "sora_storage_quota_bytes" field if the given value is not nil.
func
(
_u
*
GroupUpdateOne
)
SetNillableSoraStorageQuotaBytes
(
v
*
int64
)
*
GroupUpdateOne
{
if
v
!=
nil
{
_u
.
SetSoraStorageQuotaBytes
(
*
v
)
}
return
_u
}
// AddSoraStorageQuotaBytes adds value to the "sora_storage_quota_bytes" field.
func
(
_u
*
GroupUpdateOne
)
AddSoraStorageQuotaBytes
(
v
int64
)
*
GroupUpdateOne
{
_u
.
mutation
.
AddSoraStorageQuotaBytes
(
v
)
return
_u
}
// SetClaudeCodeOnly sets the "claude_code_only" field.
// SetClaudeCodeOnly sets the "claude_code_only" field.
func
(
_u
*
GroupUpdateOne
)
SetClaudeCodeOnly
(
v
bool
)
*
GroupUpdateOne
{
func
(
_u
*
GroupUpdateOne
)
SetClaudeCodeOnly
(
v
bool
)
*
GroupUpdateOne
{
_u
.
mutation
.
SetClaudeCodeOnly
(
v
)
_u
.
mutation
.
SetClaudeCodeOnly
(
v
)
...
@@ -2428,6 +2476,12 @@ func (_u *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error)
...
@@ -2428,6 +2476,12 @@ func (_u *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error)
if
_u
.
mutation
.
SoraVideoPricePerRequestHdCleared
()
{
if
_u
.
mutation
.
SoraVideoPricePerRequestHdCleared
()
{
_spec
.
ClearField
(
group
.
FieldSoraVideoPricePerRequestHd
,
field
.
TypeFloat64
)
_spec
.
ClearField
(
group
.
FieldSoraVideoPricePerRequestHd
,
field
.
TypeFloat64
)
}
}
if
value
,
ok
:=
_u
.
mutation
.
SoraStorageQuotaBytes
();
ok
{
_spec
.
SetField
(
group
.
FieldSoraStorageQuotaBytes
,
field
.
TypeInt64
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
AddedSoraStorageQuotaBytes
();
ok
{
_spec
.
AddField
(
group
.
FieldSoraStorageQuotaBytes
,
field
.
TypeInt64
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
ClaudeCodeOnly
();
ok
{
if
value
,
ok
:=
_u
.
mutation
.
ClaudeCodeOnly
();
ok
{
_spec
.
SetField
(
group
.
FieldClaudeCodeOnly
,
field
.
TypeBool
,
value
)
_spec
.
SetField
(
group
.
FieldClaudeCodeOnly
,
field
.
TypeBool
,
value
)
}
}
...
...
backend/ent/hook/hook.go
View file @
bb664d9b
...
@@ -93,6 +93,18 @@ func (f GroupFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error
...
@@ -93,6 +93,18 @@ func (f GroupFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error
return
nil
,
fmt
.
Errorf
(
"unexpected mutation type %T. expect *ent.GroupMutation"
,
m
)
return
nil
,
fmt
.
Errorf
(
"unexpected mutation type %T. expect *ent.GroupMutation"
,
m
)
}
}
// The IdempotencyRecordFunc type is an adapter to allow the use of ordinary
// function as IdempotencyRecord mutator.
type
IdempotencyRecordFunc
func
(
context
.
Context
,
*
ent
.
IdempotencyRecordMutation
)
(
ent
.
Value
,
error
)
// Mutate calls f(ctx, m).
func
(
f
IdempotencyRecordFunc
)
Mutate
(
ctx
context
.
Context
,
m
ent
.
Mutation
)
(
ent
.
Value
,
error
)
{
if
mv
,
ok
:=
m
.
(
*
ent
.
IdempotencyRecordMutation
);
ok
{
return
f
(
ctx
,
mv
)
}
return
nil
,
fmt
.
Errorf
(
"unexpected mutation type %T. expect *ent.IdempotencyRecordMutation"
,
m
)
}
// The PromoCodeFunc type is an adapter to allow the use of ordinary
// The PromoCodeFunc type is an adapter to allow the use of ordinary
// function as PromoCode mutator.
// function as PromoCode mutator.
type
PromoCodeFunc
func
(
context
.
Context
,
*
ent
.
PromoCodeMutation
)
(
ent
.
Value
,
error
)
type
PromoCodeFunc
func
(
context
.
Context
,
*
ent
.
PromoCodeMutation
)
(
ent
.
Value
,
error
)
...
...
backend/ent/idempotencyrecord.go
0 → 100644
View file @
bb664d9b
// 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/idempotencyrecord"
)
// IdempotencyRecord is the model entity for the IdempotencyRecord schema.
type
IdempotencyRecord
struct
{
config
`json:"-"`
// ID of the ent.
ID
int64
`json:"id,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt
time
.
Time
`json:"created_at,omitempty"`
// UpdatedAt holds the value of the "updated_at" field.
UpdatedAt
time
.
Time
`json:"updated_at,omitempty"`
// Scope holds the value of the "scope" field.
Scope
string
`json:"scope,omitempty"`
// IdempotencyKeyHash holds the value of the "idempotency_key_hash" field.
IdempotencyKeyHash
string
`json:"idempotency_key_hash,omitempty"`
// RequestFingerprint holds the value of the "request_fingerprint" field.
RequestFingerprint
string
`json:"request_fingerprint,omitempty"`
// Status holds the value of the "status" field.
Status
string
`json:"status,omitempty"`
// ResponseStatus holds the value of the "response_status" field.
ResponseStatus
*
int
`json:"response_status,omitempty"`
// ResponseBody holds the value of the "response_body" field.
ResponseBody
*
string
`json:"response_body,omitempty"`
// ErrorReason holds the value of the "error_reason" field.
ErrorReason
*
string
`json:"error_reason,omitempty"`
// LockedUntil holds the value of the "locked_until" field.
LockedUntil
*
time
.
Time
`json:"locked_until,omitempty"`
// ExpiresAt holds the value of the "expires_at" field.
ExpiresAt
time
.
Time
`json:"expires_at,omitempty"`
selectValues
sql
.
SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func
(
*
IdempotencyRecord
)
scanValues
(
columns
[]
string
)
([]
any
,
error
)
{
values
:=
make
([]
any
,
len
(
columns
))
for
i
:=
range
columns
{
switch
columns
[
i
]
{
case
idempotencyrecord
.
FieldID
,
idempotencyrecord
.
FieldResponseStatus
:
values
[
i
]
=
new
(
sql
.
NullInt64
)
case
idempotencyrecord
.
FieldScope
,
idempotencyrecord
.
FieldIdempotencyKeyHash
,
idempotencyrecord
.
FieldRequestFingerprint
,
idempotencyrecord
.
FieldStatus
,
idempotencyrecord
.
FieldResponseBody
,
idempotencyrecord
.
FieldErrorReason
:
values
[
i
]
=
new
(
sql
.
NullString
)
case
idempotencyrecord
.
FieldCreatedAt
,
idempotencyrecord
.
FieldUpdatedAt
,
idempotencyrecord
.
FieldLockedUntil
,
idempotencyrecord
.
FieldExpiresAt
:
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 IdempotencyRecord fields.
func
(
_m
*
IdempotencyRecord
)
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
idempotencyrecord
.
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
idempotencyrecord
.
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
}
case
idempotencyrecord
.
FieldUpdatedAt
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullTime
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field updated_at"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
UpdatedAt
=
value
.
Time
}
case
idempotencyrecord
.
FieldScope
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field scope"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
Scope
=
value
.
String
}
case
idempotencyrecord
.
FieldIdempotencyKeyHash
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field idempotency_key_hash"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
IdempotencyKeyHash
=
value
.
String
}
case
idempotencyrecord
.
FieldRequestFingerprint
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field request_fingerprint"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
RequestFingerprint
=
value
.
String
}
case
idempotencyrecord
.
FieldStatus
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field status"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
Status
=
value
.
String
}
case
idempotencyrecord
.
FieldResponseStatus
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullInt64
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field response_status"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
ResponseStatus
=
new
(
int
)
*
_m
.
ResponseStatus
=
int
(
value
.
Int64
)
}
case
idempotencyrecord
.
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
idempotencyrecord
.
FieldErrorReason
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field error_reason"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
ErrorReason
=
new
(
string
)
*
_m
.
ErrorReason
=
value
.
String
}
case
idempotencyrecord
.
FieldLockedUntil
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullTime
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field locked_until"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
LockedUntil
=
new
(
time
.
Time
)
*
_m
.
LockedUntil
=
value
.
Time
}
case
idempotencyrecord
.
FieldExpiresAt
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullTime
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field expires_at"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
ExpiresAt
=
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 IdempotencyRecord.
// This includes values selected through modifiers, order, etc.
func
(
_m
*
IdempotencyRecord
)
Value
(
name
string
)
(
ent
.
Value
,
error
)
{
return
_m
.
selectValues
.
Get
(
name
)
}
// Update returns a builder for updating this IdempotencyRecord.
// Note that you need to call IdempotencyRecord.Unwrap() before calling this method if this IdempotencyRecord
// was returned from a transaction, and the transaction was committed or rolled back.
func
(
_m
*
IdempotencyRecord
)
Update
()
*
IdempotencyRecordUpdateOne
{
return
NewIdempotencyRecordClient
(
_m
.
config
)
.
UpdateOne
(
_m
)
}
// Unwrap unwraps the IdempotencyRecord 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
*
IdempotencyRecord
)
Unwrap
()
*
IdempotencyRecord
{
_tx
,
ok
:=
_m
.
config
.
driver
.
(
*
txDriver
)
if
!
ok
{
panic
(
"ent: IdempotencyRecord is not a transactional entity"
)
}
_m
.
config
.
driver
=
_tx
.
drv
return
_m
}
// String implements the fmt.Stringer.
func
(
_m
*
IdempotencyRecord
)
String
()
string
{
var
builder
strings
.
Builder
builder
.
WriteString
(
"IdempotencyRecord("
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"id=%v, "
,
_m
.
ID
))
builder
.
WriteString
(
"created_at="
)
builder
.
WriteString
(
_m
.
CreatedAt
.
Format
(
time
.
ANSIC
))
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"updated_at="
)
builder
.
WriteString
(
_m
.
UpdatedAt
.
Format
(
time
.
ANSIC
))
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"scope="
)
builder
.
WriteString
(
_m
.
Scope
)
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"idempotency_key_hash="
)
builder
.
WriteString
(
_m
.
IdempotencyKeyHash
)
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"request_fingerprint="
)
builder
.
WriteString
(
_m
.
RequestFingerprint
)
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"status="
)
builder
.
WriteString
(
_m
.
Status
)
builder
.
WriteString
(
", "
)
if
v
:=
_m
.
ResponseStatus
;
v
!=
nil
{
builder
.
WriteString
(
"response_status="
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"%v"
,
*
v
))
}
builder
.
WriteString
(
", "
)
if
v
:=
_m
.
ResponseBody
;
v
!=
nil
{
builder
.
WriteString
(
"response_body="
)
builder
.
WriteString
(
*
v
)
}
builder
.
WriteString
(
", "
)
if
v
:=
_m
.
ErrorReason
;
v
!=
nil
{
builder
.
WriteString
(
"error_reason="
)
builder
.
WriteString
(
*
v
)
}
builder
.
WriteString
(
", "
)
if
v
:=
_m
.
LockedUntil
;
v
!=
nil
{
builder
.
WriteString
(
"locked_until="
)
builder
.
WriteString
(
v
.
Format
(
time
.
ANSIC
))
}
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"expires_at="
)
builder
.
WriteString
(
_m
.
ExpiresAt
.
Format
(
time
.
ANSIC
))
builder
.
WriteByte
(
')'
)
return
builder
.
String
()
}
// IdempotencyRecords is a parsable slice of IdempotencyRecord.
type
IdempotencyRecords
[]
*
IdempotencyRecord
backend/ent/idempotencyrecord/idempotencyrecord.go
0 → 100644
View file @
bb664d9b
// Code generated by ent, DO NOT EDIT.
package
idempotencyrecord
import
(
"time"
"entgo.io/ent/dialect/sql"
)
const
(
// Label holds the string label denoting the idempotencyrecord type in the database.
Label
=
"idempotency_record"
// FieldID holds the string denoting the id field in the database.
FieldID
=
"id"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt
=
"created_at"
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
FieldUpdatedAt
=
"updated_at"
// FieldScope holds the string denoting the scope field in the database.
FieldScope
=
"scope"
// FieldIdempotencyKeyHash holds the string denoting the idempotency_key_hash field in the database.
FieldIdempotencyKeyHash
=
"idempotency_key_hash"
// FieldRequestFingerprint holds the string denoting the request_fingerprint field in the database.
FieldRequestFingerprint
=
"request_fingerprint"
// FieldStatus holds the string denoting the status field in the database.
FieldStatus
=
"status"
// FieldResponseStatus holds the string denoting the response_status field in the database.
FieldResponseStatus
=
"response_status"
// FieldResponseBody holds the string denoting the response_body field in the database.
FieldResponseBody
=
"response_body"
// FieldErrorReason holds the string denoting the error_reason field in the database.
FieldErrorReason
=
"error_reason"
// FieldLockedUntil holds the string denoting the locked_until field in the database.
FieldLockedUntil
=
"locked_until"
// FieldExpiresAt holds the string denoting the expires_at field in the database.
FieldExpiresAt
=
"expires_at"
// Table holds the table name of the idempotencyrecord in the database.
Table
=
"idempotency_records"
)
// Columns holds all SQL columns for idempotencyrecord fields.
var
Columns
=
[]
string
{
FieldID
,
FieldCreatedAt
,
FieldUpdatedAt
,
FieldScope
,
FieldIdempotencyKeyHash
,
FieldRequestFingerprint
,
FieldStatus
,
FieldResponseStatus
,
FieldResponseBody
,
FieldErrorReason
,
FieldLockedUntil
,
FieldExpiresAt
,
}
// 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
(
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt
func
()
time
.
Time
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
DefaultUpdatedAt
func
()
time
.
Time
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
UpdateDefaultUpdatedAt
func
()
time
.
Time
// ScopeValidator is a validator for the "scope" field. It is called by the builders before save.
ScopeValidator
func
(
string
)
error
// IdempotencyKeyHashValidator is a validator for the "idempotency_key_hash" field. It is called by the builders before save.
IdempotencyKeyHashValidator
func
(
string
)
error
// RequestFingerprintValidator is a validator for the "request_fingerprint" field. It is called by the builders before save.
RequestFingerprintValidator
func
(
string
)
error
// StatusValidator is a validator for the "status" field. It is called by the builders before save.
StatusValidator
func
(
string
)
error
// ErrorReasonValidator is a validator for the "error_reason" field. It is called by the builders before save.
ErrorReasonValidator
func
(
string
)
error
)
// OrderOption defines the ordering options for the IdempotencyRecord 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
()
}
// ByCreatedAt orders the results by the created_at field.
func
ByCreatedAt
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldCreatedAt
,
opts
...
)
.
ToFunc
()
}
// ByUpdatedAt orders the results by the updated_at field.
func
ByUpdatedAt
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldUpdatedAt
,
opts
...
)
.
ToFunc
()
}
// ByScope orders the results by the scope field.
func
ByScope
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldScope
,
opts
...
)
.
ToFunc
()
}
// ByIdempotencyKeyHash orders the results by the idempotency_key_hash field.
func
ByIdempotencyKeyHash
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldIdempotencyKeyHash
,
opts
...
)
.
ToFunc
()
}
// ByRequestFingerprint orders the results by the request_fingerprint field.
func
ByRequestFingerprint
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldRequestFingerprint
,
opts
...
)
.
ToFunc
()
}
// ByStatus orders the results by the status field.
func
ByStatus
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldStatus
,
opts
...
)
.
ToFunc
()
}
// ByResponseStatus orders the results by the response_status field.
func
ByResponseStatus
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldResponseStatus
,
opts
...
)
.
ToFunc
()
}
// ByResponseBody orders the results by the response_body field.
func
ByResponseBody
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldResponseBody
,
opts
...
)
.
ToFunc
()
}
// ByErrorReason orders the results by the error_reason field.
func
ByErrorReason
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldErrorReason
,
opts
...
)
.
ToFunc
()
}
// ByLockedUntil orders the results by the locked_until field.
func
ByLockedUntil
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldLockedUntil
,
opts
...
)
.
ToFunc
()
}
// ByExpiresAt orders the results by the expires_at field.
func
ByExpiresAt
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldExpiresAt
,
opts
...
)
.
ToFunc
()
}
backend/ent/idempotencyrecord/where.go
0 → 100644
View file @
bb664d9b
// Code generated by ent, DO NOT EDIT.
package
idempotencyrecord
import
(
"time"
"entgo.io/ent/dialect/sql"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// ID filters vertices based on their ID field.
func
ID
(
id
int64
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEQ
(
FieldID
,
id
))
}
// IDEQ applies the EQ predicate on the ID field.
func
IDEQ
(
id
int64
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEQ
(
FieldID
,
id
))
}
// IDNEQ applies the NEQ predicate on the ID field.
func
IDNEQ
(
id
int64
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNEQ
(
FieldID
,
id
))
}
// IDIn applies the In predicate on the ID field.
func
IDIn
(
ids
...
int64
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldIn
(
FieldID
,
ids
...
))
}
// IDNotIn applies the NotIn predicate on the ID field.
func
IDNotIn
(
ids
...
int64
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNotIn
(
FieldID
,
ids
...
))
}
// IDGT applies the GT predicate on the ID field.
func
IDGT
(
id
int64
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldGT
(
FieldID
,
id
))
}
// IDGTE applies the GTE predicate on the ID field.
func
IDGTE
(
id
int64
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldGTE
(
FieldID
,
id
))
}
// IDLT applies the LT predicate on the ID field.
func
IDLT
(
id
int64
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldLT
(
FieldID
,
id
))
}
// IDLTE applies the LTE predicate on the ID field.
func
IDLTE
(
id
int64
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldLTE
(
FieldID
,
id
))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func
CreatedAt
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEQ
(
FieldCreatedAt
,
v
))
}
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func
UpdatedAt
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEQ
(
FieldUpdatedAt
,
v
))
}
// Scope applies equality check predicate on the "scope" field. It's identical to ScopeEQ.
func
Scope
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEQ
(
FieldScope
,
v
))
}
// IdempotencyKeyHash applies equality check predicate on the "idempotency_key_hash" field. It's identical to IdempotencyKeyHashEQ.
func
IdempotencyKeyHash
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEQ
(
FieldIdempotencyKeyHash
,
v
))
}
// RequestFingerprint applies equality check predicate on the "request_fingerprint" field. It's identical to RequestFingerprintEQ.
func
RequestFingerprint
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEQ
(
FieldRequestFingerprint
,
v
))
}
// Status applies equality check predicate on the "status" field. It's identical to StatusEQ.
func
Status
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEQ
(
FieldStatus
,
v
))
}
// ResponseStatus applies equality check predicate on the "response_status" field. It's identical to ResponseStatusEQ.
func
ResponseStatus
(
v
int
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEQ
(
FieldResponseStatus
,
v
))
}
// ResponseBody applies equality check predicate on the "response_body" field. It's identical to ResponseBodyEQ.
func
ResponseBody
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEQ
(
FieldResponseBody
,
v
))
}
// ErrorReason applies equality check predicate on the "error_reason" field. It's identical to ErrorReasonEQ.
func
ErrorReason
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEQ
(
FieldErrorReason
,
v
))
}
// LockedUntil applies equality check predicate on the "locked_until" field. It's identical to LockedUntilEQ.
func
LockedUntil
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEQ
(
FieldLockedUntil
,
v
))
}
// ExpiresAt applies equality check predicate on the "expires_at" field. It's identical to ExpiresAtEQ.
func
ExpiresAt
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEQ
(
FieldExpiresAt
,
v
))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func
CreatedAtEQ
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEQ
(
FieldCreatedAt
,
v
))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func
CreatedAtNEQ
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNEQ
(
FieldCreatedAt
,
v
))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func
CreatedAtIn
(
vs
...
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldIn
(
FieldCreatedAt
,
vs
...
))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func
CreatedAtNotIn
(
vs
...
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNotIn
(
FieldCreatedAt
,
vs
...
))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func
CreatedAtGT
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldGT
(
FieldCreatedAt
,
v
))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func
CreatedAtGTE
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldGTE
(
FieldCreatedAt
,
v
))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func
CreatedAtLT
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldLT
(
FieldCreatedAt
,
v
))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func
CreatedAtLTE
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldLTE
(
FieldCreatedAt
,
v
))
}
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func
UpdatedAtEQ
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEQ
(
FieldUpdatedAt
,
v
))
}
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func
UpdatedAtNEQ
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNEQ
(
FieldUpdatedAt
,
v
))
}
// UpdatedAtIn applies the In predicate on the "updated_at" field.
func
UpdatedAtIn
(
vs
...
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldIn
(
FieldUpdatedAt
,
vs
...
))
}
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func
UpdatedAtNotIn
(
vs
...
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNotIn
(
FieldUpdatedAt
,
vs
...
))
}
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
func
UpdatedAtGT
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldGT
(
FieldUpdatedAt
,
v
))
}
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func
UpdatedAtGTE
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldGTE
(
FieldUpdatedAt
,
v
))
}
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
func
UpdatedAtLT
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldLT
(
FieldUpdatedAt
,
v
))
}
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func
UpdatedAtLTE
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldLTE
(
FieldUpdatedAt
,
v
))
}
// ScopeEQ applies the EQ predicate on the "scope" field.
func
ScopeEQ
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEQ
(
FieldScope
,
v
))
}
// ScopeNEQ applies the NEQ predicate on the "scope" field.
func
ScopeNEQ
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNEQ
(
FieldScope
,
v
))
}
// ScopeIn applies the In predicate on the "scope" field.
func
ScopeIn
(
vs
...
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldIn
(
FieldScope
,
vs
...
))
}
// ScopeNotIn applies the NotIn predicate on the "scope" field.
func
ScopeNotIn
(
vs
...
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNotIn
(
FieldScope
,
vs
...
))
}
// ScopeGT applies the GT predicate on the "scope" field.
func
ScopeGT
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldGT
(
FieldScope
,
v
))
}
// ScopeGTE applies the GTE predicate on the "scope" field.
func
ScopeGTE
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldGTE
(
FieldScope
,
v
))
}
// ScopeLT applies the LT predicate on the "scope" field.
func
ScopeLT
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldLT
(
FieldScope
,
v
))
}
// ScopeLTE applies the LTE predicate on the "scope" field.
func
ScopeLTE
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldLTE
(
FieldScope
,
v
))
}
// ScopeContains applies the Contains predicate on the "scope" field.
func
ScopeContains
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldContains
(
FieldScope
,
v
))
}
// ScopeHasPrefix applies the HasPrefix predicate on the "scope" field.
func
ScopeHasPrefix
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldHasPrefix
(
FieldScope
,
v
))
}
// ScopeHasSuffix applies the HasSuffix predicate on the "scope" field.
func
ScopeHasSuffix
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldHasSuffix
(
FieldScope
,
v
))
}
// ScopeEqualFold applies the EqualFold predicate on the "scope" field.
func
ScopeEqualFold
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEqualFold
(
FieldScope
,
v
))
}
// ScopeContainsFold applies the ContainsFold predicate on the "scope" field.
func
ScopeContainsFold
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldContainsFold
(
FieldScope
,
v
))
}
// IdempotencyKeyHashEQ applies the EQ predicate on the "idempotency_key_hash" field.
func
IdempotencyKeyHashEQ
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEQ
(
FieldIdempotencyKeyHash
,
v
))
}
// IdempotencyKeyHashNEQ applies the NEQ predicate on the "idempotency_key_hash" field.
func
IdempotencyKeyHashNEQ
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNEQ
(
FieldIdempotencyKeyHash
,
v
))
}
// IdempotencyKeyHashIn applies the In predicate on the "idempotency_key_hash" field.
func
IdempotencyKeyHashIn
(
vs
...
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldIn
(
FieldIdempotencyKeyHash
,
vs
...
))
}
// IdempotencyKeyHashNotIn applies the NotIn predicate on the "idempotency_key_hash" field.
func
IdempotencyKeyHashNotIn
(
vs
...
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNotIn
(
FieldIdempotencyKeyHash
,
vs
...
))
}
// IdempotencyKeyHashGT applies the GT predicate on the "idempotency_key_hash" field.
func
IdempotencyKeyHashGT
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldGT
(
FieldIdempotencyKeyHash
,
v
))
}
// IdempotencyKeyHashGTE applies the GTE predicate on the "idempotency_key_hash" field.
func
IdempotencyKeyHashGTE
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldGTE
(
FieldIdempotencyKeyHash
,
v
))
}
// IdempotencyKeyHashLT applies the LT predicate on the "idempotency_key_hash" field.
func
IdempotencyKeyHashLT
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldLT
(
FieldIdempotencyKeyHash
,
v
))
}
// IdempotencyKeyHashLTE applies the LTE predicate on the "idempotency_key_hash" field.
func
IdempotencyKeyHashLTE
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldLTE
(
FieldIdempotencyKeyHash
,
v
))
}
// IdempotencyKeyHashContains applies the Contains predicate on the "idempotency_key_hash" field.
func
IdempotencyKeyHashContains
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldContains
(
FieldIdempotencyKeyHash
,
v
))
}
// IdempotencyKeyHashHasPrefix applies the HasPrefix predicate on the "idempotency_key_hash" field.
func
IdempotencyKeyHashHasPrefix
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldHasPrefix
(
FieldIdempotencyKeyHash
,
v
))
}
// IdempotencyKeyHashHasSuffix applies the HasSuffix predicate on the "idempotency_key_hash" field.
func
IdempotencyKeyHashHasSuffix
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldHasSuffix
(
FieldIdempotencyKeyHash
,
v
))
}
// IdempotencyKeyHashEqualFold applies the EqualFold predicate on the "idempotency_key_hash" field.
func
IdempotencyKeyHashEqualFold
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEqualFold
(
FieldIdempotencyKeyHash
,
v
))
}
// IdempotencyKeyHashContainsFold applies the ContainsFold predicate on the "idempotency_key_hash" field.
func
IdempotencyKeyHashContainsFold
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldContainsFold
(
FieldIdempotencyKeyHash
,
v
))
}
// RequestFingerprintEQ applies the EQ predicate on the "request_fingerprint" field.
func
RequestFingerprintEQ
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEQ
(
FieldRequestFingerprint
,
v
))
}
// RequestFingerprintNEQ applies the NEQ predicate on the "request_fingerprint" field.
func
RequestFingerprintNEQ
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNEQ
(
FieldRequestFingerprint
,
v
))
}
// RequestFingerprintIn applies the In predicate on the "request_fingerprint" field.
func
RequestFingerprintIn
(
vs
...
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldIn
(
FieldRequestFingerprint
,
vs
...
))
}
// RequestFingerprintNotIn applies the NotIn predicate on the "request_fingerprint" field.
func
RequestFingerprintNotIn
(
vs
...
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNotIn
(
FieldRequestFingerprint
,
vs
...
))
}
// RequestFingerprintGT applies the GT predicate on the "request_fingerprint" field.
func
RequestFingerprintGT
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldGT
(
FieldRequestFingerprint
,
v
))
}
// RequestFingerprintGTE applies the GTE predicate on the "request_fingerprint" field.
func
RequestFingerprintGTE
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldGTE
(
FieldRequestFingerprint
,
v
))
}
// RequestFingerprintLT applies the LT predicate on the "request_fingerprint" field.
func
RequestFingerprintLT
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldLT
(
FieldRequestFingerprint
,
v
))
}
// RequestFingerprintLTE applies the LTE predicate on the "request_fingerprint" field.
func
RequestFingerprintLTE
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldLTE
(
FieldRequestFingerprint
,
v
))
}
// RequestFingerprintContains applies the Contains predicate on the "request_fingerprint" field.
func
RequestFingerprintContains
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldContains
(
FieldRequestFingerprint
,
v
))
}
// RequestFingerprintHasPrefix applies the HasPrefix predicate on the "request_fingerprint" field.
func
RequestFingerprintHasPrefix
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldHasPrefix
(
FieldRequestFingerprint
,
v
))
}
// RequestFingerprintHasSuffix applies the HasSuffix predicate on the "request_fingerprint" field.
func
RequestFingerprintHasSuffix
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldHasSuffix
(
FieldRequestFingerprint
,
v
))
}
// RequestFingerprintEqualFold applies the EqualFold predicate on the "request_fingerprint" field.
func
RequestFingerprintEqualFold
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEqualFold
(
FieldRequestFingerprint
,
v
))
}
// RequestFingerprintContainsFold applies the ContainsFold predicate on the "request_fingerprint" field.
func
RequestFingerprintContainsFold
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldContainsFold
(
FieldRequestFingerprint
,
v
))
}
// StatusEQ applies the EQ predicate on the "status" field.
func
StatusEQ
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEQ
(
FieldStatus
,
v
))
}
// StatusNEQ applies the NEQ predicate on the "status" field.
func
StatusNEQ
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNEQ
(
FieldStatus
,
v
))
}
// StatusIn applies the In predicate on the "status" field.
func
StatusIn
(
vs
...
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldIn
(
FieldStatus
,
vs
...
))
}
// StatusNotIn applies the NotIn predicate on the "status" field.
func
StatusNotIn
(
vs
...
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNotIn
(
FieldStatus
,
vs
...
))
}
// StatusGT applies the GT predicate on the "status" field.
func
StatusGT
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldGT
(
FieldStatus
,
v
))
}
// StatusGTE applies the GTE predicate on the "status" field.
func
StatusGTE
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldGTE
(
FieldStatus
,
v
))
}
// StatusLT applies the LT predicate on the "status" field.
func
StatusLT
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldLT
(
FieldStatus
,
v
))
}
// StatusLTE applies the LTE predicate on the "status" field.
func
StatusLTE
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldLTE
(
FieldStatus
,
v
))
}
// StatusContains applies the Contains predicate on the "status" field.
func
StatusContains
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldContains
(
FieldStatus
,
v
))
}
// StatusHasPrefix applies the HasPrefix predicate on the "status" field.
func
StatusHasPrefix
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldHasPrefix
(
FieldStatus
,
v
))
}
// StatusHasSuffix applies the HasSuffix predicate on the "status" field.
func
StatusHasSuffix
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldHasSuffix
(
FieldStatus
,
v
))
}
// StatusEqualFold applies the EqualFold predicate on the "status" field.
func
StatusEqualFold
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEqualFold
(
FieldStatus
,
v
))
}
// StatusContainsFold applies the ContainsFold predicate on the "status" field.
func
StatusContainsFold
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldContainsFold
(
FieldStatus
,
v
))
}
// ResponseStatusEQ applies the EQ predicate on the "response_status" field.
func
ResponseStatusEQ
(
v
int
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEQ
(
FieldResponseStatus
,
v
))
}
// ResponseStatusNEQ applies the NEQ predicate on the "response_status" field.
func
ResponseStatusNEQ
(
v
int
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNEQ
(
FieldResponseStatus
,
v
))
}
// ResponseStatusIn applies the In predicate on the "response_status" field.
func
ResponseStatusIn
(
vs
...
int
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldIn
(
FieldResponseStatus
,
vs
...
))
}
// ResponseStatusNotIn applies the NotIn predicate on the "response_status" field.
func
ResponseStatusNotIn
(
vs
...
int
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNotIn
(
FieldResponseStatus
,
vs
...
))
}
// ResponseStatusGT applies the GT predicate on the "response_status" field.
func
ResponseStatusGT
(
v
int
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldGT
(
FieldResponseStatus
,
v
))
}
// ResponseStatusGTE applies the GTE predicate on the "response_status" field.
func
ResponseStatusGTE
(
v
int
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldGTE
(
FieldResponseStatus
,
v
))
}
// ResponseStatusLT applies the LT predicate on the "response_status" field.
func
ResponseStatusLT
(
v
int
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldLT
(
FieldResponseStatus
,
v
))
}
// ResponseStatusLTE applies the LTE predicate on the "response_status" field.
func
ResponseStatusLTE
(
v
int
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldLTE
(
FieldResponseStatus
,
v
))
}
// ResponseStatusIsNil applies the IsNil predicate on the "response_status" field.
func
ResponseStatusIsNil
()
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldIsNull
(
FieldResponseStatus
))
}
// ResponseStatusNotNil applies the NotNil predicate on the "response_status" field.
func
ResponseStatusNotNil
()
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNotNull
(
FieldResponseStatus
))
}
// ResponseBodyEQ applies the EQ predicate on the "response_body" field.
func
ResponseBodyEQ
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEQ
(
FieldResponseBody
,
v
))
}
// ResponseBodyNEQ applies the NEQ predicate on the "response_body" field.
func
ResponseBodyNEQ
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNEQ
(
FieldResponseBody
,
v
))
}
// ResponseBodyIn applies the In predicate on the "response_body" field.
func
ResponseBodyIn
(
vs
...
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldIn
(
FieldResponseBody
,
vs
...
))
}
// ResponseBodyNotIn applies the NotIn predicate on the "response_body" field.
func
ResponseBodyNotIn
(
vs
...
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNotIn
(
FieldResponseBody
,
vs
...
))
}
// ResponseBodyGT applies the GT predicate on the "response_body" field.
func
ResponseBodyGT
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldGT
(
FieldResponseBody
,
v
))
}
// ResponseBodyGTE applies the GTE predicate on the "response_body" field.
func
ResponseBodyGTE
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldGTE
(
FieldResponseBody
,
v
))
}
// ResponseBodyLT applies the LT predicate on the "response_body" field.
func
ResponseBodyLT
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldLT
(
FieldResponseBody
,
v
))
}
// ResponseBodyLTE applies the LTE predicate on the "response_body" field.
func
ResponseBodyLTE
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldLTE
(
FieldResponseBody
,
v
))
}
// ResponseBodyContains applies the Contains predicate on the "response_body" field.
func
ResponseBodyContains
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldContains
(
FieldResponseBody
,
v
))
}
// ResponseBodyHasPrefix applies the HasPrefix predicate on the "response_body" field.
func
ResponseBodyHasPrefix
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldHasPrefix
(
FieldResponseBody
,
v
))
}
// ResponseBodyHasSuffix applies the HasSuffix predicate on the "response_body" field.
func
ResponseBodyHasSuffix
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldHasSuffix
(
FieldResponseBody
,
v
))
}
// ResponseBodyIsNil applies the IsNil predicate on the "response_body" field.
func
ResponseBodyIsNil
()
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldIsNull
(
FieldResponseBody
))
}
// ResponseBodyNotNil applies the NotNil predicate on the "response_body" field.
func
ResponseBodyNotNil
()
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNotNull
(
FieldResponseBody
))
}
// ResponseBodyEqualFold applies the EqualFold predicate on the "response_body" field.
func
ResponseBodyEqualFold
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEqualFold
(
FieldResponseBody
,
v
))
}
// ResponseBodyContainsFold applies the ContainsFold predicate on the "response_body" field.
func
ResponseBodyContainsFold
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldContainsFold
(
FieldResponseBody
,
v
))
}
// ErrorReasonEQ applies the EQ predicate on the "error_reason" field.
func
ErrorReasonEQ
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEQ
(
FieldErrorReason
,
v
))
}
// ErrorReasonNEQ applies the NEQ predicate on the "error_reason" field.
func
ErrorReasonNEQ
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNEQ
(
FieldErrorReason
,
v
))
}
// ErrorReasonIn applies the In predicate on the "error_reason" field.
func
ErrorReasonIn
(
vs
...
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldIn
(
FieldErrorReason
,
vs
...
))
}
// ErrorReasonNotIn applies the NotIn predicate on the "error_reason" field.
func
ErrorReasonNotIn
(
vs
...
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNotIn
(
FieldErrorReason
,
vs
...
))
}
// ErrorReasonGT applies the GT predicate on the "error_reason" field.
func
ErrorReasonGT
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldGT
(
FieldErrorReason
,
v
))
}
// ErrorReasonGTE applies the GTE predicate on the "error_reason" field.
func
ErrorReasonGTE
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldGTE
(
FieldErrorReason
,
v
))
}
// ErrorReasonLT applies the LT predicate on the "error_reason" field.
func
ErrorReasonLT
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldLT
(
FieldErrorReason
,
v
))
}
// ErrorReasonLTE applies the LTE predicate on the "error_reason" field.
func
ErrorReasonLTE
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldLTE
(
FieldErrorReason
,
v
))
}
// ErrorReasonContains applies the Contains predicate on the "error_reason" field.
func
ErrorReasonContains
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldContains
(
FieldErrorReason
,
v
))
}
// ErrorReasonHasPrefix applies the HasPrefix predicate on the "error_reason" field.
func
ErrorReasonHasPrefix
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldHasPrefix
(
FieldErrorReason
,
v
))
}
// ErrorReasonHasSuffix applies the HasSuffix predicate on the "error_reason" field.
func
ErrorReasonHasSuffix
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldHasSuffix
(
FieldErrorReason
,
v
))
}
// ErrorReasonIsNil applies the IsNil predicate on the "error_reason" field.
func
ErrorReasonIsNil
()
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldIsNull
(
FieldErrorReason
))
}
// ErrorReasonNotNil applies the NotNil predicate on the "error_reason" field.
func
ErrorReasonNotNil
()
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNotNull
(
FieldErrorReason
))
}
// ErrorReasonEqualFold applies the EqualFold predicate on the "error_reason" field.
func
ErrorReasonEqualFold
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEqualFold
(
FieldErrorReason
,
v
))
}
// ErrorReasonContainsFold applies the ContainsFold predicate on the "error_reason" field.
func
ErrorReasonContainsFold
(
v
string
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldContainsFold
(
FieldErrorReason
,
v
))
}
// LockedUntilEQ applies the EQ predicate on the "locked_until" field.
func
LockedUntilEQ
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEQ
(
FieldLockedUntil
,
v
))
}
// LockedUntilNEQ applies the NEQ predicate on the "locked_until" field.
func
LockedUntilNEQ
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNEQ
(
FieldLockedUntil
,
v
))
}
// LockedUntilIn applies the In predicate on the "locked_until" field.
func
LockedUntilIn
(
vs
...
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldIn
(
FieldLockedUntil
,
vs
...
))
}
// LockedUntilNotIn applies the NotIn predicate on the "locked_until" field.
func
LockedUntilNotIn
(
vs
...
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNotIn
(
FieldLockedUntil
,
vs
...
))
}
// LockedUntilGT applies the GT predicate on the "locked_until" field.
func
LockedUntilGT
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldGT
(
FieldLockedUntil
,
v
))
}
// LockedUntilGTE applies the GTE predicate on the "locked_until" field.
func
LockedUntilGTE
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldGTE
(
FieldLockedUntil
,
v
))
}
// LockedUntilLT applies the LT predicate on the "locked_until" field.
func
LockedUntilLT
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldLT
(
FieldLockedUntil
,
v
))
}
// LockedUntilLTE applies the LTE predicate on the "locked_until" field.
func
LockedUntilLTE
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldLTE
(
FieldLockedUntil
,
v
))
}
// LockedUntilIsNil applies the IsNil predicate on the "locked_until" field.
func
LockedUntilIsNil
()
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldIsNull
(
FieldLockedUntil
))
}
// LockedUntilNotNil applies the NotNil predicate on the "locked_until" field.
func
LockedUntilNotNil
()
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNotNull
(
FieldLockedUntil
))
}
// ExpiresAtEQ applies the EQ predicate on the "expires_at" field.
func
ExpiresAtEQ
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldEQ
(
FieldExpiresAt
,
v
))
}
// ExpiresAtNEQ applies the NEQ predicate on the "expires_at" field.
func
ExpiresAtNEQ
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNEQ
(
FieldExpiresAt
,
v
))
}
// ExpiresAtIn applies the In predicate on the "expires_at" field.
func
ExpiresAtIn
(
vs
...
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldIn
(
FieldExpiresAt
,
vs
...
))
}
// ExpiresAtNotIn applies the NotIn predicate on the "expires_at" field.
func
ExpiresAtNotIn
(
vs
...
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldNotIn
(
FieldExpiresAt
,
vs
...
))
}
// ExpiresAtGT applies the GT predicate on the "expires_at" field.
func
ExpiresAtGT
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldGT
(
FieldExpiresAt
,
v
))
}
// ExpiresAtGTE applies the GTE predicate on the "expires_at" field.
func
ExpiresAtGTE
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldGTE
(
FieldExpiresAt
,
v
))
}
// ExpiresAtLT applies the LT predicate on the "expires_at" field.
func
ExpiresAtLT
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldLT
(
FieldExpiresAt
,
v
))
}
// ExpiresAtLTE applies the LTE predicate on the "expires_at" field.
func
ExpiresAtLTE
(
v
time
.
Time
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
FieldLTE
(
FieldExpiresAt
,
v
))
}
// And groups predicates with the AND operator between them.
func
And
(
predicates
...
predicate
.
IdempotencyRecord
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
AndPredicates
(
predicates
...
))
}
// Or groups predicates with the OR operator between them.
func
Or
(
predicates
...
predicate
.
IdempotencyRecord
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
OrPredicates
(
predicates
...
))
}
// Not applies the not operator on the given predicate.
func
Not
(
p
predicate
.
IdempotencyRecord
)
predicate
.
IdempotencyRecord
{
return
predicate
.
IdempotencyRecord
(
sql
.
NotPredicates
(
p
))
}
backend/ent/idempotencyrecord_create.go
0 → 100644
View file @
bb664d9b
// Code generated by ent, DO NOT EDIT.
package
ent
import
(
"context"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/idempotencyrecord"
)
// IdempotencyRecordCreate is the builder for creating a IdempotencyRecord entity.
type
IdempotencyRecordCreate
struct
{
config
mutation
*
IdempotencyRecordMutation
hooks
[]
Hook
conflict
[]
sql
.
ConflictOption
}
// SetCreatedAt sets the "created_at" field.
func
(
_c
*
IdempotencyRecordCreate
)
SetCreatedAt
(
v
time
.
Time
)
*
IdempotencyRecordCreate
{
_c
.
mutation
.
SetCreatedAt
(
v
)
return
_c
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func
(
_c
*
IdempotencyRecordCreate
)
SetNillableCreatedAt
(
v
*
time
.
Time
)
*
IdempotencyRecordCreate
{
if
v
!=
nil
{
_c
.
SetCreatedAt
(
*
v
)
}
return
_c
}
// SetUpdatedAt sets the "updated_at" field.
func
(
_c
*
IdempotencyRecordCreate
)
SetUpdatedAt
(
v
time
.
Time
)
*
IdempotencyRecordCreate
{
_c
.
mutation
.
SetUpdatedAt
(
v
)
return
_c
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func
(
_c
*
IdempotencyRecordCreate
)
SetNillableUpdatedAt
(
v
*
time
.
Time
)
*
IdempotencyRecordCreate
{
if
v
!=
nil
{
_c
.
SetUpdatedAt
(
*
v
)
}
return
_c
}
// SetScope sets the "scope" field.
func
(
_c
*
IdempotencyRecordCreate
)
SetScope
(
v
string
)
*
IdempotencyRecordCreate
{
_c
.
mutation
.
SetScope
(
v
)
return
_c
}
// SetIdempotencyKeyHash sets the "idempotency_key_hash" field.
func
(
_c
*
IdempotencyRecordCreate
)
SetIdempotencyKeyHash
(
v
string
)
*
IdempotencyRecordCreate
{
_c
.
mutation
.
SetIdempotencyKeyHash
(
v
)
return
_c
}
// SetRequestFingerprint sets the "request_fingerprint" field.
func
(
_c
*
IdempotencyRecordCreate
)
SetRequestFingerprint
(
v
string
)
*
IdempotencyRecordCreate
{
_c
.
mutation
.
SetRequestFingerprint
(
v
)
return
_c
}
// SetStatus sets the "status" field.
func
(
_c
*
IdempotencyRecordCreate
)
SetStatus
(
v
string
)
*
IdempotencyRecordCreate
{
_c
.
mutation
.
SetStatus
(
v
)
return
_c
}
// SetResponseStatus sets the "response_status" field.
func
(
_c
*
IdempotencyRecordCreate
)
SetResponseStatus
(
v
int
)
*
IdempotencyRecordCreate
{
_c
.
mutation
.
SetResponseStatus
(
v
)
return
_c
}
// SetNillableResponseStatus sets the "response_status" field if the given value is not nil.
func
(
_c
*
IdempotencyRecordCreate
)
SetNillableResponseStatus
(
v
*
int
)
*
IdempotencyRecordCreate
{
if
v
!=
nil
{
_c
.
SetResponseStatus
(
*
v
)
}
return
_c
}
// SetResponseBody sets the "response_body" field.
func
(
_c
*
IdempotencyRecordCreate
)
SetResponseBody
(
v
string
)
*
IdempotencyRecordCreate
{
_c
.
mutation
.
SetResponseBody
(
v
)
return
_c
}
// SetNillableResponseBody sets the "response_body" field if the given value is not nil.
func
(
_c
*
IdempotencyRecordCreate
)
SetNillableResponseBody
(
v
*
string
)
*
IdempotencyRecordCreate
{
if
v
!=
nil
{
_c
.
SetResponseBody
(
*
v
)
}
return
_c
}
// SetErrorReason sets the "error_reason" field.
func
(
_c
*
IdempotencyRecordCreate
)
SetErrorReason
(
v
string
)
*
IdempotencyRecordCreate
{
_c
.
mutation
.
SetErrorReason
(
v
)
return
_c
}
// SetNillableErrorReason sets the "error_reason" field if the given value is not nil.
func
(
_c
*
IdempotencyRecordCreate
)
SetNillableErrorReason
(
v
*
string
)
*
IdempotencyRecordCreate
{
if
v
!=
nil
{
_c
.
SetErrorReason
(
*
v
)
}
return
_c
}
// SetLockedUntil sets the "locked_until" field.
func
(
_c
*
IdempotencyRecordCreate
)
SetLockedUntil
(
v
time
.
Time
)
*
IdempotencyRecordCreate
{
_c
.
mutation
.
SetLockedUntil
(
v
)
return
_c
}
// SetNillableLockedUntil sets the "locked_until" field if the given value is not nil.
func
(
_c
*
IdempotencyRecordCreate
)
SetNillableLockedUntil
(
v
*
time
.
Time
)
*
IdempotencyRecordCreate
{
if
v
!=
nil
{
_c
.
SetLockedUntil
(
*
v
)
}
return
_c
}
// SetExpiresAt sets the "expires_at" field.
func
(
_c
*
IdempotencyRecordCreate
)
SetExpiresAt
(
v
time
.
Time
)
*
IdempotencyRecordCreate
{
_c
.
mutation
.
SetExpiresAt
(
v
)
return
_c
}
// Mutation returns the IdempotencyRecordMutation object of the builder.
func
(
_c
*
IdempotencyRecordCreate
)
Mutation
()
*
IdempotencyRecordMutation
{
return
_c
.
mutation
}
// Save creates the IdempotencyRecord in the database.
func
(
_c
*
IdempotencyRecordCreate
)
Save
(
ctx
context
.
Context
)
(
*
IdempotencyRecord
,
error
)
{
_c
.
defaults
()
return
withHooks
(
ctx
,
_c
.
sqlSave
,
_c
.
mutation
,
_c
.
hooks
)
}
// SaveX calls Save and panics if Save returns an error.
func
(
_c
*
IdempotencyRecordCreate
)
SaveX
(
ctx
context
.
Context
)
*
IdempotencyRecord
{
v
,
err
:=
_c
.
Save
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
v
}
// Exec executes the query.
func
(
_c
*
IdempotencyRecordCreate
)
Exec
(
ctx
context
.
Context
)
error
{
_
,
err
:=
_c
.
Save
(
ctx
)
return
err
}
// ExecX is like Exec, but panics if an error occurs.
func
(
_c
*
IdempotencyRecordCreate
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
_c
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
}
// defaults sets the default values of the builder before save.
func
(
_c
*
IdempotencyRecordCreate
)
defaults
()
{
if
_
,
ok
:=
_c
.
mutation
.
CreatedAt
();
!
ok
{
v
:=
idempotencyrecord
.
DefaultCreatedAt
()
_c
.
mutation
.
SetCreatedAt
(
v
)
}
if
_
,
ok
:=
_c
.
mutation
.
UpdatedAt
();
!
ok
{
v
:=
idempotencyrecord
.
DefaultUpdatedAt
()
_c
.
mutation
.
SetUpdatedAt
(
v
)
}
}
// check runs all checks and user-defined validators on the builder.
func
(
_c
*
IdempotencyRecordCreate
)
check
()
error
{
if
_
,
ok
:=
_c
.
mutation
.
CreatedAt
();
!
ok
{
return
&
ValidationError
{
Name
:
"created_at"
,
err
:
errors
.
New
(
`ent: missing required field "IdempotencyRecord.created_at"`
)}
}
if
_
,
ok
:=
_c
.
mutation
.
UpdatedAt
();
!
ok
{
return
&
ValidationError
{
Name
:
"updated_at"
,
err
:
errors
.
New
(
`ent: missing required field "IdempotencyRecord.updated_at"`
)}
}
if
_
,
ok
:=
_c
.
mutation
.
Scope
();
!
ok
{
return
&
ValidationError
{
Name
:
"scope"
,
err
:
errors
.
New
(
`ent: missing required field "IdempotencyRecord.scope"`
)}
}
if
v
,
ok
:=
_c
.
mutation
.
Scope
();
ok
{
if
err
:=
idempotencyrecord
.
ScopeValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"scope"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "IdempotencyRecord.scope": %w`
,
err
)}
}
}
if
_
,
ok
:=
_c
.
mutation
.
IdempotencyKeyHash
();
!
ok
{
return
&
ValidationError
{
Name
:
"idempotency_key_hash"
,
err
:
errors
.
New
(
`ent: missing required field "IdempotencyRecord.idempotency_key_hash"`
)}
}
if
v
,
ok
:=
_c
.
mutation
.
IdempotencyKeyHash
();
ok
{
if
err
:=
idempotencyrecord
.
IdempotencyKeyHashValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"idempotency_key_hash"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "IdempotencyRecord.idempotency_key_hash": %w`
,
err
)}
}
}
if
_
,
ok
:=
_c
.
mutation
.
RequestFingerprint
();
!
ok
{
return
&
ValidationError
{
Name
:
"request_fingerprint"
,
err
:
errors
.
New
(
`ent: missing required field "IdempotencyRecord.request_fingerprint"`
)}
}
if
v
,
ok
:=
_c
.
mutation
.
RequestFingerprint
();
ok
{
if
err
:=
idempotencyrecord
.
RequestFingerprintValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"request_fingerprint"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "IdempotencyRecord.request_fingerprint": %w`
,
err
)}
}
}
if
_
,
ok
:=
_c
.
mutation
.
Status
();
!
ok
{
return
&
ValidationError
{
Name
:
"status"
,
err
:
errors
.
New
(
`ent: missing required field "IdempotencyRecord.status"`
)}
}
if
v
,
ok
:=
_c
.
mutation
.
Status
();
ok
{
if
err
:=
idempotencyrecord
.
StatusValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"status"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "IdempotencyRecord.status": %w`
,
err
)}
}
}
if
v
,
ok
:=
_c
.
mutation
.
ErrorReason
();
ok
{
if
err
:=
idempotencyrecord
.
ErrorReasonValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"error_reason"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "IdempotencyRecord.error_reason": %w`
,
err
)}
}
}
if
_
,
ok
:=
_c
.
mutation
.
ExpiresAt
();
!
ok
{
return
&
ValidationError
{
Name
:
"expires_at"
,
err
:
errors
.
New
(
`ent: missing required field "IdempotencyRecord.expires_at"`
)}
}
return
nil
}
func
(
_c
*
IdempotencyRecordCreate
)
sqlSave
(
ctx
context
.
Context
)
(
*
IdempotencyRecord
,
error
)
{
if
err
:=
_c
.
check
();
err
!=
nil
{
return
nil
,
err
}
_node
,
_spec
:=
_c
.
createSpec
()
if
err
:=
sqlgraph
.
CreateNode
(
ctx
,
_c
.
driver
,
_spec
);
err
!=
nil
{
if
sqlgraph
.
IsConstraintError
(
err
)
{
err
=
&
ConstraintError
{
msg
:
err
.
Error
(),
wrap
:
err
}
}
return
nil
,
err
}
id
:=
_spec
.
ID
.
Value
.
(
int64
)
_node
.
ID
=
int64
(
id
)
_c
.
mutation
.
id
=
&
_node
.
ID
_c
.
mutation
.
done
=
true
return
_node
,
nil
}
func
(
_c
*
IdempotencyRecordCreate
)
createSpec
()
(
*
IdempotencyRecord
,
*
sqlgraph
.
CreateSpec
)
{
var
(
_node
=
&
IdempotencyRecord
{
config
:
_c
.
config
}
_spec
=
sqlgraph
.
NewCreateSpec
(
idempotencyrecord
.
Table
,
sqlgraph
.
NewFieldSpec
(
idempotencyrecord
.
FieldID
,
field
.
TypeInt64
))
)
_spec
.
OnConflict
=
_c
.
conflict
if
value
,
ok
:=
_c
.
mutation
.
CreatedAt
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldCreatedAt
,
field
.
TypeTime
,
value
)
_node
.
CreatedAt
=
value
}
if
value
,
ok
:=
_c
.
mutation
.
UpdatedAt
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldUpdatedAt
,
field
.
TypeTime
,
value
)
_node
.
UpdatedAt
=
value
}
if
value
,
ok
:=
_c
.
mutation
.
Scope
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldScope
,
field
.
TypeString
,
value
)
_node
.
Scope
=
value
}
if
value
,
ok
:=
_c
.
mutation
.
IdempotencyKeyHash
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldIdempotencyKeyHash
,
field
.
TypeString
,
value
)
_node
.
IdempotencyKeyHash
=
value
}
if
value
,
ok
:=
_c
.
mutation
.
RequestFingerprint
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldRequestFingerprint
,
field
.
TypeString
,
value
)
_node
.
RequestFingerprint
=
value
}
if
value
,
ok
:=
_c
.
mutation
.
Status
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldStatus
,
field
.
TypeString
,
value
)
_node
.
Status
=
value
}
if
value
,
ok
:=
_c
.
mutation
.
ResponseStatus
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldResponseStatus
,
field
.
TypeInt
,
value
)
_node
.
ResponseStatus
=
&
value
}
if
value
,
ok
:=
_c
.
mutation
.
ResponseBody
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldResponseBody
,
field
.
TypeString
,
value
)
_node
.
ResponseBody
=
&
value
}
if
value
,
ok
:=
_c
.
mutation
.
ErrorReason
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldErrorReason
,
field
.
TypeString
,
value
)
_node
.
ErrorReason
=
&
value
}
if
value
,
ok
:=
_c
.
mutation
.
LockedUntil
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldLockedUntil
,
field
.
TypeTime
,
value
)
_node
.
LockedUntil
=
&
value
}
if
value
,
ok
:=
_c
.
mutation
.
ExpiresAt
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldExpiresAt
,
field
.
TypeTime
,
value
)
_node
.
ExpiresAt
=
value
}
return
_node
,
_spec
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.IdempotencyRecord.Create().
// SetCreatedAt(v).
// OnConflict(
// // Update the row with the new values
// // the was proposed for insertion.
// sql.ResolveWithNewValues(),
// ).
// // Override some of the fields with custom
// // update values.
// Update(func(u *ent.IdempotencyRecordUpsert) {
// SetCreatedAt(v+v).
// }).
// Exec(ctx)
func
(
_c
*
IdempotencyRecordCreate
)
OnConflict
(
opts
...
sql
.
ConflictOption
)
*
IdempotencyRecordUpsertOne
{
_c
.
conflict
=
opts
return
&
IdempotencyRecordUpsertOne
{
create
:
_c
,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.IdempotencyRecord.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func
(
_c
*
IdempotencyRecordCreate
)
OnConflictColumns
(
columns
...
string
)
*
IdempotencyRecordUpsertOne
{
_c
.
conflict
=
append
(
_c
.
conflict
,
sql
.
ConflictColumns
(
columns
...
))
return
&
IdempotencyRecordUpsertOne
{
create
:
_c
,
}
}
type
(
// IdempotencyRecordUpsertOne is the builder for "upsert"-ing
// one IdempotencyRecord node.
IdempotencyRecordUpsertOne
struct
{
create
*
IdempotencyRecordCreate
}
// IdempotencyRecordUpsert is the "OnConflict" setter.
IdempotencyRecordUpsert
struct
{
*
sql
.
UpdateSet
}
)
// SetUpdatedAt sets the "updated_at" field.
func
(
u
*
IdempotencyRecordUpsert
)
SetUpdatedAt
(
v
time
.
Time
)
*
IdempotencyRecordUpsert
{
u
.
Set
(
idempotencyrecord
.
FieldUpdatedAt
,
v
)
return
u
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsert
)
UpdateUpdatedAt
()
*
IdempotencyRecordUpsert
{
u
.
SetExcluded
(
idempotencyrecord
.
FieldUpdatedAt
)
return
u
}
// SetScope sets the "scope" field.
func
(
u
*
IdempotencyRecordUpsert
)
SetScope
(
v
string
)
*
IdempotencyRecordUpsert
{
u
.
Set
(
idempotencyrecord
.
FieldScope
,
v
)
return
u
}
// UpdateScope sets the "scope" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsert
)
UpdateScope
()
*
IdempotencyRecordUpsert
{
u
.
SetExcluded
(
idempotencyrecord
.
FieldScope
)
return
u
}
// SetIdempotencyKeyHash sets the "idempotency_key_hash" field.
func
(
u
*
IdempotencyRecordUpsert
)
SetIdempotencyKeyHash
(
v
string
)
*
IdempotencyRecordUpsert
{
u
.
Set
(
idempotencyrecord
.
FieldIdempotencyKeyHash
,
v
)
return
u
}
// UpdateIdempotencyKeyHash sets the "idempotency_key_hash" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsert
)
UpdateIdempotencyKeyHash
()
*
IdempotencyRecordUpsert
{
u
.
SetExcluded
(
idempotencyrecord
.
FieldIdempotencyKeyHash
)
return
u
}
// SetRequestFingerprint sets the "request_fingerprint" field.
func
(
u
*
IdempotencyRecordUpsert
)
SetRequestFingerprint
(
v
string
)
*
IdempotencyRecordUpsert
{
u
.
Set
(
idempotencyrecord
.
FieldRequestFingerprint
,
v
)
return
u
}
// UpdateRequestFingerprint sets the "request_fingerprint" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsert
)
UpdateRequestFingerprint
()
*
IdempotencyRecordUpsert
{
u
.
SetExcluded
(
idempotencyrecord
.
FieldRequestFingerprint
)
return
u
}
// SetStatus sets the "status" field.
func
(
u
*
IdempotencyRecordUpsert
)
SetStatus
(
v
string
)
*
IdempotencyRecordUpsert
{
u
.
Set
(
idempotencyrecord
.
FieldStatus
,
v
)
return
u
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsert
)
UpdateStatus
()
*
IdempotencyRecordUpsert
{
u
.
SetExcluded
(
idempotencyrecord
.
FieldStatus
)
return
u
}
// SetResponseStatus sets the "response_status" field.
func
(
u
*
IdempotencyRecordUpsert
)
SetResponseStatus
(
v
int
)
*
IdempotencyRecordUpsert
{
u
.
Set
(
idempotencyrecord
.
FieldResponseStatus
,
v
)
return
u
}
// UpdateResponseStatus sets the "response_status" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsert
)
UpdateResponseStatus
()
*
IdempotencyRecordUpsert
{
u
.
SetExcluded
(
idempotencyrecord
.
FieldResponseStatus
)
return
u
}
// AddResponseStatus adds v to the "response_status" field.
func
(
u
*
IdempotencyRecordUpsert
)
AddResponseStatus
(
v
int
)
*
IdempotencyRecordUpsert
{
u
.
Add
(
idempotencyrecord
.
FieldResponseStatus
,
v
)
return
u
}
// ClearResponseStatus clears the value of the "response_status" field.
func
(
u
*
IdempotencyRecordUpsert
)
ClearResponseStatus
()
*
IdempotencyRecordUpsert
{
u
.
SetNull
(
idempotencyrecord
.
FieldResponseStatus
)
return
u
}
// SetResponseBody sets the "response_body" field.
func
(
u
*
IdempotencyRecordUpsert
)
SetResponseBody
(
v
string
)
*
IdempotencyRecordUpsert
{
u
.
Set
(
idempotencyrecord
.
FieldResponseBody
,
v
)
return
u
}
// UpdateResponseBody sets the "response_body" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsert
)
UpdateResponseBody
()
*
IdempotencyRecordUpsert
{
u
.
SetExcluded
(
idempotencyrecord
.
FieldResponseBody
)
return
u
}
// ClearResponseBody clears the value of the "response_body" field.
func
(
u
*
IdempotencyRecordUpsert
)
ClearResponseBody
()
*
IdempotencyRecordUpsert
{
u
.
SetNull
(
idempotencyrecord
.
FieldResponseBody
)
return
u
}
// SetErrorReason sets the "error_reason" field.
func
(
u
*
IdempotencyRecordUpsert
)
SetErrorReason
(
v
string
)
*
IdempotencyRecordUpsert
{
u
.
Set
(
idempotencyrecord
.
FieldErrorReason
,
v
)
return
u
}
// UpdateErrorReason sets the "error_reason" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsert
)
UpdateErrorReason
()
*
IdempotencyRecordUpsert
{
u
.
SetExcluded
(
idempotencyrecord
.
FieldErrorReason
)
return
u
}
// ClearErrorReason clears the value of the "error_reason" field.
func
(
u
*
IdempotencyRecordUpsert
)
ClearErrorReason
()
*
IdempotencyRecordUpsert
{
u
.
SetNull
(
idempotencyrecord
.
FieldErrorReason
)
return
u
}
// SetLockedUntil sets the "locked_until" field.
func
(
u
*
IdempotencyRecordUpsert
)
SetLockedUntil
(
v
time
.
Time
)
*
IdempotencyRecordUpsert
{
u
.
Set
(
idempotencyrecord
.
FieldLockedUntil
,
v
)
return
u
}
// UpdateLockedUntil sets the "locked_until" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsert
)
UpdateLockedUntil
()
*
IdempotencyRecordUpsert
{
u
.
SetExcluded
(
idempotencyrecord
.
FieldLockedUntil
)
return
u
}
// ClearLockedUntil clears the value of the "locked_until" field.
func
(
u
*
IdempotencyRecordUpsert
)
ClearLockedUntil
()
*
IdempotencyRecordUpsert
{
u
.
SetNull
(
idempotencyrecord
.
FieldLockedUntil
)
return
u
}
// SetExpiresAt sets the "expires_at" field.
func
(
u
*
IdempotencyRecordUpsert
)
SetExpiresAt
(
v
time
.
Time
)
*
IdempotencyRecordUpsert
{
u
.
Set
(
idempotencyrecord
.
FieldExpiresAt
,
v
)
return
u
}
// UpdateExpiresAt sets the "expires_at" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsert
)
UpdateExpiresAt
()
*
IdempotencyRecordUpsert
{
u
.
SetExcluded
(
idempotencyrecord
.
FieldExpiresAt
)
return
u
}
// UpdateNewValues updates the mutable fields using the new values that were set on create.
// Using this option is equivalent to using:
//
// client.IdempotencyRecord.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func
(
u
*
IdempotencyRecordUpsertOne
)
UpdateNewValues
()
*
IdempotencyRecordUpsertOne
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWithNewValues
())
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWith
(
func
(
s
*
sql
.
UpdateSet
)
{
if
_
,
exists
:=
u
.
create
.
mutation
.
CreatedAt
();
exists
{
s
.
SetIgnore
(
idempotencyrecord
.
FieldCreatedAt
)
}
}))
return
u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.IdempotencyRecord.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func
(
u
*
IdempotencyRecordUpsertOne
)
Ignore
()
*
IdempotencyRecordUpsertOne
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWithIgnore
())
return
u
}
// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func
(
u
*
IdempotencyRecordUpsertOne
)
DoNothing
()
*
IdempotencyRecordUpsertOne
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
DoNothing
())
return
u
}
// Update allows overriding fields `UPDATE` values. See the IdempotencyRecordCreate.OnConflict
// documentation for more info.
func
(
u
*
IdempotencyRecordUpsertOne
)
Update
(
set
func
(
*
IdempotencyRecordUpsert
))
*
IdempotencyRecordUpsertOne
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWith
(
func
(
update
*
sql
.
UpdateSet
)
{
set
(
&
IdempotencyRecordUpsert
{
UpdateSet
:
update
})
}))
return
u
}
// SetUpdatedAt sets the "updated_at" field.
func
(
u
*
IdempotencyRecordUpsertOne
)
SetUpdatedAt
(
v
time
.
Time
)
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
SetUpdatedAt
(
v
)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsertOne
)
UpdateUpdatedAt
()
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
UpdateUpdatedAt
()
})
}
// SetScope sets the "scope" field.
func
(
u
*
IdempotencyRecordUpsertOne
)
SetScope
(
v
string
)
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
SetScope
(
v
)
})
}
// UpdateScope sets the "scope" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsertOne
)
UpdateScope
()
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
UpdateScope
()
})
}
// SetIdempotencyKeyHash sets the "idempotency_key_hash" field.
func
(
u
*
IdempotencyRecordUpsertOne
)
SetIdempotencyKeyHash
(
v
string
)
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
SetIdempotencyKeyHash
(
v
)
})
}
// UpdateIdempotencyKeyHash sets the "idempotency_key_hash" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsertOne
)
UpdateIdempotencyKeyHash
()
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
UpdateIdempotencyKeyHash
()
})
}
// SetRequestFingerprint sets the "request_fingerprint" field.
func
(
u
*
IdempotencyRecordUpsertOne
)
SetRequestFingerprint
(
v
string
)
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
SetRequestFingerprint
(
v
)
})
}
// UpdateRequestFingerprint sets the "request_fingerprint" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsertOne
)
UpdateRequestFingerprint
()
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
UpdateRequestFingerprint
()
})
}
// SetStatus sets the "status" field.
func
(
u
*
IdempotencyRecordUpsertOne
)
SetStatus
(
v
string
)
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
SetStatus
(
v
)
})
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsertOne
)
UpdateStatus
()
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
UpdateStatus
()
})
}
// SetResponseStatus sets the "response_status" field.
func
(
u
*
IdempotencyRecordUpsertOne
)
SetResponseStatus
(
v
int
)
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
SetResponseStatus
(
v
)
})
}
// AddResponseStatus adds v to the "response_status" field.
func
(
u
*
IdempotencyRecordUpsertOne
)
AddResponseStatus
(
v
int
)
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
AddResponseStatus
(
v
)
})
}
// UpdateResponseStatus sets the "response_status" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsertOne
)
UpdateResponseStatus
()
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
UpdateResponseStatus
()
})
}
// ClearResponseStatus clears the value of the "response_status" field.
func
(
u
*
IdempotencyRecordUpsertOne
)
ClearResponseStatus
()
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
ClearResponseStatus
()
})
}
// SetResponseBody sets the "response_body" field.
func
(
u
*
IdempotencyRecordUpsertOne
)
SetResponseBody
(
v
string
)
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
SetResponseBody
(
v
)
})
}
// UpdateResponseBody sets the "response_body" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsertOne
)
UpdateResponseBody
()
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
UpdateResponseBody
()
})
}
// ClearResponseBody clears the value of the "response_body" field.
func
(
u
*
IdempotencyRecordUpsertOne
)
ClearResponseBody
()
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
ClearResponseBody
()
})
}
// SetErrorReason sets the "error_reason" field.
func
(
u
*
IdempotencyRecordUpsertOne
)
SetErrorReason
(
v
string
)
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
SetErrorReason
(
v
)
})
}
// UpdateErrorReason sets the "error_reason" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsertOne
)
UpdateErrorReason
()
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
UpdateErrorReason
()
})
}
// ClearErrorReason clears the value of the "error_reason" field.
func
(
u
*
IdempotencyRecordUpsertOne
)
ClearErrorReason
()
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
ClearErrorReason
()
})
}
// SetLockedUntil sets the "locked_until" field.
func
(
u
*
IdempotencyRecordUpsertOne
)
SetLockedUntil
(
v
time
.
Time
)
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
SetLockedUntil
(
v
)
})
}
// UpdateLockedUntil sets the "locked_until" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsertOne
)
UpdateLockedUntil
()
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
UpdateLockedUntil
()
})
}
// ClearLockedUntil clears the value of the "locked_until" field.
func
(
u
*
IdempotencyRecordUpsertOne
)
ClearLockedUntil
()
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
ClearLockedUntil
()
})
}
// SetExpiresAt sets the "expires_at" field.
func
(
u
*
IdempotencyRecordUpsertOne
)
SetExpiresAt
(
v
time
.
Time
)
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
SetExpiresAt
(
v
)
})
}
// UpdateExpiresAt sets the "expires_at" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsertOne
)
UpdateExpiresAt
()
*
IdempotencyRecordUpsertOne
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
UpdateExpiresAt
()
})
}
// Exec executes the query.
func
(
u
*
IdempotencyRecordUpsertOne
)
Exec
(
ctx
context
.
Context
)
error
{
if
len
(
u
.
create
.
conflict
)
==
0
{
return
errors
.
New
(
"ent: missing options for IdempotencyRecordCreate.OnConflict"
)
}
return
u
.
create
.
Exec
(
ctx
)
}
// ExecX is like Exec, but panics if an error occurs.
func
(
u
*
IdempotencyRecordUpsertOne
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
u
.
create
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
}
// Exec executes the UPSERT query and returns the inserted/updated ID.
func
(
u
*
IdempotencyRecordUpsertOne
)
ID
(
ctx
context
.
Context
)
(
id
int64
,
err
error
)
{
node
,
err
:=
u
.
create
.
Save
(
ctx
)
if
err
!=
nil
{
return
id
,
err
}
return
node
.
ID
,
nil
}
// IDX is like ID, but panics if an error occurs.
func
(
u
*
IdempotencyRecordUpsertOne
)
IDX
(
ctx
context
.
Context
)
int64
{
id
,
err
:=
u
.
ID
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
id
}
// IdempotencyRecordCreateBulk is the builder for creating many IdempotencyRecord entities in bulk.
type
IdempotencyRecordCreateBulk
struct
{
config
err
error
builders
[]
*
IdempotencyRecordCreate
conflict
[]
sql
.
ConflictOption
}
// Save creates the IdempotencyRecord entities in the database.
func
(
_c
*
IdempotencyRecordCreateBulk
)
Save
(
ctx
context
.
Context
)
([]
*
IdempotencyRecord
,
error
)
{
if
_c
.
err
!=
nil
{
return
nil
,
_c
.
err
}
specs
:=
make
([]
*
sqlgraph
.
CreateSpec
,
len
(
_c
.
builders
))
nodes
:=
make
([]
*
IdempotencyRecord
,
len
(
_c
.
builders
))
mutators
:=
make
([]
Mutator
,
len
(
_c
.
builders
))
for
i
:=
range
_c
.
builders
{
func
(
i
int
,
root
context
.
Context
)
{
builder
:=
_c
.
builders
[
i
]
builder
.
defaults
()
var
mut
Mutator
=
MutateFunc
(
func
(
ctx
context
.
Context
,
m
Mutation
)
(
Value
,
error
)
{
mutation
,
ok
:=
m
.
(
*
IdempotencyRecordMutation
)
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"unexpected mutation type %T"
,
m
)
}
if
err
:=
builder
.
check
();
err
!=
nil
{
return
nil
,
err
}
builder
.
mutation
=
mutation
var
err
error
nodes
[
i
],
specs
[
i
]
=
builder
.
createSpec
()
if
i
<
len
(
mutators
)
-
1
{
_
,
err
=
mutators
[
i
+
1
]
.
Mutate
(
root
,
_c
.
builders
[
i
+
1
]
.
mutation
)
}
else
{
spec
:=
&
sqlgraph
.
BatchCreateSpec
{
Nodes
:
specs
}
spec
.
OnConflict
=
_c
.
conflict
// Invoke the actual operation on the latest mutation in the chain.
if
err
=
sqlgraph
.
BatchCreate
(
ctx
,
_c
.
driver
,
spec
);
err
!=
nil
{
if
sqlgraph
.
IsConstraintError
(
err
)
{
err
=
&
ConstraintError
{
msg
:
err
.
Error
(),
wrap
:
err
}
}
}
}
if
err
!=
nil
{
return
nil
,
err
}
mutation
.
id
=
&
nodes
[
i
]
.
ID
if
specs
[
i
]
.
ID
.
Value
!=
nil
{
id
:=
specs
[
i
]
.
ID
.
Value
.
(
int64
)
nodes
[
i
]
.
ID
=
int64
(
id
)
}
mutation
.
done
=
true
return
nodes
[
i
],
nil
})
for
i
:=
len
(
builder
.
hooks
)
-
1
;
i
>=
0
;
i
--
{
mut
=
builder
.
hooks
[
i
](
mut
)
}
mutators
[
i
]
=
mut
}(
i
,
ctx
)
}
if
len
(
mutators
)
>
0
{
if
_
,
err
:=
mutators
[
0
]
.
Mutate
(
ctx
,
_c
.
builders
[
0
]
.
mutation
);
err
!=
nil
{
return
nil
,
err
}
}
return
nodes
,
nil
}
// SaveX is like Save, but panics if an error occurs.
func
(
_c
*
IdempotencyRecordCreateBulk
)
SaveX
(
ctx
context
.
Context
)
[]
*
IdempotencyRecord
{
v
,
err
:=
_c
.
Save
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
v
}
// Exec executes the query.
func
(
_c
*
IdempotencyRecordCreateBulk
)
Exec
(
ctx
context
.
Context
)
error
{
_
,
err
:=
_c
.
Save
(
ctx
)
return
err
}
// ExecX is like Exec, but panics if an error occurs.
func
(
_c
*
IdempotencyRecordCreateBulk
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
_c
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.IdempotencyRecord.CreateBulk(builders...).
// OnConflict(
// // Update the row with the new values
// // the was proposed for insertion.
// sql.ResolveWithNewValues(),
// ).
// // Override some of the fields with custom
// // update values.
// Update(func(u *ent.IdempotencyRecordUpsert) {
// SetCreatedAt(v+v).
// }).
// Exec(ctx)
func
(
_c
*
IdempotencyRecordCreateBulk
)
OnConflict
(
opts
...
sql
.
ConflictOption
)
*
IdempotencyRecordUpsertBulk
{
_c
.
conflict
=
opts
return
&
IdempotencyRecordUpsertBulk
{
create
:
_c
,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.IdempotencyRecord.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func
(
_c
*
IdempotencyRecordCreateBulk
)
OnConflictColumns
(
columns
...
string
)
*
IdempotencyRecordUpsertBulk
{
_c
.
conflict
=
append
(
_c
.
conflict
,
sql
.
ConflictColumns
(
columns
...
))
return
&
IdempotencyRecordUpsertBulk
{
create
:
_c
,
}
}
// IdempotencyRecordUpsertBulk is the builder for "upsert"-ing
// a bulk of IdempotencyRecord nodes.
type
IdempotencyRecordUpsertBulk
struct
{
create
*
IdempotencyRecordCreateBulk
}
// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
// client.IdempotencyRecord.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func
(
u
*
IdempotencyRecordUpsertBulk
)
UpdateNewValues
()
*
IdempotencyRecordUpsertBulk
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWithNewValues
())
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWith
(
func
(
s
*
sql
.
UpdateSet
)
{
for
_
,
b
:=
range
u
.
create
.
builders
{
if
_
,
exists
:=
b
.
mutation
.
CreatedAt
();
exists
{
s
.
SetIgnore
(
idempotencyrecord
.
FieldCreatedAt
)
}
}
}))
return
u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.IdempotencyRecord.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func
(
u
*
IdempotencyRecordUpsertBulk
)
Ignore
()
*
IdempotencyRecordUpsertBulk
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWithIgnore
())
return
u
}
// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func
(
u
*
IdempotencyRecordUpsertBulk
)
DoNothing
()
*
IdempotencyRecordUpsertBulk
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
DoNothing
())
return
u
}
// Update allows overriding fields `UPDATE` values. See the IdempotencyRecordCreateBulk.OnConflict
// documentation for more info.
func
(
u
*
IdempotencyRecordUpsertBulk
)
Update
(
set
func
(
*
IdempotencyRecordUpsert
))
*
IdempotencyRecordUpsertBulk
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWith
(
func
(
update
*
sql
.
UpdateSet
)
{
set
(
&
IdempotencyRecordUpsert
{
UpdateSet
:
update
})
}))
return
u
}
// SetUpdatedAt sets the "updated_at" field.
func
(
u
*
IdempotencyRecordUpsertBulk
)
SetUpdatedAt
(
v
time
.
Time
)
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
SetUpdatedAt
(
v
)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsertBulk
)
UpdateUpdatedAt
()
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
UpdateUpdatedAt
()
})
}
// SetScope sets the "scope" field.
func
(
u
*
IdempotencyRecordUpsertBulk
)
SetScope
(
v
string
)
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
SetScope
(
v
)
})
}
// UpdateScope sets the "scope" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsertBulk
)
UpdateScope
()
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
UpdateScope
()
})
}
// SetIdempotencyKeyHash sets the "idempotency_key_hash" field.
func
(
u
*
IdempotencyRecordUpsertBulk
)
SetIdempotencyKeyHash
(
v
string
)
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
SetIdempotencyKeyHash
(
v
)
})
}
// UpdateIdempotencyKeyHash sets the "idempotency_key_hash" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsertBulk
)
UpdateIdempotencyKeyHash
()
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
UpdateIdempotencyKeyHash
()
})
}
// SetRequestFingerprint sets the "request_fingerprint" field.
func
(
u
*
IdempotencyRecordUpsertBulk
)
SetRequestFingerprint
(
v
string
)
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
SetRequestFingerprint
(
v
)
})
}
// UpdateRequestFingerprint sets the "request_fingerprint" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsertBulk
)
UpdateRequestFingerprint
()
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
UpdateRequestFingerprint
()
})
}
// SetStatus sets the "status" field.
func
(
u
*
IdempotencyRecordUpsertBulk
)
SetStatus
(
v
string
)
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
SetStatus
(
v
)
})
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsertBulk
)
UpdateStatus
()
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
UpdateStatus
()
})
}
// SetResponseStatus sets the "response_status" field.
func
(
u
*
IdempotencyRecordUpsertBulk
)
SetResponseStatus
(
v
int
)
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
SetResponseStatus
(
v
)
})
}
// AddResponseStatus adds v to the "response_status" field.
func
(
u
*
IdempotencyRecordUpsertBulk
)
AddResponseStatus
(
v
int
)
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
AddResponseStatus
(
v
)
})
}
// UpdateResponseStatus sets the "response_status" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsertBulk
)
UpdateResponseStatus
()
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
UpdateResponseStatus
()
})
}
// ClearResponseStatus clears the value of the "response_status" field.
func
(
u
*
IdempotencyRecordUpsertBulk
)
ClearResponseStatus
()
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
ClearResponseStatus
()
})
}
// SetResponseBody sets the "response_body" field.
func
(
u
*
IdempotencyRecordUpsertBulk
)
SetResponseBody
(
v
string
)
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
SetResponseBody
(
v
)
})
}
// UpdateResponseBody sets the "response_body" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsertBulk
)
UpdateResponseBody
()
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
UpdateResponseBody
()
})
}
// ClearResponseBody clears the value of the "response_body" field.
func
(
u
*
IdempotencyRecordUpsertBulk
)
ClearResponseBody
()
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
ClearResponseBody
()
})
}
// SetErrorReason sets the "error_reason" field.
func
(
u
*
IdempotencyRecordUpsertBulk
)
SetErrorReason
(
v
string
)
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
SetErrorReason
(
v
)
})
}
// UpdateErrorReason sets the "error_reason" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsertBulk
)
UpdateErrorReason
()
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
UpdateErrorReason
()
})
}
// ClearErrorReason clears the value of the "error_reason" field.
func
(
u
*
IdempotencyRecordUpsertBulk
)
ClearErrorReason
()
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
ClearErrorReason
()
})
}
// SetLockedUntil sets the "locked_until" field.
func
(
u
*
IdempotencyRecordUpsertBulk
)
SetLockedUntil
(
v
time
.
Time
)
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
SetLockedUntil
(
v
)
})
}
// UpdateLockedUntil sets the "locked_until" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsertBulk
)
UpdateLockedUntil
()
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
UpdateLockedUntil
()
})
}
// ClearLockedUntil clears the value of the "locked_until" field.
func
(
u
*
IdempotencyRecordUpsertBulk
)
ClearLockedUntil
()
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
ClearLockedUntil
()
})
}
// SetExpiresAt sets the "expires_at" field.
func
(
u
*
IdempotencyRecordUpsertBulk
)
SetExpiresAt
(
v
time
.
Time
)
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
SetExpiresAt
(
v
)
})
}
// UpdateExpiresAt sets the "expires_at" field to the value that was provided on create.
func
(
u
*
IdempotencyRecordUpsertBulk
)
UpdateExpiresAt
()
*
IdempotencyRecordUpsertBulk
{
return
u
.
Update
(
func
(
s
*
IdempotencyRecordUpsert
)
{
s
.
UpdateExpiresAt
()
})
}
// Exec executes the query.
func
(
u
*
IdempotencyRecordUpsertBulk
)
Exec
(
ctx
context
.
Context
)
error
{
if
u
.
create
.
err
!=
nil
{
return
u
.
create
.
err
}
for
i
,
b
:=
range
u
.
create
.
builders
{
if
len
(
b
.
conflict
)
!=
0
{
return
fmt
.
Errorf
(
"ent: OnConflict was set for builder %d. Set it on the IdempotencyRecordCreateBulk instead"
,
i
)
}
}
if
len
(
u
.
create
.
conflict
)
==
0
{
return
errors
.
New
(
"ent: missing options for IdempotencyRecordCreateBulk.OnConflict"
)
}
return
u
.
create
.
Exec
(
ctx
)
}
// ExecX is like Exec, but panics if an error occurs.
func
(
u
*
IdempotencyRecordUpsertBulk
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
u
.
create
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
}
backend/ent/idempotencyrecord_delete.go
0 → 100644
View file @
bb664d9b
// 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/idempotencyrecord"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// IdempotencyRecordDelete is the builder for deleting a IdempotencyRecord entity.
type
IdempotencyRecordDelete
struct
{
config
hooks
[]
Hook
mutation
*
IdempotencyRecordMutation
}
// Where appends a list predicates to the IdempotencyRecordDelete builder.
func
(
_d
*
IdempotencyRecordDelete
)
Where
(
ps
...
predicate
.
IdempotencyRecord
)
*
IdempotencyRecordDelete
{
_d
.
mutation
.
Where
(
ps
...
)
return
_d
}
// Exec executes the deletion query and returns how many vertices were deleted.
func
(
_d
*
IdempotencyRecordDelete
)
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
*
IdempotencyRecordDelete
)
ExecX
(
ctx
context
.
Context
)
int
{
n
,
err
:=
_d
.
Exec
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
n
}
func
(
_d
*
IdempotencyRecordDelete
)
sqlExec
(
ctx
context
.
Context
)
(
int
,
error
)
{
_spec
:=
sqlgraph
.
NewDeleteSpec
(
idempotencyrecord
.
Table
,
sqlgraph
.
NewFieldSpec
(
idempotencyrecord
.
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
}
// IdempotencyRecordDeleteOne is the builder for deleting a single IdempotencyRecord entity.
type
IdempotencyRecordDeleteOne
struct
{
_d
*
IdempotencyRecordDelete
}
// Where appends a list predicates to the IdempotencyRecordDelete builder.
func
(
_d
*
IdempotencyRecordDeleteOne
)
Where
(
ps
...
predicate
.
IdempotencyRecord
)
*
IdempotencyRecordDeleteOne
{
_d
.
_d
.
mutation
.
Where
(
ps
...
)
return
_d
}
// Exec executes the deletion query.
func
(
_d
*
IdempotencyRecordDeleteOne
)
Exec
(
ctx
context
.
Context
)
error
{
n
,
err
:=
_d
.
_d
.
Exec
(
ctx
)
switch
{
case
err
!=
nil
:
return
err
case
n
==
0
:
return
&
NotFoundError
{
idempotencyrecord
.
Label
}
default
:
return
nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func
(
_d
*
IdempotencyRecordDeleteOne
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
_d
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
}
backend/ent/idempotencyrecord_query.go
0 → 100644
View file @
bb664d9b
// 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/idempotencyrecord"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// IdempotencyRecordQuery is the builder for querying IdempotencyRecord entities.
type
IdempotencyRecordQuery
struct
{
config
ctx
*
QueryContext
order
[]
idempotencyrecord
.
OrderOption
inters
[]
Interceptor
predicates
[]
predicate
.
IdempotencyRecord
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 IdempotencyRecordQuery builder.
func
(
_q
*
IdempotencyRecordQuery
)
Where
(
ps
...
predicate
.
IdempotencyRecord
)
*
IdempotencyRecordQuery
{
_q
.
predicates
=
append
(
_q
.
predicates
,
ps
...
)
return
_q
}
// Limit the number of records to be returned by this query.
func
(
_q
*
IdempotencyRecordQuery
)
Limit
(
limit
int
)
*
IdempotencyRecordQuery
{
_q
.
ctx
.
Limit
=
&
limit
return
_q
}
// Offset to start from.
func
(
_q
*
IdempotencyRecordQuery
)
Offset
(
offset
int
)
*
IdempotencyRecordQuery
{
_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
*
IdempotencyRecordQuery
)
Unique
(
unique
bool
)
*
IdempotencyRecordQuery
{
_q
.
ctx
.
Unique
=
&
unique
return
_q
}
// Order specifies how the records should be ordered.
func
(
_q
*
IdempotencyRecordQuery
)
Order
(
o
...
idempotencyrecord
.
OrderOption
)
*
IdempotencyRecordQuery
{
_q
.
order
=
append
(
_q
.
order
,
o
...
)
return
_q
}
// First returns the first IdempotencyRecord entity from the query.
// Returns a *NotFoundError when no IdempotencyRecord was found.
func
(
_q
*
IdempotencyRecordQuery
)
First
(
ctx
context
.
Context
)
(
*
IdempotencyRecord
,
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
{
idempotencyrecord
.
Label
}
}
return
nodes
[
0
],
nil
}
// FirstX is like First, but panics if an error occurs.
func
(
_q
*
IdempotencyRecordQuery
)
FirstX
(
ctx
context
.
Context
)
*
IdempotencyRecord
{
node
,
err
:=
_q
.
First
(
ctx
)
if
err
!=
nil
&&
!
IsNotFound
(
err
)
{
panic
(
err
)
}
return
node
}
// FirstID returns the first IdempotencyRecord ID from the query.
// Returns a *NotFoundError when no IdempotencyRecord ID was found.
func
(
_q
*
IdempotencyRecordQuery
)
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
{
idempotencyrecord
.
Label
}
return
}
return
ids
[
0
],
nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func
(
_q
*
IdempotencyRecordQuery
)
FirstIDX
(
ctx
context
.
Context
)
int64
{
id
,
err
:=
_q
.
FirstID
(
ctx
)
if
err
!=
nil
&&
!
IsNotFound
(
err
)
{
panic
(
err
)
}
return
id
}
// Only returns a single IdempotencyRecord entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one IdempotencyRecord entity is found.
// Returns a *NotFoundError when no IdempotencyRecord entities are found.
func
(
_q
*
IdempotencyRecordQuery
)
Only
(
ctx
context
.
Context
)
(
*
IdempotencyRecord
,
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
{
idempotencyrecord
.
Label
}
default
:
return
nil
,
&
NotSingularError
{
idempotencyrecord
.
Label
}
}
}
// OnlyX is like Only, but panics if an error occurs.
func
(
_q
*
IdempotencyRecordQuery
)
OnlyX
(
ctx
context
.
Context
)
*
IdempotencyRecord
{
node
,
err
:=
_q
.
Only
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
node
}
// OnlyID is like Only, but returns the only IdempotencyRecord ID in the query.
// Returns a *NotSingularError when more than one IdempotencyRecord ID is found.
// Returns a *NotFoundError when no entities are found.
func
(
_q
*
IdempotencyRecordQuery
)
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
{
idempotencyrecord
.
Label
}
default
:
err
=
&
NotSingularError
{
idempotencyrecord
.
Label
}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func
(
_q
*
IdempotencyRecordQuery
)
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 IdempotencyRecords.
func
(
_q
*
IdempotencyRecordQuery
)
All
(
ctx
context
.
Context
)
([]
*
IdempotencyRecord
,
error
)
{
ctx
=
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryAll
)
if
err
:=
_q
.
prepareQuery
(
ctx
);
err
!=
nil
{
return
nil
,
err
}
qr
:=
querierAll
[[]
*
IdempotencyRecord
,
*
IdempotencyRecordQuery
]()
return
withInterceptors
[[]
*
IdempotencyRecord
](
ctx
,
_q
,
qr
,
_q
.
inters
)
}
// AllX is like All, but panics if an error occurs.
func
(
_q
*
IdempotencyRecordQuery
)
AllX
(
ctx
context
.
Context
)
[]
*
IdempotencyRecord
{
nodes
,
err
:=
_q
.
All
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
nodes
}
// IDs executes the query and returns a list of IdempotencyRecord IDs.
func
(
_q
*
IdempotencyRecordQuery
)
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
(
idempotencyrecord
.
FieldID
)
.
Scan
(
ctx
,
&
ids
);
err
!=
nil
{
return
nil
,
err
}
return
ids
,
nil
}
// IDsX is like IDs, but panics if an error occurs.
func
(
_q
*
IdempotencyRecordQuery
)
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
*
IdempotencyRecordQuery
)
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
[
*
IdempotencyRecordQuery
](),
_q
.
inters
)
}
// CountX is like Count, but panics if an error occurs.
func
(
_q
*
IdempotencyRecordQuery
)
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
*
IdempotencyRecordQuery
)
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
*
IdempotencyRecordQuery
)
ExistX
(
ctx
context
.
Context
)
bool
{
exist
,
err
:=
_q
.
Exist
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
exist
}
// Clone returns a duplicate of the IdempotencyRecordQuery 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
*
IdempotencyRecordQuery
)
Clone
()
*
IdempotencyRecordQuery
{
if
_q
==
nil
{
return
nil
}
return
&
IdempotencyRecordQuery
{
config
:
_q
.
config
,
ctx
:
_q
.
ctx
.
Clone
(),
order
:
append
([]
idempotencyrecord
.
OrderOption
{},
_q
.
order
...
),
inters
:
append
([]
Interceptor
{},
_q
.
inters
...
),
predicates
:
append
([]
predicate
.
IdempotencyRecord
{},
_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 {
// CreatedAt time.Time `json:"created_at,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.IdempotencyRecord.Query().
// GroupBy(idempotencyrecord.FieldCreatedAt).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func
(
_q
*
IdempotencyRecordQuery
)
GroupBy
(
field
string
,
fields
...
string
)
*
IdempotencyRecordGroupBy
{
_q
.
ctx
.
Fields
=
append
([]
string
{
field
},
fields
...
)
grbuild
:=
&
IdempotencyRecordGroupBy
{
build
:
_q
}
grbuild
.
flds
=
&
_q
.
ctx
.
Fields
grbuild
.
label
=
idempotencyrecord
.
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 {
// CreatedAt time.Time `json:"created_at,omitempty"`
// }
//
// client.IdempotencyRecord.Query().
// Select(idempotencyrecord.FieldCreatedAt).
// Scan(ctx, &v)
func
(
_q
*
IdempotencyRecordQuery
)
Select
(
fields
...
string
)
*
IdempotencyRecordSelect
{
_q
.
ctx
.
Fields
=
append
(
_q
.
ctx
.
Fields
,
fields
...
)
sbuild
:=
&
IdempotencyRecordSelect
{
IdempotencyRecordQuery
:
_q
}
sbuild
.
label
=
idempotencyrecord
.
Label
sbuild
.
flds
,
sbuild
.
scan
=
&
_q
.
ctx
.
Fields
,
sbuild
.
Scan
return
sbuild
}
// Aggregate returns a IdempotencyRecordSelect configured with the given aggregations.
func
(
_q
*
IdempotencyRecordQuery
)
Aggregate
(
fns
...
AggregateFunc
)
*
IdempotencyRecordSelect
{
return
_q
.
Select
()
.
Aggregate
(
fns
...
)
}
func
(
_q
*
IdempotencyRecordQuery
)
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
!
idempotencyrecord
.
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
*
IdempotencyRecordQuery
)
sqlAll
(
ctx
context
.
Context
,
hooks
...
queryHook
)
([]
*
IdempotencyRecord
,
error
)
{
var
(
nodes
=
[]
*
IdempotencyRecord
{}
_spec
=
_q
.
querySpec
()
)
_spec
.
ScanValues
=
func
(
columns
[]
string
)
([]
any
,
error
)
{
return
(
*
IdempotencyRecord
)
.
scanValues
(
nil
,
columns
)
}
_spec
.
Assign
=
func
(
columns
[]
string
,
values
[]
any
)
error
{
node
:=
&
IdempotencyRecord
{
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
*
IdempotencyRecordQuery
)
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
*
IdempotencyRecordQuery
)
querySpec
()
*
sqlgraph
.
QuerySpec
{
_spec
:=
sqlgraph
.
NewQuerySpec
(
idempotencyrecord
.
Table
,
idempotencyrecord
.
Columns
,
sqlgraph
.
NewFieldSpec
(
idempotencyrecord
.
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
,
idempotencyrecord
.
FieldID
)
for
i
:=
range
fields
{
if
fields
[
i
]
!=
idempotencyrecord
.
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
*
IdempotencyRecordQuery
)
sqlQuery
(
ctx
context
.
Context
)
*
sql
.
Selector
{
builder
:=
sql
.
Dialect
(
_q
.
driver
.
Dialect
())
t1
:=
builder
.
Table
(
idempotencyrecord
.
Table
)
columns
:=
_q
.
ctx
.
Fields
if
len
(
columns
)
==
0
{
columns
=
idempotencyrecord
.
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
*
IdempotencyRecordQuery
)
ForUpdate
(
opts
...
sql
.
LockOption
)
*
IdempotencyRecordQuery
{
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
*
IdempotencyRecordQuery
)
ForShare
(
opts
...
sql
.
LockOption
)
*
IdempotencyRecordQuery
{
if
_q
.
driver
.
Dialect
()
==
dialect
.
Postgres
{
_q
.
Unique
(
false
)
}
_q
.
modifiers
=
append
(
_q
.
modifiers
,
func
(
s
*
sql
.
Selector
)
{
s
.
ForShare
(
opts
...
)
})
return
_q
}
// IdempotencyRecordGroupBy is the group-by builder for IdempotencyRecord entities.
type
IdempotencyRecordGroupBy
struct
{
selector
build
*
IdempotencyRecordQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func
(
_g
*
IdempotencyRecordGroupBy
)
Aggregate
(
fns
...
AggregateFunc
)
*
IdempotencyRecordGroupBy
{
_g
.
fns
=
append
(
_g
.
fns
,
fns
...
)
return
_g
}
// Scan applies the selector query and scans the result into the given value.
func
(
_g
*
IdempotencyRecordGroupBy
)
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
[
*
IdempotencyRecordQuery
,
*
IdempotencyRecordGroupBy
](
ctx
,
_g
.
build
,
_g
,
_g
.
build
.
inters
,
v
)
}
func
(
_g
*
IdempotencyRecordGroupBy
)
sqlScan
(
ctx
context
.
Context
,
root
*
IdempotencyRecordQuery
,
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
)
}
// IdempotencyRecordSelect is the builder for selecting fields of IdempotencyRecord entities.
type
IdempotencyRecordSelect
struct
{
*
IdempotencyRecordQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func
(
_s
*
IdempotencyRecordSelect
)
Aggregate
(
fns
...
AggregateFunc
)
*
IdempotencyRecordSelect
{
_s
.
fns
=
append
(
_s
.
fns
,
fns
...
)
return
_s
}
// Scan applies the selector query and scans the result into the given value.
func
(
_s
*
IdempotencyRecordSelect
)
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
[
*
IdempotencyRecordQuery
,
*
IdempotencyRecordSelect
](
ctx
,
_s
.
IdempotencyRecordQuery
,
_s
,
_s
.
inters
,
v
)
}
func
(
_s
*
IdempotencyRecordSelect
)
sqlScan
(
ctx
context
.
Context
,
root
*
IdempotencyRecordQuery
,
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/idempotencyrecord_update.go
0 → 100644
View file @
bb664d9b
// Code generated by ent, DO NOT EDIT.
package
ent
import
(
"context"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/idempotencyrecord"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// IdempotencyRecordUpdate is the builder for updating IdempotencyRecord entities.
type
IdempotencyRecordUpdate
struct
{
config
hooks
[]
Hook
mutation
*
IdempotencyRecordMutation
}
// Where appends a list predicates to the IdempotencyRecordUpdate builder.
func
(
_u
*
IdempotencyRecordUpdate
)
Where
(
ps
...
predicate
.
IdempotencyRecord
)
*
IdempotencyRecordUpdate
{
_u
.
mutation
.
Where
(
ps
...
)
return
_u
}
// SetUpdatedAt sets the "updated_at" field.
func
(
_u
*
IdempotencyRecordUpdate
)
SetUpdatedAt
(
v
time
.
Time
)
*
IdempotencyRecordUpdate
{
_u
.
mutation
.
SetUpdatedAt
(
v
)
return
_u
}
// SetScope sets the "scope" field.
func
(
_u
*
IdempotencyRecordUpdate
)
SetScope
(
v
string
)
*
IdempotencyRecordUpdate
{
_u
.
mutation
.
SetScope
(
v
)
return
_u
}
// SetNillableScope sets the "scope" field if the given value is not nil.
func
(
_u
*
IdempotencyRecordUpdate
)
SetNillableScope
(
v
*
string
)
*
IdempotencyRecordUpdate
{
if
v
!=
nil
{
_u
.
SetScope
(
*
v
)
}
return
_u
}
// SetIdempotencyKeyHash sets the "idempotency_key_hash" field.
func
(
_u
*
IdempotencyRecordUpdate
)
SetIdempotencyKeyHash
(
v
string
)
*
IdempotencyRecordUpdate
{
_u
.
mutation
.
SetIdempotencyKeyHash
(
v
)
return
_u
}
// SetNillableIdempotencyKeyHash sets the "idempotency_key_hash" field if the given value is not nil.
func
(
_u
*
IdempotencyRecordUpdate
)
SetNillableIdempotencyKeyHash
(
v
*
string
)
*
IdempotencyRecordUpdate
{
if
v
!=
nil
{
_u
.
SetIdempotencyKeyHash
(
*
v
)
}
return
_u
}
// SetRequestFingerprint sets the "request_fingerprint" field.
func
(
_u
*
IdempotencyRecordUpdate
)
SetRequestFingerprint
(
v
string
)
*
IdempotencyRecordUpdate
{
_u
.
mutation
.
SetRequestFingerprint
(
v
)
return
_u
}
// SetNillableRequestFingerprint sets the "request_fingerprint" field if the given value is not nil.
func
(
_u
*
IdempotencyRecordUpdate
)
SetNillableRequestFingerprint
(
v
*
string
)
*
IdempotencyRecordUpdate
{
if
v
!=
nil
{
_u
.
SetRequestFingerprint
(
*
v
)
}
return
_u
}
// SetStatus sets the "status" field.
func
(
_u
*
IdempotencyRecordUpdate
)
SetStatus
(
v
string
)
*
IdempotencyRecordUpdate
{
_u
.
mutation
.
SetStatus
(
v
)
return
_u
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func
(
_u
*
IdempotencyRecordUpdate
)
SetNillableStatus
(
v
*
string
)
*
IdempotencyRecordUpdate
{
if
v
!=
nil
{
_u
.
SetStatus
(
*
v
)
}
return
_u
}
// SetResponseStatus sets the "response_status" field.
func
(
_u
*
IdempotencyRecordUpdate
)
SetResponseStatus
(
v
int
)
*
IdempotencyRecordUpdate
{
_u
.
mutation
.
ResetResponseStatus
()
_u
.
mutation
.
SetResponseStatus
(
v
)
return
_u
}
// SetNillableResponseStatus sets the "response_status" field if the given value is not nil.
func
(
_u
*
IdempotencyRecordUpdate
)
SetNillableResponseStatus
(
v
*
int
)
*
IdempotencyRecordUpdate
{
if
v
!=
nil
{
_u
.
SetResponseStatus
(
*
v
)
}
return
_u
}
// AddResponseStatus adds value to the "response_status" field.
func
(
_u
*
IdempotencyRecordUpdate
)
AddResponseStatus
(
v
int
)
*
IdempotencyRecordUpdate
{
_u
.
mutation
.
AddResponseStatus
(
v
)
return
_u
}
// ClearResponseStatus clears the value of the "response_status" field.
func
(
_u
*
IdempotencyRecordUpdate
)
ClearResponseStatus
()
*
IdempotencyRecordUpdate
{
_u
.
mutation
.
ClearResponseStatus
()
return
_u
}
// SetResponseBody sets the "response_body" field.
func
(
_u
*
IdempotencyRecordUpdate
)
SetResponseBody
(
v
string
)
*
IdempotencyRecordUpdate
{
_u
.
mutation
.
SetResponseBody
(
v
)
return
_u
}
// SetNillableResponseBody sets the "response_body" field if the given value is not nil.
func
(
_u
*
IdempotencyRecordUpdate
)
SetNillableResponseBody
(
v
*
string
)
*
IdempotencyRecordUpdate
{
if
v
!=
nil
{
_u
.
SetResponseBody
(
*
v
)
}
return
_u
}
// ClearResponseBody clears the value of the "response_body" field.
func
(
_u
*
IdempotencyRecordUpdate
)
ClearResponseBody
()
*
IdempotencyRecordUpdate
{
_u
.
mutation
.
ClearResponseBody
()
return
_u
}
// SetErrorReason sets the "error_reason" field.
func
(
_u
*
IdempotencyRecordUpdate
)
SetErrorReason
(
v
string
)
*
IdempotencyRecordUpdate
{
_u
.
mutation
.
SetErrorReason
(
v
)
return
_u
}
// SetNillableErrorReason sets the "error_reason" field if the given value is not nil.
func
(
_u
*
IdempotencyRecordUpdate
)
SetNillableErrorReason
(
v
*
string
)
*
IdempotencyRecordUpdate
{
if
v
!=
nil
{
_u
.
SetErrorReason
(
*
v
)
}
return
_u
}
// ClearErrorReason clears the value of the "error_reason" field.
func
(
_u
*
IdempotencyRecordUpdate
)
ClearErrorReason
()
*
IdempotencyRecordUpdate
{
_u
.
mutation
.
ClearErrorReason
()
return
_u
}
// SetLockedUntil sets the "locked_until" field.
func
(
_u
*
IdempotencyRecordUpdate
)
SetLockedUntil
(
v
time
.
Time
)
*
IdempotencyRecordUpdate
{
_u
.
mutation
.
SetLockedUntil
(
v
)
return
_u
}
// SetNillableLockedUntil sets the "locked_until" field if the given value is not nil.
func
(
_u
*
IdempotencyRecordUpdate
)
SetNillableLockedUntil
(
v
*
time
.
Time
)
*
IdempotencyRecordUpdate
{
if
v
!=
nil
{
_u
.
SetLockedUntil
(
*
v
)
}
return
_u
}
// ClearLockedUntil clears the value of the "locked_until" field.
func
(
_u
*
IdempotencyRecordUpdate
)
ClearLockedUntil
()
*
IdempotencyRecordUpdate
{
_u
.
mutation
.
ClearLockedUntil
()
return
_u
}
// SetExpiresAt sets the "expires_at" field.
func
(
_u
*
IdempotencyRecordUpdate
)
SetExpiresAt
(
v
time
.
Time
)
*
IdempotencyRecordUpdate
{
_u
.
mutation
.
SetExpiresAt
(
v
)
return
_u
}
// SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
func
(
_u
*
IdempotencyRecordUpdate
)
SetNillableExpiresAt
(
v
*
time
.
Time
)
*
IdempotencyRecordUpdate
{
if
v
!=
nil
{
_u
.
SetExpiresAt
(
*
v
)
}
return
_u
}
// Mutation returns the IdempotencyRecordMutation object of the builder.
func
(
_u
*
IdempotencyRecordUpdate
)
Mutation
()
*
IdempotencyRecordMutation
{
return
_u
.
mutation
}
// Save executes the query and returns the number of nodes affected by the update operation.
func
(
_u
*
IdempotencyRecordUpdate
)
Save
(
ctx
context
.
Context
)
(
int
,
error
)
{
_u
.
defaults
()
return
withHooks
(
ctx
,
_u
.
sqlSave
,
_u
.
mutation
,
_u
.
hooks
)
}
// SaveX is like Save, but panics if an error occurs.
func
(
_u
*
IdempotencyRecordUpdate
)
SaveX
(
ctx
context
.
Context
)
int
{
affected
,
err
:=
_u
.
Save
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
affected
}
// Exec executes the query.
func
(
_u
*
IdempotencyRecordUpdate
)
Exec
(
ctx
context
.
Context
)
error
{
_
,
err
:=
_u
.
Save
(
ctx
)
return
err
}
// ExecX is like Exec, but panics if an error occurs.
func
(
_u
*
IdempotencyRecordUpdate
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
_u
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
}
// defaults sets the default values of the builder before save.
func
(
_u
*
IdempotencyRecordUpdate
)
defaults
()
{
if
_
,
ok
:=
_u
.
mutation
.
UpdatedAt
();
!
ok
{
v
:=
idempotencyrecord
.
UpdateDefaultUpdatedAt
()
_u
.
mutation
.
SetUpdatedAt
(
v
)
}
}
// check runs all checks and user-defined validators on the builder.
func
(
_u
*
IdempotencyRecordUpdate
)
check
()
error
{
if
v
,
ok
:=
_u
.
mutation
.
Scope
();
ok
{
if
err
:=
idempotencyrecord
.
ScopeValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"scope"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "IdempotencyRecord.scope": %w`
,
err
)}
}
}
if
v
,
ok
:=
_u
.
mutation
.
IdempotencyKeyHash
();
ok
{
if
err
:=
idempotencyrecord
.
IdempotencyKeyHashValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"idempotency_key_hash"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "IdempotencyRecord.idempotency_key_hash": %w`
,
err
)}
}
}
if
v
,
ok
:=
_u
.
mutation
.
RequestFingerprint
();
ok
{
if
err
:=
idempotencyrecord
.
RequestFingerprintValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"request_fingerprint"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "IdempotencyRecord.request_fingerprint": %w`
,
err
)}
}
}
if
v
,
ok
:=
_u
.
mutation
.
Status
();
ok
{
if
err
:=
idempotencyrecord
.
StatusValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"status"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "IdempotencyRecord.status": %w`
,
err
)}
}
}
if
v
,
ok
:=
_u
.
mutation
.
ErrorReason
();
ok
{
if
err
:=
idempotencyrecord
.
ErrorReasonValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"error_reason"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "IdempotencyRecord.error_reason": %w`
,
err
)}
}
}
return
nil
}
func
(
_u
*
IdempotencyRecordUpdate
)
sqlSave
(
ctx
context
.
Context
)
(
_node
int
,
err
error
)
{
if
err
:=
_u
.
check
();
err
!=
nil
{
return
_node
,
err
}
_spec
:=
sqlgraph
.
NewUpdateSpec
(
idempotencyrecord
.
Table
,
idempotencyrecord
.
Columns
,
sqlgraph
.
NewFieldSpec
(
idempotencyrecord
.
FieldID
,
field
.
TypeInt64
))
if
ps
:=
_u
.
mutation
.
predicates
;
len
(
ps
)
>
0
{
_spec
.
Predicate
=
func
(
selector
*
sql
.
Selector
)
{
for
i
:=
range
ps
{
ps
[
i
](
selector
)
}
}
}
if
value
,
ok
:=
_u
.
mutation
.
UpdatedAt
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldUpdatedAt
,
field
.
TypeTime
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
Scope
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldScope
,
field
.
TypeString
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
IdempotencyKeyHash
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldIdempotencyKeyHash
,
field
.
TypeString
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
RequestFingerprint
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldRequestFingerprint
,
field
.
TypeString
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
Status
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldStatus
,
field
.
TypeString
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
ResponseStatus
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldResponseStatus
,
field
.
TypeInt
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
AddedResponseStatus
();
ok
{
_spec
.
AddField
(
idempotencyrecord
.
FieldResponseStatus
,
field
.
TypeInt
,
value
)
}
if
_u
.
mutation
.
ResponseStatusCleared
()
{
_spec
.
ClearField
(
idempotencyrecord
.
FieldResponseStatus
,
field
.
TypeInt
)
}
if
value
,
ok
:=
_u
.
mutation
.
ResponseBody
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldResponseBody
,
field
.
TypeString
,
value
)
}
if
_u
.
mutation
.
ResponseBodyCleared
()
{
_spec
.
ClearField
(
idempotencyrecord
.
FieldResponseBody
,
field
.
TypeString
)
}
if
value
,
ok
:=
_u
.
mutation
.
ErrorReason
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldErrorReason
,
field
.
TypeString
,
value
)
}
if
_u
.
mutation
.
ErrorReasonCleared
()
{
_spec
.
ClearField
(
idempotencyrecord
.
FieldErrorReason
,
field
.
TypeString
)
}
if
value
,
ok
:=
_u
.
mutation
.
LockedUntil
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldLockedUntil
,
field
.
TypeTime
,
value
)
}
if
_u
.
mutation
.
LockedUntilCleared
()
{
_spec
.
ClearField
(
idempotencyrecord
.
FieldLockedUntil
,
field
.
TypeTime
)
}
if
value
,
ok
:=
_u
.
mutation
.
ExpiresAt
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldExpiresAt
,
field
.
TypeTime
,
value
)
}
if
_node
,
err
=
sqlgraph
.
UpdateNodes
(
ctx
,
_u
.
driver
,
_spec
);
err
!=
nil
{
if
_
,
ok
:=
err
.
(
*
sqlgraph
.
NotFoundError
);
ok
{
err
=
&
NotFoundError
{
idempotencyrecord
.
Label
}
}
else
if
sqlgraph
.
IsConstraintError
(
err
)
{
err
=
&
ConstraintError
{
msg
:
err
.
Error
(),
wrap
:
err
}
}
return
0
,
err
}
_u
.
mutation
.
done
=
true
return
_node
,
nil
}
// IdempotencyRecordUpdateOne is the builder for updating a single IdempotencyRecord entity.
type
IdempotencyRecordUpdateOne
struct
{
config
fields
[]
string
hooks
[]
Hook
mutation
*
IdempotencyRecordMutation
}
// SetUpdatedAt sets the "updated_at" field.
func
(
_u
*
IdempotencyRecordUpdateOne
)
SetUpdatedAt
(
v
time
.
Time
)
*
IdempotencyRecordUpdateOne
{
_u
.
mutation
.
SetUpdatedAt
(
v
)
return
_u
}
// SetScope sets the "scope" field.
func
(
_u
*
IdempotencyRecordUpdateOne
)
SetScope
(
v
string
)
*
IdempotencyRecordUpdateOne
{
_u
.
mutation
.
SetScope
(
v
)
return
_u
}
// SetNillableScope sets the "scope" field if the given value is not nil.
func
(
_u
*
IdempotencyRecordUpdateOne
)
SetNillableScope
(
v
*
string
)
*
IdempotencyRecordUpdateOne
{
if
v
!=
nil
{
_u
.
SetScope
(
*
v
)
}
return
_u
}
// SetIdempotencyKeyHash sets the "idempotency_key_hash" field.
func
(
_u
*
IdempotencyRecordUpdateOne
)
SetIdempotencyKeyHash
(
v
string
)
*
IdempotencyRecordUpdateOne
{
_u
.
mutation
.
SetIdempotencyKeyHash
(
v
)
return
_u
}
// SetNillableIdempotencyKeyHash sets the "idempotency_key_hash" field if the given value is not nil.
func
(
_u
*
IdempotencyRecordUpdateOne
)
SetNillableIdempotencyKeyHash
(
v
*
string
)
*
IdempotencyRecordUpdateOne
{
if
v
!=
nil
{
_u
.
SetIdempotencyKeyHash
(
*
v
)
}
return
_u
}
// SetRequestFingerprint sets the "request_fingerprint" field.
func
(
_u
*
IdempotencyRecordUpdateOne
)
SetRequestFingerprint
(
v
string
)
*
IdempotencyRecordUpdateOne
{
_u
.
mutation
.
SetRequestFingerprint
(
v
)
return
_u
}
// SetNillableRequestFingerprint sets the "request_fingerprint" field if the given value is not nil.
func
(
_u
*
IdempotencyRecordUpdateOne
)
SetNillableRequestFingerprint
(
v
*
string
)
*
IdempotencyRecordUpdateOne
{
if
v
!=
nil
{
_u
.
SetRequestFingerprint
(
*
v
)
}
return
_u
}
// SetStatus sets the "status" field.
func
(
_u
*
IdempotencyRecordUpdateOne
)
SetStatus
(
v
string
)
*
IdempotencyRecordUpdateOne
{
_u
.
mutation
.
SetStatus
(
v
)
return
_u
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func
(
_u
*
IdempotencyRecordUpdateOne
)
SetNillableStatus
(
v
*
string
)
*
IdempotencyRecordUpdateOne
{
if
v
!=
nil
{
_u
.
SetStatus
(
*
v
)
}
return
_u
}
// SetResponseStatus sets the "response_status" field.
func
(
_u
*
IdempotencyRecordUpdateOne
)
SetResponseStatus
(
v
int
)
*
IdempotencyRecordUpdateOne
{
_u
.
mutation
.
ResetResponseStatus
()
_u
.
mutation
.
SetResponseStatus
(
v
)
return
_u
}
// SetNillableResponseStatus sets the "response_status" field if the given value is not nil.
func
(
_u
*
IdempotencyRecordUpdateOne
)
SetNillableResponseStatus
(
v
*
int
)
*
IdempotencyRecordUpdateOne
{
if
v
!=
nil
{
_u
.
SetResponseStatus
(
*
v
)
}
return
_u
}
// AddResponseStatus adds value to the "response_status" field.
func
(
_u
*
IdempotencyRecordUpdateOne
)
AddResponseStatus
(
v
int
)
*
IdempotencyRecordUpdateOne
{
_u
.
mutation
.
AddResponseStatus
(
v
)
return
_u
}
// ClearResponseStatus clears the value of the "response_status" field.
func
(
_u
*
IdempotencyRecordUpdateOne
)
ClearResponseStatus
()
*
IdempotencyRecordUpdateOne
{
_u
.
mutation
.
ClearResponseStatus
()
return
_u
}
// SetResponseBody sets the "response_body" field.
func
(
_u
*
IdempotencyRecordUpdateOne
)
SetResponseBody
(
v
string
)
*
IdempotencyRecordUpdateOne
{
_u
.
mutation
.
SetResponseBody
(
v
)
return
_u
}
// SetNillableResponseBody sets the "response_body" field if the given value is not nil.
func
(
_u
*
IdempotencyRecordUpdateOne
)
SetNillableResponseBody
(
v
*
string
)
*
IdempotencyRecordUpdateOne
{
if
v
!=
nil
{
_u
.
SetResponseBody
(
*
v
)
}
return
_u
}
// ClearResponseBody clears the value of the "response_body" field.
func
(
_u
*
IdempotencyRecordUpdateOne
)
ClearResponseBody
()
*
IdempotencyRecordUpdateOne
{
_u
.
mutation
.
ClearResponseBody
()
return
_u
}
// SetErrorReason sets the "error_reason" field.
func
(
_u
*
IdempotencyRecordUpdateOne
)
SetErrorReason
(
v
string
)
*
IdempotencyRecordUpdateOne
{
_u
.
mutation
.
SetErrorReason
(
v
)
return
_u
}
// SetNillableErrorReason sets the "error_reason" field if the given value is not nil.
func
(
_u
*
IdempotencyRecordUpdateOne
)
SetNillableErrorReason
(
v
*
string
)
*
IdempotencyRecordUpdateOne
{
if
v
!=
nil
{
_u
.
SetErrorReason
(
*
v
)
}
return
_u
}
// ClearErrorReason clears the value of the "error_reason" field.
func
(
_u
*
IdempotencyRecordUpdateOne
)
ClearErrorReason
()
*
IdempotencyRecordUpdateOne
{
_u
.
mutation
.
ClearErrorReason
()
return
_u
}
// SetLockedUntil sets the "locked_until" field.
func
(
_u
*
IdempotencyRecordUpdateOne
)
SetLockedUntil
(
v
time
.
Time
)
*
IdempotencyRecordUpdateOne
{
_u
.
mutation
.
SetLockedUntil
(
v
)
return
_u
}
// SetNillableLockedUntil sets the "locked_until" field if the given value is not nil.
func
(
_u
*
IdempotencyRecordUpdateOne
)
SetNillableLockedUntil
(
v
*
time
.
Time
)
*
IdempotencyRecordUpdateOne
{
if
v
!=
nil
{
_u
.
SetLockedUntil
(
*
v
)
}
return
_u
}
// ClearLockedUntil clears the value of the "locked_until" field.
func
(
_u
*
IdempotencyRecordUpdateOne
)
ClearLockedUntil
()
*
IdempotencyRecordUpdateOne
{
_u
.
mutation
.
ClearLockedUntil
()
return
_u
}
// SetExpiresAt sets the "expires_at" field.
func
(
_u
*
IdempotencyRecordUpdateOne
)
SetExpiresAt
(
v
time
.
Time
)
*
IdempotencyRecordUpdateOne
{
_u
.
mutation
.
SetExpiresAt
(
v
)
return
_u
}
// SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
func
(
_u
*
IdempotencyRecordUpdateOne
)
SetNillableExpiresAt
(
v
*
time
.
Time
)
*
IdempotencyRecordUpdateOne
{
if
v
!=
nil
{
_u
.
SetExpiresAt
(
*
v
)
}
return
_u
}
// Mutation returns the IdempotencyRecordMutation object of the builder.
func
(
_u
*
IdempotencyRecordUpdateOne
)
Mutation
()
*
IdempotencyRecordMutation
{
return
_u
.
mutation
}
// Where appends a list predicates to the IdempotencyRecordUpdate builder.
func
(
_u
*
IdempotencyRecordUpdateOne
)
Where
(
ps
...
predicate
.
IdempotencyRecord
)
*
IdempotencyRecordUpdateOne
{
_u
.
mutation
.
Where
(
ps
...
)
return
_u
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func
(
_u
*
IdempotencyRecordUpdateOne
)
Select
(
field
string
,
fields
...
string
)
*
IdempotencyRecordUpdateOne
{
_u
.
fields
=
append
([]
string
{
field
},
fields
...
)
return
_u
}
// Save executes the query and returns the updated IdempotencyRecord entity.
func
(
_u
*
IdempotencyRecordUpdateOne
)
Save
(
ctx
context
.
Context
)
(
*
IdempotencyRecord
,
error
)
{
_u
.
defaults
()
return
withHooks
(
ctx
,
_u
.
sqlSave
,
_u
.
mutation
,
_u
.
hooks
)
}
// SaveX is like Save, but panics if an error occurs.
func
(
_u
*
IdempotencyRecordUpdateOne
)
SaveX
(
ctx
context
.
Context
)
*
IdempotencyRecord
{
node
,
err
:=
_u
.
Save
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
node
}
// Exec executes the query on the entity.
func
(
_u
*
IdempotencyRecordUpdateOne
)
Exec
(
ctx
context
.
Context
)
error
{
_
,
err
:=
_u
.
Save
(
ctx
)
return
err
}
// ExecX is like Exec, but panics if an error occurs.
func
(
_u
*
IdempotencyRecordUpdateOne
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
_u
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
}
// defaults sets the default values of the builder before save.
func
(
_u
*
IdempotencyRecordUpdateOne
)
defaults
()
{
if
_
,
ok
:=
_u
.
mutation
.
UpdatedAt
();
!
ok
{
v
:=
idempotencyrecord
.
UpdateDefaultUpdatedAt
()
_u
.
mutation
.
SetUpdatedAt
(
v
)
}
}
// check runs all checks and user-defined validators on the builder.
func
(
_u
*
IdempotencyRecordUpdateOne
)
check
()
error
{
if
v
,
ok
:=
_u
.
mutation
.
Scope
();
ok
{
if
err
:=
idempotencyrecord
.
ScopeValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"scope"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "IdempotencyRecord.scope": %w`
,
err
)}
}
}
if
v
,
ok
:=
_u
.
mutation
.
IdempotencyKeyHash
();
ok
{
if
err
:=
idempotencyrecord
.
IdempotencyKeyHashValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"idempotency_key_hash"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "IdempotencyRecord.idempotency_key_hash": %w`
,
err
)}
}
}
if
v
,
ok
:=
_u
.
mutation
.
RequestFingerprint
();
ok
{
if
err
:=
idempotencyrecord
.
RequestFingerprintValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"request_fingerprint"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "IdempotencyRecord.request_fingerprint": %w`
,
err
)}
}
}
if
v
,
ok
:=
_u
.
mutation
.
Status
();
ok
{
if
err
:=
idempotencyrecord
.
StatusValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"status"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "IdempotencyRecord.status": %w`
,
err
)}
}
}
if
v
,
ok
:=
_u
.
mutation
.
ErrorReason
();
ok
{
if
err
:=
idempotencyrecord
.
ErrorReasonValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"error_reason"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "IdempotencyRecord.error_reason": %w`
,
err
)}
}
}
return
nil
}
func
(
_u
*
IdempotencyRecordUpdateOne
)
sqlSave
(
ctx
context
.
Context
)
(
_node
*
IdempotencyRecord
,
err
error
)
{
if
err
:=
_u
.
check
();
err
!=
nil
{
return
_node
,
err
}
_spec
:=
sqlgraph
.
NewUpdateSpec
(
idempotencyrecord
.
Table
,
idempotencyrecord
.
Columns
,
sqlgraph
.
NewFieldSpec
(
idempotencyrecord
.
FieldID
,
field
.
TypeInt64
))
id
,
ok
:=
_u
.
mutation
.
ID
()
if
!
ok
{
return
nil
,
&
ValidationError
{
Name
:
"id"
,
err
:
errors
.
New
(
`ent: missing "IdempotencyRecord.id" for update`
)}
}
_spec
.
Node
.
ID
.
Value
=
id
if
fields
:=
_u
.
fields
;
len
(
fields
)
>
0
{
_spec
.
Node
.
Columns
=
make
([]
string
,
0
,
len
(
fields
))
_spec
.
Node
.
Columns
=
append
(
_spec
.
Node
.
Columns
,
idempotencyrecord
.
FieldID
)
for
_
,
f
:=
range
fields
{
if
!
idempotencyrecord
.
ValidColumn
(
f
)
{
return
nil
,
&
ValidationError
{
Name
:
f
,
err
:
fmt
.
Errorf
(
"ent: invalid field %q for query"
,
f
)}
}
if
f
!=
idempotencyrecord
.
FieldID
{
_spec
.
Node
.
Columns
=
append
(
_spec
.
Node
.
Columns
,
f
)
}
}
}
if
ps
:=
_u
.
mutation
.
predicates
;
len
(
ps
)
>
0
{
_spec
.
Predicate
=
func
(
selector
*
sql
.
Selector
)
{
for
i
:=
range
ps
{
ps
[
i
](
selector
)
}
}
}
if
value
,
ok
:=
_u
.
mutation
.
UpdatedAt
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldUpdatedAt
,
field
.
TypeTime
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
Scope
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldScope
,
field
.
TypeString
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
IdempotencyKeyHash
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldIdempotencyKeyHash
,
field
.
TypeString
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
RequestFingerprint
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldRequestFingerprint
,
field
.
TypeString
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
Status
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldStatus
,
field
.
TypeString
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
ResponseStatus
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldResponseStatus
,
field
.
TypeInt
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
AddedResponseStatus
();
ok
{
_spec
.
AddField
(
idempotencyrecord
.
FieldResponseStatus
,
field
.
TypeInt
,
value
)
}
if
_u
.
mutation
.
ResponseStatusCleared
()
{
_spec
.
ClearField
(
idempotencyrecord
.
FieldResponseStatus
,
field
.
TypeInt
)
}
if
value
,
ok
:=
_u
.
mutation
.
ResponseBody
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldResponseBody
,
field
.
TypeString
,
value
)
}
if
_u
.
mutation
.
ResponseBodyCleared
()
{
_spec
.
ClearField
(
idempotencyrecord
.
FieldResponseBody
,
field
.
TypeString
)
}
if
value
,
ok
:=
_u
.
mutation
.
ErrorReason
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldErrorReason
,
field
.
TypeString
,
value
)
}
if
_u
.
mutation
.
ErrorReasonCleared
()
{
_spec
.
ClearField
(
idempotencyrecord
.
FieldErrorReason
,
field
.
TypeString
)
}
if
value
,
ok
:=
_u
.
mutation
.
LockedUntil
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldLockedUntil
,
field
.
TypeTime
,
value
)
}
if
_u
.
mutation
.
LockedUntilCleared
()
{
_spec
.
ClearField
(
idempotencyrecord
.
FieldLockedUntil
,
field
.
TypeTime
)
}
if
value
,
ok
:=
_u
.
mutation
.
ExpiresAt
();
ok
{
_spec
.
SetField
(
idempotencyrecord
.
FieldExpiresAt
,
field
.
TypeTime
,
value
)
}
_node
=
&
IdempotencyRecord
{
config
:
_u
.
config
}
_spec
.
Assign
=
_node
.
assignValues
_spec
.
ScanValues
=
_node
.
scanValues
if
err
=
sqlgraph
.
UpdateNode
(
ctx
,
_u
.
driver
,
_spec
);
err
!=
nil
{
if
_
,
ok
:=
err
.
(
*
sqlgraph
.
NotFoundError
);
ok
{
err
=
&
NotFoundError
{
idempotencyrecord
.
Label
}
}
else
if
sqlgraph
.
IsConstraintError
(
err
)
{
err
=
&
ConstraintError
{
msg
:
err
.
Error
(),
wrap
:
err
}
}
return
nil
,
err
}
_u
.
mutation
.
done
=
true
return
_node
,
nil
}
backend/ent/intercept/intercept.go
View file @
bb664d9b
...
@@ -15,6 +15,7 @@ import (
...
@@ -15,6 +15,7 @@ import (
"github.com/Wei-Shaw/sub2api/ent/apikey"
"github.com/Wei-Shaw/sub2api/ent/apikey"
"github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
"github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
"github.com/Wei-Shaw/sub2api/ent/group"
"github.com/Wei-Shaw/sub2api/ent/group"
"github.com/Wei-Shaw/sub2api/ent/idempotencyrecord"
"github.com/Wei-Shaw/sub2api/ent/predicate"
"github.com/Wei-Shaw/sub2api/ent/predicate"
"github.com/Wei-Shaw/sub2api/ent/promocode"
"github.com/Wei-Shaw/sub2api/ent/promocode"
"github.com/Wei-Shaw/sub2api/ent/promocodeusage"
"github.com/Wei-Shaw/sub2api/ent/promocodeusage"
...
@@ -276,6 +277,33 @@ func (f TraverseGroup) Traverse(ctx context.Context, q ent.Query) error {
...
@@ -276,6 +277,33 @@ func (f TraverseGroup) Traverse(ctx context.Context, q ent.Query) error {
return
fmt
.
Errorf
(
"unexpected query type %T. expect *ent.GroupQuery"
,
q
)
return
fmt
.
Errorf
(
"unexpected query type %T. expect *ent.GroupQuery"
,
q
)
}
}
// The IdempotencyRecordFunc type is an adapter to allow the use of ordinary function as a Querier.
type
IdempotencyRecordFunc
func
(
context
.
Context
,
*
ent
.
IdempotencyRecordQuery
)
(
ent
.
Value
,
error
)
// Query calls f(ctx, q).
func
(
f
IdempotencyRecordFunc
)
Query
(
ctx
context
.
Context
,
q
ent
.
Query
)
(
ent
.
Value
,
error
)
{
if
q
,
ok
:=
q
.
(
*
ent
.
IdempotencyRecordQuery
);
ok
{
return
f
(
ctx
,
q
)
}
return
nil
,
fmt
.
Errorf
(
"unexpected query type %T. expect *ent.IdempotencyRecordQuery"
,
q
)
}
// The TraverseIdempotencyRecord type is an adapter to allow the use of ordinary function as Traverser.
type
TraverseIdempotencyRecord
func
(
context
.
Context
,
*
ent
.
IdempotencyRecordQuery
)
error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func
(
f
TraverseIdempotencyRecord
)
Intercept
(
next
ent
.
Querier
)
ent
.
Querier
{
return
next
}
// Traverse calls f(ctx, q).
func
(
f
TraverseIdempotencyRecord
)
Traverse
(
ctx
context
.
Context
,
q
ent
.
Query
)
error
{
if
q
,
ok
:=
q
.
(
*
ent
.
IdempotencyRecordQuery
);
ok
{
return
f
(
ctx
,
q
)
}
return
fmt
.
Errorf
(
"unexpected query type %T. expect *ent.IdempotencyRecordQuery"
,
q
)
}
// The PromoCodeFunc type is an adapter to allow the use of ordinary function as a Querier.
// The PromoCodeFunc type is an adapter to allow the use of ordinary function as a Querier.
type
PromoCodeFunc
func
(
context
.
Context
,
*
ent
.
PromoCodeQuery
)
(
ent
.
Value
,
error
)
type
PromoCodeFunc
func
(
context
.
Context
,
*
ent
.
PromoCodeQuery
)
(
ent
.
Value
,
error
)
...
@@ -644,6 +672,8 @@ func NewQuery(q ent.Query) (Query, error) {
...
@@ -644,6 +672,8 @@ func NewQuery(q ent.Query) (Query, error) {
return
&
query
[
*
ent
.
ErrorPassthroughRuleQuery
,
predicate
.
ErrorPassthroughRule
,
errorpassthroughrule
.
OrderOption
]{
typ
:
ent
.
TypeErrorPassthroughRule
,
tq
:
q
},
nil
return
&
query
[
*
ent
.
ErrorPassthroughRuleQuery
,
predicate
.
ErrorPassthroughRule
,
errorpassthroughrule
.
OrderOption
]{
typ
:
ent
.
TypeErrorPassthroughRule
,
tq
:
q
},
nil
case
*
ent
.
GroupQuery
:
case
*
ent
.
GroupQuery
:
return
&
query
[
*
ent
.
GroupQuery
,
predicate
.
Group
,
group
.
OrderOption
]{
typ
:
ent
.
TypeGroup
,
tq
:
q
},
nil
return
&
query
[
*
ent
.
GroupQuery
,
predicate
.
Group
,
group
.
OrderOption
]{
typ
:
ent
.
TypeGroup
,
tq
:
q
},
nil
case
*
ent
.
IdempotencyRecordQuery
:
return
&
query
[
*
ent
.
IdempotencyRecordQuery
,
predicate
.
IdempotencyRecord
,
idempotencyrecord
.
OrderOption
]{
typ
:
ent
.
TypeIdempotencyRecord
,
tq
:
q
},
nil
case
*
ent
.
PromoCodeQuery
:
case
*
ent
.
PromoCodeQuery
:
return
&
query
[
*
ent
.
PromoCodeQuery
,
predicate
.
PromoCode
,
promocode
.
OrderOption
]{
typ
:
ent
.
TypePromoCode
,
tq
:
q
},
nil
return
&
query
[
*
ent
.
PromoCodeQuery
,
predicate
.
PromoCode
,
promocode
.
OrderOption
]{
typ
:
ent
.
TypePromoCode
,
tq
:
q
},
nil
case
*
ent
.
PromoCodeUsageQuery
:
case
*
ent
.
PromoCodeUsageQuery
:
...
...
backend/ent/migrate/schema.go
View file @
bb664d9b
...
@@ -108,6 +108,8 @@ var (
...
@@ -108,6 +108,8 @@ var (
{
Name
:
"rate_limited_at"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"timestamptz"
}},
{
Name
:
"rate_limited_at"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"timestamptz"
}},
{
Name
:
"rate_limit_reset_at"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"timestamptz"
}},
{
Name
:
"rate_limit_reset_at"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"timestamptz"
}},
{
Name
:
"overload_until"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"timestamptz"
}},
{
Name
:
"overload_until"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"timestamptz"
}},
{
Name
:
"temp_unschedulable_until"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"timestamptz"
}},
{
Name
:
"temp_unschedulable_reason"
,
Type
:
field
.
TypeString
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"text"
}},
{
Name
:
"session_window_start"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"timestamptz"
}},
{
Name
:
"session_window_start"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"timestamptz"
}},
{
Name
:
"session_window_end"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"timestamptz"
}},
{
Name
:
"session_window_end"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"timestamptz"
}},
{
Name
:
"session_window_status"
,
Type
:
field
.
TypeString
,
Nullable
:
true
,
Size
:
20
},
{
Name
:
"session_window_status"
,
Type
:
field
.
TypeString
,
Nullable
:
true
,
Size
:
20
},
...
@@ -121,7 +123,7 @@ var (
...
@@ -121,7 +123,7 @@ var (
ForeignKeys
:
[]
*
schema
.
ForeignKey
{
ForeignKeys
:
[]
*
schema
.
ForeignKey
{
{
{
Symbol
:
"accounts_proxies_proxy"
,
Symbol
:
"accounts_proxies_proxy"
,
Columns
:
[]
*
schema
.
Column
{
AccountsColumns
[
2
5
]},
Columns
:
[]
*
schema
.
Column
{
AccountsColumns
[
2
7
]},
RefColumns
:
[]
*
schema
.
Column
{
ProxiesColumns
[
0
]},
RefColumns
:
[]
*
schema
.
Column
{
ProxiesColumns
[
0
]},
OnDelete
:
schema
.
SetNull
,
OnDelete
:
schema
.
SetNull
,
},
},
...
@@ -145,7 +147,7 @@ var (
...
@@ -145,7 +147,7 @@ var (
{
{
Name
:
"account_proxy_id"
,
Name
:
"account_proxy_id"
,
Unique
:
false
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
AccountsColumns
[
2
5
]},
Columns
:
[]
*
schema
.
Column
{
AccountsColumns
[
2
7
]},
},
},
{
{
Name
:
"account_priority"
,
Name
:
"account_priority"
,
...
@@ -177,6 +179,16 @@ var (
...
@@ -177,6 +179,16 @@ var (
Unique
:
false
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
AccountsColumns
[
21
]},
Columns
:
[]
*
schema
.
Column
{
AccountsColumns
[
21
]},
},
},
{
Name
:
"account_platform_priority"
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
AccountsColumns
[
6
],
AccountsColumns
[
11
]},
},
{
Name
:
"account_priority_status"
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
AccountsColumns
[
11
],
AccountsColumns
[
13
]},
},
{
{
Name
:
"account_deleted_at"
,
Name
:
"account_deleted_at"
,
Unique
:
false
,
Unique
:
false
,
...
@@ -376,6 +388,7 @@ var (
...
@@ -376,6 +388,7 @@ var (
{
Name
:
"sora_image_price_540"
,
Type
:
field
.
TypeFloat64
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"decimal(20,8)"
}},
{
Name
:
"sora_image_price_540"
,
Type
:
field
.
TypeFloat64
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"decimal(20,8)"
}},
{
Name
:
"sora_video_price_per_request"
,
Type
:
field
.
TypeFloat64
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"decimal(20,8)"
}},
{
Name
:
"sora_video_price_per_request"
,
Type
:
field
.
TypeFloat64
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"decimal(20,8)"
}},
{
Name
:
"sora_video_price_per_request_hd"
,
Type
:
field
.
TypeFloat64
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"decimal(20,8)"
}},
{
Name
:
"sora_video_price_per_request_hd"
,
Type
:
field
.
TypeFloat64
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"decimal(20,8)"
}},
{
Name
:
"sora_storage_quota_bytes"
,
Type
:
field
.
TypeInt64
,
Default
:
0
},
{
Name
:
"claude_code_only"
,
Type
:
field
.
TypeBool
,
Default
:
false
},
{
Name
:
"claude_code_only"
,
Type
:
field
.
TypeBool
,
Default
:
false
},
{
Name
:
"fallback_group_id"
,
Type
:
field
.
TypeInt64
,
Nullable
:
true
},
{
Name
:
"fallback_group_id"
,
Type
:
field
.
TypeInt64
,
Nullable
:
true
},
{
Name
:
"fallback_group_id_on_invalid_request"
,
Type
:
field
.
TypeInt64
,
Nullable
:
true
},
{
Name
:
"fallback_group_id_on_invalid_request"
,
Type
:
field
.
TypeInt64
,
Nullable
:
true
},
...
@@ -419,7 +432,45 @@ var (
...
@@ -419,7 +432,45 @@ var (
{
{
Name
:
"group_sort_order"
,
Name
:
"group_sort_order"
,
Unique
:
false
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
GroupsColumns
[
29
]},
Columns
:
[]
*
schema
.
Column
{
GroupsColumns
[
30
]},
},
},
}
// IdempotencyRecordsColumns holds the columns for the "idempotency_records" table.
IdempotencyRecordsColumns
=
[]
*
schema
.
Column
{
{
Name
:
"id"
,
Type
:
field
.
TypeInt64
,
Increment
:
true
},
{
Name
:
"created_at"
,
Type
:
field
.
TypeTime
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"timestamptz"
}},
{
Name
:
"updated_at"
,
Type
:
field
.
TypeTime
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"timestamptz"
}},
{
Name
:
"scope"
,
Type
:
field
.
TypeString
,
Size
:
128
},
{
Name
:
"idempotency_key_hash"
,
Type
:
field
.
TypeString
,
Size
:
64
},
{
Name
:
"request_fingerprint"
,
Type
:
field
.
TypeString
,
Size
:
64
},
{
Name
:
"status"
,
Type
:
field
.
TypeString
,
Size
:
32
},
{
Name
:
"response_status"
,
Type
:
field
.
TypeInt
,
Nullable
:
true
},
{
Name
:
"response_body"
,
Type
:
field
.
TypeString
,
Nullable
:
true
},
{
Name
:
"error_reason"
,
Type
:
field
.
TypeString
,
Nullable
:
true
,
Size
:
128
},
{
Name
:
"locked_until"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
},
{
Name
:
"expires_at"
,
Type
:
field
.
TypeTime
},
}
// IdempotencyRecordsTable holds the schema information for the "idempotency_records" table.
IdempotencyRecordsTable
=
&
schema
.
Table
{
Name
:
"idempotency_records"
,
Columns
:
IdempotencyRecordsColumns
,
PrimaryKey
:
[]
*
schema
.
Column
{
IdempotencyRecordsColumns
[
0
]},
Indexes
:
[]
*
schema
.
Index
{
{
Name
:
"idempotencyrecord_scope_idempotency_key_hash"
,
Unique
:
true
,
Columns
:
[]
*
schema
.
Column
{
IdempotencyRecordsColumns
[
3
],
IdempotencyRecordsColumns
[
4
]},
},
{
Name
:
"idempotencyrecord_expires_at"
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
IdempotencyRecordsColumns
[
11
]},
},
{
Name
:
"idempotencyrecord_status_locked_until"
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
IdempotencyRecordsColumns
[
6
],
IdempotencyRecordsColumns
[
10
]},
},
},
},
},
}
}
...
@@ -771,6 +822,11 @@ var (
...
@@ -771,6 +822,11 @@ var (
Unique
:
false
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
28
],
UsageLogsColumns
[
27
]},
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
28
],
UsageLogsColumns
[
27
]},
},
},
{
Name
:
"usagelog_group_id_created_at"
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
30
],
UsageLogsColumns
[
27
]},
},
},
},
}
}
// UsersColumns holds the columns for the "users" table.
// UsersColumns holds the columns for the "users" table.
...
@@ -790,6 +846,8 @@ var (
...
@@ -790,6 +846,8 @@ var (
{
Name
:
"totp_secret_encrypted"
,
Type
:
field
.
TypeString
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"text"
}},
{
Name
:
"totp_secret_encrypted"
,
Type
:
field
.
TypeString
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"text"
}},
{
Name
:
"totp_enabled"
,
Type
:
field
.
TypeBool
,
Default
:
false
},
{
Name
:
"totp_enabled"
,
Type
:
field
.
TypeBool
,
Default
:
false
},
{
Name
:
"totp_enabled_at"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
},
{
Name
:
"totp_enabled_at"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
},
{
Name
:
"sora_storage_quota_bytes"
,
Type
:
field
.
TypeInt64
,
Default
:
0
},
{
Name
:
"sora_storage_used_bytes"
,
Type
:
field
.
TypeInt64
,
Default
:
0
},
}
}
// UsersTable holds the schema information for the "users" table.
// UsersTable holds the schema information for the "users" table.
UsersTable
=
&
schema
.
Table
{
UsersTable
=
&
schema
.
Table
{
...
@@ -995,6 +1053,11 @@ var (
...
@@ -995,6 +1053,11 @@ var (
Unique
:
false
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
UserSubscriptionsColumns
[
5
]},
Columns
:
[]
*
schema
.
Column
{
UserSubscriptionsColumns
[
5
]},
},
},
{
Name
:
"usersubscription_user_id_status_expires_at"
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
UserSubscriptionsColumns
[
16
],
UserSubscriptionsColumns
[
6
],
UserSubscriptionsColumns
[
5
]},
},
{
{
Name
:
"usersubscription_assigned_by"
,
Name
:
"usersubscription_assigned_by"
,
Unique
:
false
,
Unique
:
false
,
...
@@ -1021,6 +1084,7 @@ var (
...
@@ -1021,6 +1084,7 @@ var (
AnnouncementReadsTable
,
AnnouncementReadsTable
,
ErrorPassthroughRulesTable
,
ErrorPassthroughRulesTable
,
GroupsTable
,
GroupsTable
,
IdempotencyRecordsTable
,
PromoCodesTable
,
PromoCodesTable
,
PromoCodeUsagesTable
,
PromoCodeUsagesTable
,
ProxiesTable
,
ProxiesTable
,
...
@@ -1066,6 +1130,9 @@ func init() {
...
@@ -1066,6 +1130,9 @@ func init() {
GroupsTable
.
Annotation
=
&
entsql
.
Annotation
{
GroupsTable
.
Annotation
=
&
entsql
.
Annotation
{
Table
:
"groups"
,
Table
:
"groups"
,
}
}
IdempotencyRecordsTable
.
Annotation
=
&
entsql
.
Annotation
{
Table
:
"idempotency_records"
,
}
PromoCodesTable
.
Annotation
=
&
entsql
.
Annotation
{
PromoCodesTable
.
Annotation
=
&
entsql
.
Annotation
{
Table
:
"promo_codes"
,
Table
:
"promo_codes"
,
}
}
...
...
backend/ent/mutation.go
View file @
bb664d9b
...
@@ -19,6 +19,7 @@ import (
...
@@ -19,6 +19,7 @@ import (
"github.com/Wei-Shaw/sub2api/ent/apikey"
"github.com/Wei-Shaw/sub2api/ent/apikey"
"github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
"github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
"github.com/Wei-Shaw/sub2api/ent/group"
"github.com/Wei-Shaw/sub2api/ent/group"
"github.com/Wei-Shaw/sub2api/ent/idempotencyrecord"
"github.com/Wei-Shaw/sub2api/ent/predicate"
"github.com/Wei-Shaw/sub2api/ent/predicate"
"github.com/Wei-Shaw/sub2api/ent/promocode"
"github.com/Wei-Shaw/sub2api/ent/promocode"
"github.com/Wei-Shaw/sub2api/ent/promocodeusage"
"github.com/Wei-Shaw/sub2api/ent/promocodeusage"
...
@@ -52,6 +53,7 @@ const (
...
@@ -52,6 +53,7 @@ const (
TypeAnnouncementRead = "AnnouncementRead"
TypeAnnouncementRead = "AnnouncementRead"
TypeErrorPassthroughRule = "ErrorPassthroughRule"
TypeErrorPassthroughRule = "ErrorPassthroughRule"
TypeGroup = "Group"
TypeGroup = "Group"
TypeIdempotencyRecord = "IdempotencyRecord"
TypePromoCode = "PromoCode"
TypePromoCode = "PromoCode"
TypePromoCodeUsage = "PromoCodeUsage"
TypePromoCodeUsage = "PromoCodeUsage"
TypeProxy = "Proxy"
TypeProxy = "Proxy"
...
@@ -1503,48 +1505,50 @@ func (m *APIKeyMutation) ResetEdge(name string) error {
...
@@ -1503,48 +1505,50 @@ func (m *APIKeyMutation) ResetEdge(name string) error {
// AccountMutation represents an operation that mutates the Account nodes in the graph.
// AccountMutation represents an operation that mutates the Account nodes in the graph.
type AccountMutation struct {
type AccountMutation struct {
config
config
op Op
op Op
typ string
typ string
id *int64
id *int64
created_at *time.Time
created_at *time.Time
updated_at *time.Time
updated_at *time.Time
deleted_at *time.Time
deleted_at *time.Time
name *string
name *string
notes *string
notes *string
platform *string
platform *string
_type *string
_type *string
credentials *map[string]interface{}
credentials *map[string]interface{}
extra *map[string]interface{}
extra *map[string]interface{}
concurrency *int
concurrency *int
addconcurrency *int
addconcurrency *int
priority *int
priority *int
addpriority *int
addpriority *int
rate_multiplier *float64
rate_multiplier *float64
addrate_multiplier *float64
addrate_multiplier *float64
status *string
status *string
error_message *string
error_message *string
last_used_at *time.Time
last_used_at *time.Time
expires_at *time.Time
expires_at *time.Time
auto_pause_on_expired *bool
auto_pause_on_expired *bool
schedulable *bool
schedulable *bool
rate_limited_at *time.Time
rate_limited_at *time.Time
rate_limit_reset_at *time.Time
rate_limit_reset_at *time.Time
overload_until *time.Time
overload_until *time.Time
session_window_start *time.Time
temp_unschedulable_until *time.Time
session_window_end *time.Time
temp_unschedulable_reason *string
session_window_status *string
session_window_start *time.Time
clearedFields map[string]struct{}
session_window_end *time.Time
groups map[int64]struct{}
session_window_status *string
removedgroups map[int64]struct{}
clearedFields map[string]struct{}
clearedgroups bool
groups map[int64]struct{}
proxy *int64
removedgroups map[int64]struct{}
clearedproxy bool
clearedgroups bool
usage_logs map[int64]struct{}
proxy *int64
removedusage_logs map[int64]struct{}
clearedproxy bool
clearedusage_logs bool
usage_logs map[int64]struct{}
done bool
removedusage_logs map[int64]struct{}
oldValue func(context.Context) (*Account, error)
clearedusage_logs bool
predicates []predicate.Account
done bool
oldValue func(context.Context) (*Account, error)
predicates []predicate.Account
}
}
var _ ent.Mutation = (*AccountMutation)(nil)
var _ ent.Mutation = (*AccountMutation)(nil)
...
@@ -2614,6 +2618,104 @@ func (m *AccountMutation) ResetOverloadUntil() {
...
@@ -2614,6 +2618,104 @@ func (m *AccountMutation) ResetOverloadUntil() {
delete(m.clearedFields, account.FieldOverloadUntil)
delete(m.clearedFields, account.FieldOverloadUntil)
}
}
// SetTempUnschedulableUntil sets the "temp_unschedulable_until" field.
func (m *AccountMutation) SetTempUnschedulableUntil(t time.Time) {
m.temp_unschedulable_until = &t
}
// TempUnschedulableUntil returns the value of the "temp_unschedulable_until" field in the mutation.
func (m *AccountMutation) TempUnschedulableUntil() (r time.Time, exists bool) {
v := m.temp_unschedulable_until
if v == nil {
return
}
return *v, true
}
// OldTempUnschedulableUntil returns the old "temp_unschedulable_until" field's value of the Account entity.
// If the Account object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *AccountMutation) OldTempUnschedulableUntil(ctx context.Context) (v *time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldTempUnschedulableUntil is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldTempUnschedulableUntil requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTempUnschedulableUntil: %w", err)
}
return oldValue.TempUnschedulableUntil, nil
}
// ClearTempUnschedulableUntil clears the value of the "temp_unschedulable_until" field.
func (m *AccountMutation) ClearTempUnschedulableUntil() {
m.temp_unschedulable_until = nil
m.clearedFields[account.FieldTempUnschedulableUntil] = struct{}{}
}
// TempUnschedulableUntilCleared returns if the "temp_unschedulable_until" field was cleared in this mutation.
func (m *AccountMutation) TempUnschedulableUntilCleared() bool {
_, ok := m.clearedFields[account.FieldTempUnschedulableUntil]
return ok
}
// ResetTempUnschedulableUntil resets all changes to the "temp_unschedulable_until" field.
func (m *AccountMutation) ResetTempUnschedulableUntil() {
m.temp_unschedulable_until = nil
delete(m.clearedFields, account.FieldTempUnschedulableUntil)
}
// SetTempUnschedulableReason sets the "temp_unschedulable_reason" field.
func (m *AccountMutation) SetTempUnschedulableReason(s string) {
m.temp_unschedulable_reason = &s
}
// TempUnschedulableReason returns the value of the "temp_unschedulable_reason" field in the mutation.
func (m *AccountMutation) TempUnschedulableReason() (r string, exists bool) {
v := m.temp_unschedulable_reason
if v == nil {
return
}
return *v, true
}
// OldTempUnschedulableReason returns the old "temp_unschedulable_reason" field's value of the Account entity.
// If the Account object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *AccountMutation) OldTempUnschedulableReason(ctx context.Context) (v *string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldTempUnschedulableReason is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldTempUnschedulableReason requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTempUnschedulableReason: %w", err)
}
return oldValue.TempUnschedulableReason, nil
}
// ClearTempUnschedulableReason clears the value of the "temp_unschedulable_reason" field.
func (m *AccountMutation) ClearTempUnschedulableReason() {
m.temp_unschedulable_reason = nil
m.clearedFields[account.FieldTempUnschedulableReason] = struct{}{}
}
// TempUnschedulableReasonCleared returns if the "temp_unschedulable_reason" field was cleared in this mutation.
func (m *AccountMutation) TempUnschedulableReasonCleared() bool {
_, ok := m.clearedFields[account.FieldTempUnschedulableReason]
return ok
}
// ResetTempUnschedulableReason resets all changes to the "temp_unschedulable_reason" field.
func (m *AccountMutation) ResetTempUnschedulableReason() {
m.temp_unschedulable_reason = nil
delete(m.clearedFields, account.FieldTempUnschedulableReason)
}
// SetSessionWindowStart sets the "session_window_start" field.
// SetSessionWindowStart sets the "session_window_start" field.
func (m *AccountMutation) SetSessionWindowStart(t time.Time) {
func (m *AccountMutation) SetSessionWindowStart(t time.Time) {
m.session_window_start = &t
m.session_window_start = &t
...
@@ -2930,7 +3032,7 @@ func (m *AccountMutation) Type() string {
...
@@ -2930,7 +3032,7 @@ func (m *AccountMutation) Type() string {
// order to get all numeric fields that were incremented/decremented, call
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
// AddedFields().
func (m *AccountMutation) Fields() []string {
func (m *AccountMutation) Fields() []string {
fields := make([]string, 0, 2
5
)
fields := make([]string, 0, 2
7
)
if m.created_at != nil {
if m.created_at != nil {
fields = append(fields, account.FieldCreatedAt)
fields = append(fields, account.FieldCreatedAt)
}
}
...
@@ -2997,6 +3099,12 @@ func (m *AccountMutation) Fields() []string {
...
@@ -2997,6 +3099,12 @@ func (m *AccountMutation) Fields() []string {
if m.overload_until != nil {
if m.overload_until != nil {
fields = append(fields, account.FieldOverloadUntil)
fields = append(fields, account.FieldOverloadUntil)
}
}
if m.temp_unschedulable_until != nil {
fields = append(fields, account.FieldTempUnschedulableUntil)
}
if m.temp_unschedulable_reason != nil {
fields = append(fields, account.FieldTempUnschedulableReason)
}
if m.session_window_start != nil {
if m.session_window_start != nil {
fields = append(fields, account.FieldSessionWindowStart)
fields = append(fields, account.FieldSessionWindowStart)
}
}
...
@@ -3058,6 +3166,10 @@ func (m *AccountMutation) Field(name string) (ent.Value, bool) {
...
@@ -3058,6 +3166,10 @@ func (m *AccountMutation) Field(name string) (ent.Value, bool) {
return m.RateLimitResetAt()
return m.RateLimitResetAt()
case account.FieldOverloadUntil:
case account.FieldOverloadUntil:
return m.OverloadUntil()
return m.OverloadUntil()
case account.FieldTempUnschedulableUntil:
return m.TempUnschedulableUntil()
case account.FieldTempUnschedulableReason:
return m.TempUnschedulableReason()
case account.FieldSessionWindowStart:
case account.FieldSessionWindowStart:
return m.SessionWindowStart()
return m.SessionWindowStart()
case account.FieldSessionWindowEnd:
case account.FieldSessionWindowEnd:
...
@@ -3117,6 +3229,10 @@ func (m *AccountMutation) OldField(ctx context.Context, name string) (ent.Value,
...
@@ -3117,6 +3229,10 @@ func (m *AccountMutation) OldField(ctx context.Context, name string) (ent.Value,
return m.OldRateLimitResetAt(ctx)
return m.OldRateLimitResetAt(ctx)
case account.FieldOverloadUntil:
case account.FieldOverloadUntil:
return m.OldOverloadUntil(ctx)
return m.OldOverloadUntil(ctx)
case account.FieldTempUnschedulableUntil:
return m.OldTempUnschedulableUntil(ctx)
case account.FieldTempUnschedulableReason:
return m.OldTempUnschedulableReason(ctx)
case account.FieldSessionWindowStart:
case account.FieldSessionWindowStart:
return m.OldSessionWindowStart(ctx)
return m.OldSessionWindowStart(ctx)
case account.FieldSessionWindowEnd:
case account.FieldSessionWindowEnd:
...
@@ -3286,6 +3402,20 @@ func (m *AccountMutation) SetField(name string, value ent.Value) error {
...
@@ -3286,6 +3402,20 @@ func (m *AccountMutation) SetField(name string, value ent.Value) error {
}
}
m.SetOverloadUntil(v)
m.SetOverloadUntil(v)
return nil
return nil
case account.FieldTempUnschedulableUntil:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTempUnschedulableUntil(v)
return nil
case account.FieldTempUnschedulableReason:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTempUnschedulableReason(v)
return nil
case account.FieldSessionWindowStart:
case account.FieldSessionWindowStart:
v, ok := value.(time.Time)
v, ok := value.(time.Time)
if !ok {
if !ok {
...
@@ -3403,6 +3533,12 @@ func (m *AccountMutation) ClearedFields() []string {
...
@@ -3403,6 +3533,12 @@ func (m *AccountMutation) ClearedFields() []string {
if m.FieldCleared(account.FieldOverloadUntil) {
if m.FieldCleared(account.FieldOverloadUntil) {
fields = append(fields, account.FieldOverloadUntil)
fields = append(fields, account.FieldOverloadUntil)
}
}
if m.FieldCleared(account.FieldTempUnschedulableUntil) {
fields = append(fields, account.FieldTempUnschedulableUntil)
}
if m.FieldCleared(account.FieldTempUnschedulableReason) {
fields = append(fields, account.FieldTempUnschedulableReason)
}
if m.FieldCleared(account.FieldSessionWindowStart) {
if m.FieldCleared(account.FieldSessionWindowStart) {
fields = append(fields, account.FieldSessionWindowStart)
fields = append(fields, account.FieldSessionWindowStart)
}
}
...
@@ -3453,6 +3589,12 @@ func (m *AccountMutation) ClearField(name string) error {
...
@@ -3453,6 +3589,12 @@ func (m *AccountMutation) ClearField(name string) error {
case account.FieldOverloadUntil:
case account.FieldOverloadUntil:
m.ClearOverloadUntil()
m.ClearOverloadUntil()
return nil
return nil
case account.FieldTempUnschedulableUntil:
m.ClearTempUnschedulableUntil()
return nil
case account.FieldTempUnschedulableReason:
m.ClearTempUnschedulableReason()
return nil
case account.FieldSessionWindowStart:
case account.FieldSessionWindowStart:
m.ClearSessionWindowStart()
m.ClearSessionWindowStart()
return nil
return nil
...
@@ -3536,6 +3678,12 @@ func (m *AccountMutation) ResetField(name string) error {
...
@@ -3536,6 +3678,12 @@ func (m *AccountMutation) ResetField(name string) error {
case account.FieldOverloadUntil:
case account.FieldOverloadUntil:
m.ResetOverloadUntil()
m.ResetOverloadUntil()
return nil
return nil
case account.FieldTempUnschedulableUntil:
m.ResetTempUnschedulableUntil()
return nil
case account.FieldTempUnschedulableReason:
m.ResetTempUnschedulableReason()
return nil
case account.FieldSessionWindowStart:
case account.FieldSessionWindowStart:
m.ResetSessionWindowStart()
m.ResetSessionWindowStart()
return nil
return nil
...
@@ -7186,6 +7334,8 @@ type GroupMutation struct {
...
@@ -7186,6 +7334,8 @@ type GroupMutation struct {
addsora_video_price_per_request *float64
addsora_video_price_per_request *float64
sora_video_price_per_request_hd *float64
sora_video_price_per_request_hd *float64
addsora_video_price_per_request_hd *float64
addsora_video_price_per_request_hd *float64
sora_storage_quota_bytes *int64
addsora_storage_quota_bytes *int64
claude_code_only *bool
claude_code_only *bool
fallback_group_id *int64
fallback_group_id *int64
addfallback_group_id *int64
addfallback_group_id *int64
...
@@ -8482,6 +8632,62 @@ func (m *GroupMutation) ResetSoraVideoPricePerRequestHd() {
...
@@ -8482,6 +8632,62 @@ func (m *GroupMutation) ResetSoraVideoPricePerRequestHd() {
delete(m.clearedFields, group.FieldSoraVideoPricePerRequestHd)
delete(m.clearedFields, group.FieldSoraVideoPricePerRequestHd)
}
}
// SetSoraStorageQuotaBytes sets the "sora_storage_quota_bytes" field.
func (m *GroupMutation) SetSoraStorageQuotaBytes(i int64) {
m.sora_storage_quota_bytes = &i
m.addsora_storage_quota_bytes = nil
}
// SoraStorageQuotaBytes returns the value of the "sora_storage_quota_bytes" field in the mutation.
func (m *GroupMutation) SoraStorageQuotaBytes() (r int64, exists bool) {
v := m.sora_storage_quota_bytes
if v == nil {
return
}
return *v, true
}
// OldSoraStorageQuotaBytes returns the old "sora_storage_quota_bytes" field's value of the Group entity.
// If the Group object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *GroupMutation) OldSoraStorageQuotaBytes(ctx context.Context) (v int64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSoraStorageQuotaBytes is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSoraStorageQuotaBytes requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSoraStorageQuotaBytes: %w", err)
}
return oldValue.SoraStorageQuotaBytes, nil
}
// AddSoraStorageQuotaBytes adds i to the "sora_storage_quota_bytes" field.
func (m *GroupMutation) AddSoraStorageQuotaBytes(i int64) {
if m.addsora_storage_quota_bytes != nil {
*m.addsora_storage_quota_bytes += i
} else {
m.addsora_storage_quota_bytes = &i
}
}
// AddedSoraStorageQuotaBytes returns the value that was added to the "sora_storage_quota_bytes" field in this mutation.
func (m *GroupMutation) AddedSoraStorageQuotaBytes() (r int64, exists bool) {
v := m.addsora_storage_quota_bytes
if v == nil {
return
}
return *v, true
}
// ResetSoraStorageQuotaBytes resets all changes to the "sora_storage_quota_bytes" field.
func (m *GroupMutation) ResetSoraStorageQuotaBytes() {
m.sora_storage_quota_bytes = nil
m.addsora_storage_quota_bytes = nil
}
// SetClaudeCodeOnly sets the "claude_code_only" field.
// SetClaudeCodeOnly sets the "claude_code_only" field.
func (m *GroupMutation) SetClaudeCodeOnly(b bool) {
func (m *GroupMutation) SetClaudeCodeOnly(b bool) {
m.claude_code_only = &b
m.claude_code_only = &b
...
@@ -9244,7 +9450,7 @@ func (m *GroupMutation) Type() string {
...
@@ -9244,7 +9450,7 @@ func (m *GroupMutation) Type() string {
// order to get all numeric fields that were incremented/decremented, call
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
// AddedFields().
func (m *GroupMutation) Fields() []string {
func (m *GroupMutation) Fields() []string {
fields := make([]string, 0,
29
)
fields := make([]string, 0,
30
)
if m.created_at != nil {
if m.created_at != nil {
fields = append(fields, group.FieldCreatedAt)
fields = append(fields, group.FieldCreatedAt)
}
}
...
@@ -9308,6 +9514,9 @@ func (m *GroupMutation) Fields() []string {
...
@@ -9308,6 +9514,9 @@ func (m *GroupMutation) Fields() []string {
if m.sora_video_price_per_request_hd != nil {
if m.sora_video_price_per_request_hd != nil {
fields = append(fields, group.FieldSoraVideoPricePerRequestHd)
fields = append(fields, group.FieldSoraVideoPricePerRequestHd)
}
}
if m.sora_storage_quota_bytes != nil {
fields = append(fields, group.FieldSoraStorageQuotaBytes)
}
if m.claude_code_only != nil {
if m.claude_code_only != nil {
fields = append(fields, group.FieldClaudeCodeOnly)
fields = append(fields, group.FieldClaudeCodeOnly)
}
}
...
@@ -9382,6 +9591,8 @@ func (m *GroupMutation) Field(name string) (ent.Value, bool) {
...
@@ -9382,6 +9591,8 @@ func (m *GroupMutation) Field(name string) (ent.Value, bool) {
return m.SoraVideoPricePerRequest()
return m.SoraVideoPricePerRequest()
case group.FieldSoraVideoPricePerRequestHd:
case group.FieldSoraVideoPricePerRequestHd:
return m.SoraVideoPricePerRequestHd()
return m.SoraVideoPricePerRequestHd()
case group.FieldSoraStorageQuotaBytes:
return m.SoraStorageQuotaBytes()
case group.FieldClaudeCodeOnly:
case group.FieldClaudeCodeOnly:
return m.ClaudeCodeOnly()
return m.ClaudeCodeOnly()
case group.FieldFallbackGroupID:
case group.FieldFallbackGroupID:
...
@@ -9449,6 +9660,8 @@ func (m *GroupMutation) OldField(ctx context.Context, name string) (ent.Value, e
...
@@ -9449,6 +9660,8 @@ func (m *GroupMutation) OldField(ctx context.Context, name string) (ent.Value, e
return m.OldSoraVideoPricePerRequest(ctx)
return m.OldSoraVideoPricePerRequest(ctx)
case group.FieldSoraVideoPricePerRequestHd:
case group.FieldSoraVideoPricePerRequestHd:
return m.OldSoraVideoPricePerRequestHd(ctx)
return m.OldSoraVideoPricePerRequestHd(ctx)
case group.FieldSoraStorageQuotaBytes:
return m.OldSoraStorageQuotaBytes(ctx)
case group.FieldClaudeCodeOnly:
case group.FieldClaudeCodeOnly:
return m.OldClaudeCodeOnly(ctx)
return m.OldClaudeCodeOnly(ctx)
case group.FieldFallbackGroupID:
case group.FieldFallbackGroupID:
...
@@ -9621,6 +9834,13 @@ func (m *GroupMutation) SetField(name string, value ent.Value) error {
...
@@ -9621,6 +9834,13 @@ func (m *GroupMutation) SetField(name string, value ent.Value) error {
}
}
m.SetSoraVideoPricePerRequestHd(v)
m.SetSoraVideoPricePerRequestHd(v)
return nil
return nil
case group.FieldSoraStorageQuotaBytes:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSoraStorageQuotaBytes(v)
return nil
case group.FieldClaudeCodeOnly:
case group.FieldClaudeCodeOnly:
v, ok := value.(bool)
v, ok := value.(bool)
if !ok {
if !ok {
...
@@ -9721,6 +9941,9 @@ func (m *GroupMutation) AddedFields() []string {
...
@@ -9721,6 +9941,9 @@ func (m *GroupMutation) AddedFields() []string {
if m.addsora_video_price_per_request_hd != nil {
if m.addsora_video_price_per_request_hd != nil {
fields = append(fields, group.FieldSoraVideoPricePerRequestHd)
fields = append(fields, group.FieldSoraVideoPricePerRequestHd)
}
}
if m.addsora_storage_quota_bytes != nil {
fields = append(fields, group.FieldSoraStorageQuotaBytes)
}
if m.addfallback_group_id != nil {
if m.addfallback_group_id != nil {
fields = append(fields, group.FieldFallbackGroupID)
fields = append(fields, group.FieldFallbackGroupID)
}
}
...
@@ -9762,6 +9985,8 @@ func (m *GroupMutation) AddedField(name string) (ent.Value, bool) {
...
@@ -9762,6 +9985,8 @@ func (m *GroupMutation) AddedField(name string) (ent.Value, bool) {
return m.AddedSoraVideoPricePerRequest()
return m.AddedSoraVideoPricePerRequest()
case group.FieldSoraVideoPricePerRequestHd:
case group.FieldSoraVideoPricePerRequestHd:
return m.AddedSoraVideoPricePerRequestHd()
return m.AddedSoraVideoPricePerRequestHd()
case group.FieldSoraStorageQuotaBytes:
return m.AddedSoraStorageQuotaBytes()
case group.FieldFallbackGroupID:
case group.FieldFallbackGroupID:
return m.AddedFallbackGroupID()
return m.AddedFallbackGroupID()
case group.FieldFallbackGroupIDOnInvalidRequest:
case group.FieldFallbackGroupIDOnInvalidRequest:
...
@@ -9861,6 +10086,13 @@ func (m *GroupMutation) AddField(name string, value ent.Value) error {
...
@@ -9861,6 +10086,13 @@ func (m *GroupMutation) AddField(name string, value ent.Value) error {
}
}
m.AddSoraVideoPricePerRequestHd(v)
m.AddSoraVideoPricePerRequestHd(v)
return nil
return nil
case group.FieldSoraStorageQuotaBytes:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddSoraStorageQuotaBytes(v)
return nil
case group.FieldFallbackGroupID:
case group.FieldFallbackGroupID:
v, ok := value.(int64)
v, ok := value.(int64)
if !ok {
if !ok {
...
@@ -10065,6 +10297,9 @@ func (m *GroupMutation) ResetField(name string) error {
...
@@ -10065,6 +10297,9 @@ func (m *GroupMutation) ResetField(name string) error {
case group.FieldSoraVideoPricePerRequestHd:
case group.FieldSoraVideoPricePerRequestHd:
m.ResetSoraVideoPricePerRequestHd()
m.ResetSoraVideoPricePerRequestHd()
return nil
return nil
case group.FieldSoraStorageQuotaBytes:
m.ResetSoraStorageQuotaBytes()
return nil
case group.FieldClaudeCodeOnly:
case group.FieldClaudeCodeOnly:
m.ResetClaudeCodeOnly()
m.ResetClaudeCodeOnly()
return nil
return nil
...
@@ -10119,192 +10354,1174 @@ func (m *GroupMutation) AddedEdges() []string {
...
@@ -10119,192 +10354,1174 @@ func (m *GroupMutation) AddedEdges() []string {
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
// name in this mutation.
func (m *GroupMutation) AddedIDs(name string) []ent.Value {
func (m *GroupMutation) AddedIDs(name string) []ent.Value {
switch name {
switch name {
case group.EdgeAPIKeys:
case group.EdgeAPIKeys:
ids := make([]ent.Value, 0, len(m.api_keys))
ids := make([]ent.Value, 0, len(m.api_keys))
for id := range m.api_keys {
for id := range m.api_keys {
ids = append(ids, id)
ids = append(ids, id)
}
}
return ids
return ids
case group.EdgeRedeemCodes:
case group.EdgeRedeemCodes:
ids := make([]ent.Value, 0, len(m.redeem_codes))
ids := make([]ent.Value, 0, len(m.redeem_codes))
for id := range m.redeem_codes {
for id := range m.redeem_codes {
ids = append(ids, id)
ids = append(ids, id)
}
}
return ids
return ids
case group.EdgeSubscriptions:
case group.EdgeSubscriptions:
ids := make([]ent.Value, 0, len(m.subscriptions))
ids := make([]ent.Value, 0, len(m.subscriptions))
for id := range m.subscriptions {
for id := range m.subscriptions {
ids = append(ids, id)
ids = append(ids, id)
}
}
return ids
return ids
case group.EdgeUsageLogs:
case group.EdgeUsageLogs:
ids := make([]ent.Value, 0, len(m.usage_logs))
ids := make([]ent.Value, 0, len(m.usage_logs))
for id := range m.usage_logs {
for id := range m.usage_logs {
ids = append(ids, id)
ids = append(ids, id)
}
}
return ids
return ids
case group.EdgeAccounts:
case group.EdgeAccounts:
ids := make([]ent.Value, 0, len(m.accounts))
ids := make([]ent.Value, 0, len(m.accounts))
for id := range m.accounts {
for id := range m.accounts {
ids = append(ids, id)
ids = append(ids, id)
}
}
return ids
return ids
case group.EdgeAllowedUsers:
case group.EdgeAllowedUsers:
ids := make([]ent.Value, 0, len(m.allowed_users))
ids := make([]ent.Value, 0, len(m.allowed_users))
for id := range m.allowed_users {
for id := range m.allowed_users {
ids = append(ids, id)
ids = append(ids, id)
}
}
return ids
return ids
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *GroupMutation) RemovedEdges() []string {
edges := make([]string, 0, 6)
if m.removedapi_keys != nil {
edges = append(edges, group.EdgeAPIKeys)
}
if m.removedredeem_codes != nil {
edges = append(edges, group.EdgeRedeemCodes)
}
if m.removedsubscriptions != nil {
edges = append(edges, group.EdgeSubscriptions)
}
if m.removedusage_logs != nil {
edges = append(edges, group.EdgeUsageLogs)
}
if m.removedaccounts != nil {
edges = append(edges, group.EdgeAccounts)
}
if m.removedallowed_users != nil {
edges = append(edges, group.EdgeAllowedUsers)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *GroupMutation) RemovedIDs(name string) []ent.Value {
switch name {
case group.EdgeAPIKeys:
ids := make([]ent.Value, 0, len(m.removedapi_keys))
for id := range m.removedapi_keys {
ids = append(ids, id)
}
return ids
case group.EdgeRedeemCodes:
ids := make([]ent.Value, 0, len(m.removedredeem_codes))
for id := range m.removedredeem_codes {
ids = append(ids, id)
}
return ids
case group.EdgeSubscriptions:
ids := make([]ent.Value, 0, len(m.removedsubscriptions))
for id := range m.removedsubscriptions {
ids = append(ids, id)
}
return ids
case group.EdgeUsageLogs:
ids := make([]ent.Value, 0, len(m.removedusage_logs))
for id := range m.removedusage_logs {
ids = append(ids, id)
}
return ids
case group.EdgeAccounts:
ids := make([]ent.Value, 0, len(m.removedaccounts))
for id := range m.removedaccounts {
ids = append(ids, id)
}
return ids
case group.EdgeAllowedUsers:
ids := make([]ent.Value, 0, len(m.removedallowed_users))
for id := range m.removedallowed_users {
ids = append(ids, id)
}
return ids
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *GroupMutation) ClearedEdges() []string {
edges := make([]string, 0, 6)
if m.clearedapi_keys {
edges = append(edges, group.EdgeAPIKeys)
}
if m.clearedredeem_codes {
edges = append(edges, group.EdgeRedeemCodes)
}
if m.clearedsubscriptions {
edges = append(edges, group.EdgeSubscriptions)
}
if m.clearedusage_logs {
edges = append(edges, group.EdgeUsageLogs)
}
if m.clearedaccounts {
edges = append(edges, group.EdgeAccounts)
}
if m.clearedallowed_users {
edges = append(edges, group.EdgeAllowedUsers)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *GroupMutation) EdgeCleared(name string) bool {
switch name {
case group.EdgeAPIKeys:
return m.clearedapi_keys
case group.EdgeRedeemCodes:
return m.clearedredeem_codes
case group.EdgeSubscriptions:
return m.clearedsubscriptions
case group.EdgeUsageLogs:
return m.clearedusage_logs
case group.EdgeAccounts:
return m.clearedaccounts
case group.EdgeAllowedUsers:
return m.clearedallowed_users
}
return false
}
// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *GroupMutation) ClearEdge(name string) error {
switch name {
}
return fmt.Errorf("unknown Group unique edge %s", name)
}
// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *GroupMutation) ResetEdge(name string) error {
switch name {
case group.EdgeAPIKeys:
m.ResetAPIKeys()
return nil
case group.EdgeRedeemCodes:
m.ResetRedeemCodes()
return nil
case group.EdgeSubscriptions:
m.ResetSubscriptions()
return nil
case group.EdgeUsageLogs:
m.ResetUsageLogs()
return nil
case group.EdgeAccounts:
m.ResetAccounts()
return nil
case group.EdgeAllowedUsers:
m.ResetAllowedUsers()
return nil
}
return fmt.Errorf("unknown Group edge %s", name)
}
// IdempotencyRecordMutation represents an operation that mutates the IdempotencyRecord nodes in the graph.
type IdempotencyRecordMutation struct {
config
op Op
typ string
id *int64
created_at *time.Time
updated_at *time.Time
scope *string
idempotency_key_hash *string
request_fingerprint *string
status *string
response_status *int
addresponse_status *int
response_body *string
error_reason *string
locked_until *time.Time
expires_at *time.Time
clearedFields map[string]struct{}
done bool
oldValue func(context.Context) (*IdempotencyRecord, error)
predicates []predicate.IdempotencyRecord
}
var _ ent.Mutation = (*IdempotencyRecordMutation)(nil)
// idempotencyrecordOption allows management of the mutation configuration using functional options.
type idempotencyrecordOption func(*IdempotencyRecordMutation)
// newIdempotencyRecordMutation creates new mutation for the IdempotencyRecord entity.
func newIdempotencyRecordMutation(c config, op Op, opts ...idempotencyrecordOption) *IdempotencyRecordMutation {
m := &IdempotencyRecordMutation{
config: c,
op: op,
typ: TypeIdempotencyRecord,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withIdempotencyRecordID sets the ID field of the mutation.
func withIdempotencyRecordID(id int64) idempotencyrecordOption {
return func(m *IdempotencyRecordMutation) {
var (
err error
once sync.Once
value *IdempotencyRecord
)
m.oldValue = func(ctx context.Context) (*IdempotencyRecord, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().IdempotencyRecord.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withIdempotencyRecord sets the old IdempotencyRecord of the mutation.
func withIdempotencyRecord(node *IdempotencyRecord) idempotencyrecordOption {
return func(m *IdempotencyRecordMutation) {
m.oldValue = func(context.Context) (*IdempotencyRecord, error) {
return node, nil
}
m.id = &node.ID
}
}
// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
func (m IdempotencyRecordMutation) Client() *Client {
client := &Client{config: m.config}
client.init()
return client
}
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
func (m IdempotencyRecordMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("ent: mutation is not running in a transaction")
}
tx := &Tx{config: m.config}
tx.init()
return tx, nil
}
// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *IdempotencyRecordMutation) ID() (id int64, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// IDs queries the database and returns the entity ids that match the mutation's predicate.
// That means, if the mutation is applied within a transaction with an isolation level such
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
// or updated by the mutation.
func (m *IdempotencyRecordMutation) IDs(ctx context.Context) ([]int64, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []int64{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().IdempotencyRecord.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetCreatedAt sets the "created_at" field.
func (m *IdempotencyRecordMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *IdempotencyRecordMutation) CreatedAt() (r time.Time, exists bool) {
v := m.created_at
if v == nil {
return
}
return *v, true
}
// OldCreatedAt returns the old "created_at" field's value of the IdempotencyRecord entity.
// If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *IdempotencyRecordMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldCreatedAt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
}
return oldValue.CreatedAt, nil
}
// ResetCreatedAt resets all changes to the "created_at" field.
func (m *IdempotencyRecordMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *IdempotencyRecordMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *IdempotencyRecordMutation) UpdatedAt() (r time.Time, exists bool) {
v := m.updated_at
if v == nil {
return
}
return *v, true
}
// OldUpdatedAt returns the old "updated_at" field's value of the IdempotencyRecord entity.
// If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *IdempotencyRecordMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
}
return oldValue.UpdatedAt, nil
}
// ResetUpdatedAt resets all changes to the "updated_at" field.
func (m *IdempotencyRecordMutation) ResetUpdatedAt() {
m.updated_at = nil
}
// SetScope sets the "scope" field.
func (m *IdempotencyRecordMutation) SetScope(s string) {
m.scope = &s
}
// Scope returns the value of the "scope" field in the mutation.
func (m *IdempotencyRecordMutation) Scope() (r string, exists bool) {
v := m.scope
if v == nil {
return
}
return *v, true
}
// OldScope returns the old "scope" field's value of the IdempotencyRecord entity.
// If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *IdempotencyRecordMutation) OldScope(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldScope is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldScope requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldScope: %w", err)
}
return oldValue.Scope, nil
}
// ResetScope resets all changes to the "scope" field.
func (m *IdempotencyRecordMutation) ResetScope() {
m.scope = nil
}
// SetIdempotencyKeyHash sets the "idempotency_key_hash" field.
func (m *IdempotencyRecordMutation) SetIdempotencyKeyHash(s string) {
m.idempotency_key_hash = &s
}
// IdempotencyKeyHash returns the value of the "idempotency_key_hash" field in the mutation.
func (m *IdempotencyRecordMutation) IdempotencyKeyHash() (r string, exists bool) {
v := m.idempotency_key_hash
if v == nil {
return
}
return *v, true
}
// OldIdempotencyKeyHash returns the old "idempotency_key_hash" field's value of the IdempotencyRecord entity.
// If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *IdempotencyRecordMutation) OldIdempotencyKeyHash(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldIdempotencyKeyHash is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldIdempotencyKeyHash requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldIdempotencyKeyHash: %w", err)
}
return oldValue.IdempotencyKeyHash, nil
}
// ResetIdempotencyKeyHash resets all changes to the "idempotency_key_hash" field.
func (m *IdempotencyRecordMutation) ResetIdempotencyKeyHash() {
m.idempotency_key_hash = nil
}
// SetRequestFingerprint sets the "request_fingerprint" field.
func (m *IdempotencyRecordMutation) SetRequestFingerprint(s string) {
m.request_fingerprint = &s
}
// RequestFingerprint returns the value of the "request_fingerprint" field in the mutation.
func (m *IdempotencyRecordMutation) RequestFingerprint() (r string, exists bool) {
v := m.request_fingerprint
if v == nil {
return
}
return *v, true
}
// OldRequestFingerprint returns the old "request_fingerprint" field's value of the IdempotencyRecord entity.
// If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *IdempotencyRecordMutation) OldRequestFingerprint(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRequestFingerprint is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRequestFingerprint requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRequestFingerprint: %w", err)
}
return oldValue.RequestFingerprint, nil
}
// ResetRequestFingerprint resets all changes to the "request_fingerprint" field.
func (m *IdempotencyRecordMutation) ResetRequestFingerprint() {
m.request_fingerprint = nil
}
// SetStatus sets the "status" field.
func (m *IdempotencyRecordMutation) SetStatus(s string) {
m.status = &s
}
// Status returns the value of the "status" field in the mutation.
func (m *IdempotencyRecordMutation) Status() (r string, exists bool) {
v := m.status
if v == nil {
return
}
return *v, true
}
// OldStatus returns the old "status" field's value of the IdempotencyRecord entity.
// If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *IdempotencyRecordMutation) OldStatus(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldStatus is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldStatus requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldStatus: %w", err)
}
return oldValue.Status, nil
}
// ResetStatus resets all changes to the "status" field.
func (m *IdempotencyRecordMutation) ResetStatus() {
m.status = nil
}
// SetResponseStatus sets the "response_status" field.
func (m *IdempotencyRecordMutation) SetResponseStatus(i int) {
m.response_status = &i
m.addresponse_status = nil
}
// ResponseStatus returns the value of the "response_status" field in the mutation.
func (m *IdempotencyRecordMutation) ResponseStatus() (r int, exists bool) {
v := m.response_status
if v == nil {
return
}
return *v, true
}
// OldResponseStatus returns the old "response_status" field's value of the IdempotencyRecord entity.
// If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *IdempotencyRecordMutation) OldResponseStatus(ctx context.Context) (v *int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldResponseStatus is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldResponseStatus requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldResponseStatus: %w", err)
}
return oldValue.ResponseStatus, nil
}
// AddResponseStatus adds i to the "response_status" field.
func (m *IdempotencyRecordMutation) AddResponseStatus(i int) {
if m.addresponse_status != nil {
*m.addresponse_status += i
} else {
m.addresponse_status = &i
}
}
// AddedResponseStatus returns the value that was added to the "response_status" field in this mutation.
func (m *IdempotencyRecordMutation) AddedResponseStatus() (r int, exists bool) {
v := m.addresponse_status
if v == nil {
return
}
return *v, true
}
// ClearResponseStatus clears the value of the "response_status" field.
func (m *IdempotencyRecordMutation) ClearResponseStatus() {
m.response_status = nil
m.addresponse_status = nil
m.clearedFields[idempotencyrecord.FieldResponseStatus] = struct{}{}
}
// ResponseStatusCleared returns if the "response_status" field was cleared in this mutation.
func (m *IdempotencyRecordMutation) ResponseStatusCleared() bool {
_, ok := m.clearedFields[idempotencyrecord.FieldResponseStatus]
return ok
}
// ResetResponseStatus resets all changes to the "response_status" field.
func (m *IdempotencyRecordMutation) ResetResponseStatus() {
m.response_status = nil
m.addresponse_status = nil
delete(m.clearedFields, idempotencyrecord.FieldResponseStatus)
}
// SetResponseBody sets the "response_body" field.
func (m *IdempotencyRecordMutation) SetResponseBody(s string) {
m.response_body = &s
}
// ResponseBody returns the value of the "response_body" field in the mutation.
func (m *IdempotencyRecordMutation) ResponseBody() (r string, exists bool) {
v := m.response_body
if v == nil {
return
}
return *v, true
}
// OldResponseBody returns the old "response_body" field's value of the IdempotencyRecord entity.
// If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *IdempotencyRecordMutation) OldResponseBody(ctx context.Context) (v *string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldResponseBody is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldResponseBody requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldResponseBody: %w", err)
}
return oldValue.ResponseBody, nil
}
// ClearResponseBody clears the value of the "response_body" field.
func (m *IdempotencyRecordMutation) ClearResponseBody() {
m.response_body = nil
m.clearedFields[idempotencyrecord.FieldResponseBody] = struct{}{}
}
// ResponseBodyCleared returns if the "response_body" field was cleared in this mutation.
func (m *IdempotencyRecordMutation) ResponseBodyCleared() bool {
_, ok := m.clearedFields[idempotencyrecord.FieldResponseBody]
return ok
}
// ResetResponseBody resets all changes to the "response_body" field.
func (m *IdempotencyRecordMutation) ResetResponseBody() {
m.response_body = nil
delete(m.clearedFields, idempotencyrecord.FieldResponseBody)
}
// SetErrorReason sets the "error_reason" field.
func (m *IdempotencyRecordMutation) SetErrorReason(s string) {
m.error_reason = &s
}
// ErrorReason returns the value of the "error_reason" field in the mutation.
func (m *IdempotencyRecordMutation) ErrorReason() (r string, exists bool) {
v := m.error_reason
if v == nil {
return
}
return *v, true
}
// OldErrorReason returns the old "error_reason" field's value of the IdempotencyRecord entity.
// If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *IdempotencyRecordMutation) OldErrorReason(ctx context.Context) (v *string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldErrorReason is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldErrorReason requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldErrorReason: %w", err)
}
return oldValue.ErrorReason, nil
}
// ClearErrorReason clears the value of the "error_reason" field.
func (m *IdempotencyRecordMutation) ClearErrorReason() {
m.error_reason = nil
m.clearedFields[idempotencyrecord.FieldErrorReason] = struct{}{}
}
// ErrorReasonCleared returns if the "error_reason" field was cleared in this mutation.
func (m *IdempotencyRecordMutation) ErrorReasonCleared() bool {
_, ok := m.clearedFields[idempotencyrecord.FieldErrorReason]
return ok
}
// ResetErrorReason resets all changes to the "error_reason" field.
func (m *IdempotencyRecordMutation) ResetErrorReason() {
m.error_reason = nil
delete(m.clearedFields, idempotencyrecord.FieldErrorReason)
}
// SetLockedUntil sets the "locked_until" field.
func (m *IdempotencyRecordMutation) SetLockedUntil(t time.Time) {
m.locked_until = &t
}
// LockedUntil returns the value of the "locked_until" field in the mutation.
func (m *IdempotencyRecordMutation) LockedUntil() (r time.Time, exists bool) {
v := m.locked_until
if v == nil {
return
}
return *v, true
}
// OldLockedUntil returns the old "locked_until" field's value of the IdempotencyRecord entity.
// If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *IdempotencyRecordMutation) OldLockedUntil(ctx context.Context) (v *time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldLockedUntil is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldLockedUntil requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldLockedUntil: %w", err)
}
return oldValue.LockedUntil, nil
}
// ClearLockedUntil clears the value of the "locked_until" field.
func (m *IdempotencyRecordMutation) ClearLockedUntil() {
m.locked_until = nil
m.clearedFields[idempotencyrecord.FieldLockedUntil] = struct{}{}
}
// LockedUntilCleared returns if the "locked_until" field was cleared in this mutation.
func (m *IdempotencyRecordMutation) LockedUntilCleared() bool {
_, ok := m.clearedFields[idempotencyrecord.FieldLockedUntil]
return ok
}
// ResetLockedUntil resets all changes to the "locked_until" field.
func (m *IdempotencyRecordMutation) ResetLockedUntil() {
m.locked_until = nil
delete(m.clearedFields, idempotencyrecord.FieldLockedUntil)
}
// SetExpiresAt sets the "expires_at" field.
func (m *IdempotencyRecordMutation) SetExpiresAt(t time.Time) {
m.expires_at = &t
}
// ExpiresAt returns the value of the "expires_at" field in the mutation.
func (m *IdempotencyRecordMutation) ExpiresAt() (r time.Time, exists bool) {
v := m.expires_at
if v == nil {
return
}
return *v, true
}
// OldExpiresAt returns the old "expires_at" field's value of the IdempotencyRecord entity.
// If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *IdempotencyRecordMutation) OldExpiresAt(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldExpiresAt is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldExpiresAt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldExpiresAt: %w", err)
}
return oldValue.ExpiresAt, nil
}
// ResetExpiresAt resets all changes to the "expires_at" field.
func (m *IdempotencyRecordMutation) ResetExpiresAt() {
m.expires_at = nil
}
// Where appends a list predicates to the IdempotencyRecordMutation builder.
func (m *IdempotencyRecordMutation) Where(ps ...predicate.IdempotencyRecord) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the IdempotencyRecordMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *IdempotencyRecordMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.IdempotencyRecord, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *IdempotencyRecordMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *IdempotencyRecordMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (IdempotencyRecord).
func (m *IdempotencyRecordMutation) Type() string {
return m.typ
}
// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *IdempotencyRecordMutation) Fields() []string {
fields := make([]string, 0, 11)
if m.created_at != nil {
fields = append(fields, idempotencyrecord.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, idempotencyrecord.FieldUpdatedAt)
}
if m.scope != nil {
fields = append(fields, idempotencyrecord.FieldScope)
}
if m.idempotency_key_hash != nil {
fields = append(fields, idempotencyrecord.FieldIdempotencyKeyHash)
}
if m.request_fingerprint != nil {
fields = append(fields, idempotencyrecord.FieldRequestFingerprint)
}
if m.status != nil {
fields = append(fields, idempotencyrecord.FieldStatus)
}
if m.response_status != nil {
fields = append(fields, idempotencyrecord.FieldResponseStatus)
}
if m.response_body != nil {
fields = append(fields, idempotencyrecord.FieldResponseBody)
}
if m.error_reason != nil {
fields = append(fields, idempotencyrecord.FieldErrorReason)
}
if m.locked_until != nil {
fields = append(fields, idempotencyrecord.FieldLockedUntil)
}
if m.expires_at != nil {
fields = append(fields, idempotencyrecord.FieldExpiresAt)
}
return fields
}
// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *IdempotencyRecordMutation) Field(name string) (ent.Value, bool) {
switch name {
case idempotencyrecord.FieldCreatedAt:
return m.CreatedAt()
case idempotencyrecord.FieldUpdatedAt:
return m.UpdatedAt()
case idempotencyrecord.FieldScope:
return m.Scope()
case idempotencyrecord.FieldIdempotencyKeyHash:
return m.IdempotencyKeyHash()
case idempotencyrecord.FieldRequestFingerprint:
return m.RequestFingerprint()
case idempotencyrecord.FieldStatus:
return m.Status()
case idempotencyrecord.FieldResponseStatus:
return m.ResponseStatus()
case idempotencyrecord.FieldResponseBody:
return m.ResponseBody()
case idempotencyrecord.FieldErrorReason:
return m.ErrorReason()
case idempotencyrecord.FieldLockedUntil:
return m.LockedUntil()
case idempotencyrecord.FieldExpiresAt:
return m.ExpiresAt()
}
return nil, false
}
// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *IdempotencyRecordMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case idempotencyrecord.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case idempotencyrecord.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
case idempotencyrecord.FieldScope:
return m.OldScope(ctx)
case idempotencyrecord.FieldIdempotencyKeyHash:
return m.OldIdempotencyKeyHash(ctx)
case idempotencyrecord.FieldRequestFingerprint:
return m.OldRequestFingerprint(ctx)
case idempotencyrecord.FieldStatus:
return m.OldStatus(ctx)
case idempotencyrecord.FieldResponseStatus:
return m.OldResponseStatus(ctx)
case idempotencyrecord.FieldResponseBody:
return m.OldResponseBody(ctx)
case idempotencyrecord.FieldErrorReason:
return m.OldErrorReason(ctx)
case idempotencyrecord.FieldLockedUntil:
return m.OldLockedUntil(ctx)
case idempotencyrecord.FieldExpiresAt:
return m.OldExpiresAt(ctx)
}
return nil, fmt.Errorf("unknown IdempotencyRecord field %s", name)
}
// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *IdempotencyRecordMutation) SetField(name string, value ent.Value) error {
switch name {
case idempotencyrecord.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
case idempotencyrecord.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
case idempotencyrecord.FieldScope:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetScope(v)
return nil
case idempotencyrecord.FieldIdempotencyKeyHash:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetIdempotencyKeyHash(v)
return nil
case idempotencyrecord.FieldRequestFingerprint:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRequestFingerprint(v)
return nil
case idempotencyrecord.FieldStatus:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetStatus(v)
return nil
case idempotencyrecord.FieldResponseStatus:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetResponseStatus(v)
return nil
case idempotencyrecord.FieldResponseBody:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetResponseBody(v)
return nil
case idempotencyrecord.FieldErrorReason:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetErrorReason(v)
return nil
case idempotencyrecord.FieldLockedUntil:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetLockedUntil(v)
return nil
case idempotencyrecord.FieldExpiresAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetExpiresAt(v)
return nil
}
return fmt.Errorf("unknown IdempotencyRecord field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *IdempotencyRecordMutation) AddedFields() []string {
var fields []string
if m.addresponse_status != nil {
fields = append(fields, idempotencyrecord.FieldResponseStatus)
}
return fields
}
// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
func (m *IdempotencyRecordMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case idempotencyrecord.FieldResponseStatus:
return m.AddedResponseStatus()
}
return nil, false
}
// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *IdempotencyRecordMutation) AddField(name string, value ent.Value) error {
switch name {
case idempotencyrecord.FieldResponseStatus:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddResponseStatus(v)
return nil
}
return fmt.Errorf("unknown IdempotencyRecord numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *IdempotencyRecordMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(idempotencyrecord.FieldResponseStatus) {
fields = append(fields, idempotencyrecord.FieldResponseStatus)
}
if m.FieldCleared(idempotencyrecord.FieldResponseBody) {
fields = append(fields, idempotencyrecord.FieldResponseBody)
}
if m.FieldCleared(idempotencyrecord.FieldErrorReason) {
fields = append(fields, idempotencyrecord.FieldErrorReason)
}
if m.FieldCleared(idempotencyrecord.FieldLockedUntil) {
fields = append(fields, idempotencyrecord.FieldLockedUntil)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *IdempotencyRecordMutation) FieldCleared(name string) bool {
_, ok := m.clearedFields[name]
return ok
}
// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
func (m *IdempotencyRecordMutation) ClearField(name string) error {
switch name {
case idempotencyrecord.FieldResponseStatus:
m.ClearResponseStatus()
return nil
case idempotencyrecord.FieldResponseBody:
m.ClearResponseBody()
return nil
case idempotencyrecord.FieldErrorReason:
m.ClearErrorReason()
return nil
case idempotencyrecord.FieldLockedUntil:
m.ClearLockedUntil()
return nil
}
return fmt.Errorf("unknown IdempotencyRecord nullable field %s", name)
}
// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
func (m *IdempotencyRecordMutation) ResetField(name string) error {
switch name {
case idempotencyrecord.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case idempotencyrecord.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
case idempotencyrecord.FieldScope:
m.ResetScope()
return nil
case idempotencyrecord.FieldIdempotencyKeyHash:
m.ResetIdempotencyKeyHash()
return nil
case idempotencyrecord.FieldRequestFingerprint:
m.ResetRequestFingerprint()
return nil
case idempotencyrecord.FieldStatus:
m.ResetStatus()
return nil
case idempotencyrecord.FieldResponseStatus:
m.ResetResponseStatus()
return nil
case idempotencyrecord.FieldResponseBody:
m.ResetResponseBody()
return nil
case idempotencyrecord.FieldErrorReason:
m.ResetErrorReason()
return nil
case idempotencyrecord.FieldLockedUntil:
m.ResetLockedUntil()
return nil
case idempotencyrecord.FieldExpiresAt:
m.ResetExpiresAt()
return nil
}
return fmt.Errorf("unknown IdempotencyRecord field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *IdempotencyRecordMutation) AddedEdges() []string {
edges := make([]string, 0, 0)
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *IdempotencyRecordMutation) AddedIDs(name string) []ent.Value {
return nil
return nil
}
}
// RemovedEdges returns all edge names that were removed in this mutation.
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *GroupMutation) RemovedEdges() []string {
func (m *IdempotencyRecordMutation) RemovedEdges() []string {
edges := make([]string, 0, 6)
edges := make([]string, 0, 0)
if m.removedapi_keys != nil {
edges = append(edges, group.EdgeAPIKeys)
}
if m.removedredeem_codes != nil {
edges = append(edges, group.EdgeRedeemCodes)
}
if m.removedsubscriptions != nil {
edges = append(edges, group.EdgeSubscriptions)
}
if m.removedusage_logs != nil {
edges = append(edges, group.EdgeUsageLogs)
}
if m.removedaccounts != nil {
edges = append(edges, group.EdgeAccounts)
}
if m.removedallowed_users != nil {
edges = append(edges, group.EdgeAllowedUsers)
}
return edges
return edges
}
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
// the given name in this mutation.
func (m *GroupMutation) RemovedIDs(name string) []ent.Value {
func (m *IdempotencyRecordMutation) RemovedIDs(name string) []ent.Value {
switch name {
case group.EdgeAPIKeys:
ids := make([]ent.Value, 0, len(m.removedapi_keys))
for id := range m.removedapi_keys {
ids = append(ids, id)
}
return ids
case group.EdgeRedeemCodes:
ids := make([]ent.Value, 0, len(m.removedredeem_codes))
for id := range m.removedredeem_codes {
ids = append(ids, id)
}
return ids
case group.EdgeSubscriptions:
ids := make([]ent.Value, 0, len(m.removedsubscriptions))
for id := range m.removedsubscriptions {
ids = append(ids, id)
}
return ids
case group.EdgeUsageLogs:
ids := make([]ent.Value, 0, len(m.removedusage_logs))
for id := range m.removedusage_logs {
ids = append(ids, id)
}
return ids
case group.EdgeAccounts:
ids := make([]ent.Value, 0, len(m.removedaccounts))
for id := range m.removedaccounts {
ids = append(ids, id)
}
return ids
case group.EdgeAllowedUsers:
ids := make([]ent.Value, 0, len(m.removedallowed_users))
for id := range m.removedallowed_users {
ids = append(ids, id)
}
return ids
}
return nil
return nil
}
}
// ClearedEdges returns all edge names that were cleared in this mutation.
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *GroupMutation) ClearedEdges() []string {
func (m *IdempotencyRecordMutation) ClearedEdges() []string {
edges := make([]string, 0, 6)
edges := make([]string, 0, 0)
if m.clearedapi_keys {
edges = append(edges, group.EdgeAPIKeys)
}
if m.clearedredeem_codes {
edges = append(edges, group.EdgeRedeemCodes)
}
if m.clearedsubscriptions {
edges = append(edges, group.EdgeSubscriptions)
}
if m.clearedusage_logs {
edges = append(edges, group.EdgeUsageLogs)
}
if m.clearedaccounts {
edges = append(edges, group.EdgeAccounts)
}
if m.clearedallowed_users {
edges = append(edges, group.EdgeAllowedUsers)
}
return edges
return edges
}
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
// was cleared in this mutation.
func (m *GroupMutation) EdgeCleared(name string) bool {
func (m *IdempotencyRecordMutation) EdgeCleared(name string) bool {
switch name {
case group.EdgeAPIKeys:
return m.clearedapi_keys
case group.EdgeRedeemCodes:
return m.clearedredeem_codes
case group.EdgeSubscriptions:
return m.clearedsubscriptions
case group.EdgeUsageLogs:
return m.clearedusage_logs
case group.EdgeAccounts:
return m.clearedaccounts
case group.EdgeAllowedUsers:
return m.clearedallowed_users
}
return false
return false
}
}
// ClearEdge clears the value of the edge with the given name. It returns an error
// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
// if that edge is not defined in the schema.
func (m *GroupMutation) ClearEdge(name string) error {
func (m *IdempotencyRecordMutation) ClearEdge(name string) error {
switch name {
return fmt.Errorf("unknown IdempotencyRecord unique edge %s", name)
}
return fmt.Errorf("unknown Group unique edge %s", name)
}
}
// ResetEdge resets all changes to the edge with the given name in this mutation.
// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
// It returns an error if the edge is not defined in the schema.
func (m *GroupMutation) ResetEdge(name string) error {
func (m *IdempotencyRecordMutation) ResetEdge(name string) error {
switch name {
return fmt.Errorf("unknown IdempotencyRecord edge %s", name)
case group.EdgeAPIKeys:
m.ResetAPIKeys()
return nil
case group.EdgeRedeemCodes:
m.ResetRedeemCodes()
return nil
case group.EdgeSubscriptions:
m.ResetSubscriptions()
return nil
case group.EdgeUsageLogs:
m.ResetUsageLogs()
return nil
case group.EdgeAccounts:
m.ResetAccounts()
return nil
case group.EdgeAllowedUsers:
m.ResetAllowedUsers()
return nil
}
return fmt.Errorf("unknown Group edge %s", name)
}
}
// PromoCodeMutation represents an operation that mutates the PromoCode nodes in the graph.
// PromoCodeMutation represents an operation that mutates the PromoCode nodes in the graph.
...
@@ -19038,6 +20255,10 @@ type UserMutation struct {
...
@@ -19038,6 +20255,10 @@ type UserMutation struct {
totp_secret_encrypted *string
totp_secret_encrypted *string
totp_enabled *bool
totp_enabled *bool
totp_enabled_at *time.Time
totp_enabled_at *time.Time
sora_storage_quota_bytes *int64
addsora_storage_quota_bytes *int64
sora_storage_used_bytes *int64
addsora_storage_used_bytes *int64
clearedFields map[string]struct{}
clearedFields map[string]struct{}
api_keys map[int64]struct{}
api_keys map[int64]struct{}
removedapi_keys map[int64]struct{}
removedapi_keys map[int64]struct{}
...
@@ -19752,6 +20973,118 @@ func (m *UserMutation) ResetTotpEnabledAt() {
...
@@ -19752,6 +20973,118 @@ func (m *UserMutation) ResetTotpEnabledAt() {
delete(m.clearedFields, user.FieldTotpEnabledAt)
delete(m.clearedFields, user.FieldTotpEnabledAt)
}
}
// SetSoraStorageQuotaBytes sets the "sora_storage_quota_bytes" field.
func (m *UserMutation) SetSoraStorageQuotaBytes(i int64) {
m.sora_storage_quota_bytes = &i
m.addsora_storage_quota_bytes = nil
}
// SoraStorageQuotaBytes returns the value of the "sora_storage_quota_bytes" field in the mutation.
func (m *UserMutation) SoraStorageQuotaBytes() (r int64, exists bool) {
v := m.sora_storage_quota_bytes
if v == nil {
return
}
return *v, true
}
// OldSoraStorageQuotaBytes returns the old "sora_storage_quota_bytes" field's value of the User entity.
// If the User object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserMutation) OldSoraStorageQuotaBytes(ctx context.Context) (v int64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSoraStorageQuotaBytes is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSoraStorageQuotaBytes requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSoraStorageQuotaBytes: %w", err)
}
return oldValue.SoraStorageQuotaBytes, nil
}
// AddSoraStorageQuotaBytes adds i to the "sora_storage_quota_bytes" field.
func (m *UserMutation) AddSoraStorageQuotaBytes(i int64) {
if m.addsora_storage_quota_bytes != nil {
*m.addsora_storage_quota_bytes += i
} else {
m.addsora_storage_quota_bytes = &i
}
}
// AddedSoraStorageQuotaBytes returns the value that was added to the "sora_storage_quota_bytes" field in this mutation.
func (m *UserMutation) AddedSoraStorageQuotaBytes() (r int64, exists bool) {
v := m.addsora_storage_quota_bytes
if v == nil {
return
}
return *v, true
}
// ResetSoraStorageQuotaBytes resets all changes to the "sora_storage_quota_bytes" field.
func (m *UserMutation) ResetSoraStorageQuotaBytes() {
m.sora_storage_quota_bytes = nil
m.addsora_storage_quota_bytes = nil
}
// SetSoraStorageUsedBytes sets the "sora_storage_used_bytes" field.
func (m *UserMutation) SetSoraStorageUsedBytes(i int64) {
m.sora_storage_used_bytes = &i
m.addsora_storage_used_bytes = nil
}
// SoraStorageUsedBytes returns the value of the "sora_storage_used_bytes" field in the mutation.
func (m *UserMutation) SoraStorageUsedBytes() (r int64, exists bool) {
v := m.sora_storage_used_bytes
if v == nil {
return
}
return *v, true
}
// OldSoraStorageUsedBytes returns the old "sora_storage_used_bytes" field's value of the User entity.
// If the User object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserMutation) OldSoraStorageUsedBytes(ctx context.Context) (v int64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSoraStorageUsedBytes is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSoraStorageUsedBytes requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSoraStorageUsedBytes: %w", err)
}
return oldValue.SoraStorageUsedBytes, nil
}
// AddSoraStorageUsedBytes adds i to the "sora_storage_used_bytes" field.
func (m *UserMutation) AddSoraStorageUsedBytes(i int64) {
if m.addsora_storage_used_bytes != nil {
*m.addsora_storage_used_bytes += i
} else {
m.addsora_storage_used_bytes = &i
}
}
// AddedSoraStorageUsedBytes returns the value that was added to the "sora_storage_used_bytes" field in this mutation.
func (m *UserMutation) AddedSoraStorageUsedBytes() (r int64, exists bool) {
v := m.addsora_storage_used_bytes
if v == nil {
return
}
return *v, true
}
// ResetSoraStorageUsedBytes resets all changes to the "sora_storage_used_bytes" field.
func (m *UserMutation) ResetSoraStorageUsedBytes() {
m.sora_storage_used_bytes = nil
m.addsora_storage_used_bytes = nil
}
// 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 (m *UserMutation) AddAPIKeyIDs(ids ...int64) {
func (m *UserMutation) AddAPIKeyIDs(ids ...int64) {
if m.api_keys == nil {
if m.api_keys == nil {
...
@@ -20272,7 +21605,7 @@ func (m *UserMutation) Type() string {
...
@@ -20272,7 +21605,7 @@ func (m *UserMutation) Type() string {
// order to get all numeric fields that were incremented/decremented, call
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
// AddedFields().
func (m *UserMutation) Fields() []string {
func (m *UserMutation) Fields() []string {
fields := make([]string, 0, 1
4
)
fields := make([]string, 0, 1
6
)
if m.created_at != nil {
if m.created_at != nil {
fields = append(fields, user.FieldCreatedAt)
fields = append(fields, user.FieldCreatedAt)
}
}
...
@@ -20315,6 +21648,12 @@ func (m *UserMutation) Fields() []string {
...
@@ -20315,6 +21648,12 @@ func (m *UserMutation) Fields() []string {
if m.totp_enabled_at != nil {
if m.totp_enabled_at != nil {
fields = append(fields, user.FieldTotpEnabledAt)
fields = append(fields, user.FieldTotpEnabledAt)
}
}
if m.sora_storage_quota_bytes != nil {
fields = append(fields, user.FieldSoraStorageQuotaBytes)
}
if m.sora_storage_used_bytes != nil {
fields = append(fields, user.FieldSoraStorageUsedBytes)
}
return fields
return fields
}
}
...
@@ -20351,6 +21690,10 @@ func (m *UserMutation) Field(name string) (ent.Value, bool) {
...
@@ -20351,6 +21690,10 @@ func (m *UserMutation) Field(name string) (ent.Value, bool) {
return m.TotpEnabled()
return m.TotpEnabled()
case user.FieldTotpEnabledAt:
case user.FieldTotpEnabledAt:
return m.TotpEnabledAt()
return m.TotpEnabledAt()
case user.FieldSoraStorageQuotaBytes:
return m.SoraStorageQuotaBytes()
case user.FieldSoraStorageUsedBytes:
return m.SoraStorageUsedBytes()
}
}
return nil, false
return nil, false
}
}
...
@@ -20388,6 +21731,10 @@ func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, er
...
@@ -20388,6 +21731,10 @@ func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, er
return m.OldTotpEnabled(ctx)
return m.OldTotpEnabled(ctx)
case user.FieldTotpEnabledAt:
case user.FieldTotpEnabledAt:
return m.OldTotpEnabledAt(ctx)
return m.OldTotpEnabledAt(ctx)
case user.FieldSoraStorageQuotaBytes:
return m.OldSoraStorageQuotaBytes(ctx)
case user.FieldSoraStorageUsedBytes:
return m.OldSoraStorageUsedBytes(ctx)
}
}
return nil, fmt.Errorf("unknown User field %s", name)
return nil, fmt.Errorf("unknown User field %s", name)
}
}
...
@@ -20495,6 +21842,20 @@ func (m *UserMutation) SetField(name string, value ent.Value) error {
...
@@ -20495,6 +21842,20 @@ func (m *UserMutation) SetField(name string, value ent.Value) error {
}
}
m.SetTotpEnabledAt(v)
m.SetTotpEnabledAt(v)
return nil
return nil
case user.FieldSoraStorageQuotaBytes:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSoraStorageQuotaBytes(v)
return nil
case user.FieldSoraStorageUsedBytes:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSoraStorageUsedBytes(v)
return nil
}
}
return fmt.Errorf("unknown User field %s", name)
return fmt.Errorf("unknown User field %s", name)
}
}
...
@@ -20509,6 +21870,12 @@ func (m *UserMutation) AddedFields() []string {
...
@@ -20509,6 +21870,12 @@ func (m *UserMutation) AddedFields() []string {
if m.addconcurrency != nil {
if m.addconcurrency != nil {
fields = append(fields, user.FieldConcurrency)
fields = append(fields, user.FieldConcurrency)
}
}
if m.addsora_storage_quota_bytes != nil {
fields = append(fields, user.FieldSoraStorageQuotaBytes)
}
if m.addsora_storage_used_bytes != nil {
fields = append(fields, user.FieldSoraStorageUsedBytes)
}
return fields
return fields
}
}
...
@@ -20521,6 +21888,10 @@ func (m *UserMutation) AddedField(name string) (ent.Value, bool) {
...
@@ -20521,6 +21888,10 @@ func (m *UserMutation) AddedField(name string) (ent.Value, bool) {
return m.AddedBalance()
return m.AddedBalance()
case user.FieldConcurrency:
case user.FieldConcurrency:
return m.AddedConcurrency()
return m.AddedConcurrency()
case user.FieldSoraStorageQuotaBytes:
return m.AddedSoraStorageQuotaBytes()
case user.FieldSoraStorageUsedBytes:
return m.AddedSoraStorageUsedBytes()
}
}
return nil, false
return nil, false
}
}
...
@@ -20544,6 +21915,20 @@ func (m *UserMutation) AddField(name string, value ent.Value) error {
...
@@ -20544,6 +21915,20 @@ func (m *UserMutation) AddField(name string, value ent.Value) error {
}
}
m.AddConcurrency(v)
m.AddConcurrency(v)
return nil
return nil
case user.FieldSoraStorageQuotaBytes:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddSoraStorageQuotaBytes(v)
return nil
case user.FieldSoraStorageUsedBytes:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddSoraStorageUsedBytes(v)
return nil
}
}
return fmt.Errorf("unknown User numeric field %s", name)
return fmt.Errorf("unknown User numeric field %s", name)
}
}
...
@@ -20634,6 +22019,12 @@ func (m *UserMutation) ResetField(name string) error {
...
@@ -20634,6 +22019,12 @@ func (m *UserMutation) ResetField(name string) error {
case user.FieldTotpEnabledAt:
case user.FieldTotpEnabledAt:
m.ResetTotpEnabledAt()
m.ResetTotpEnabledAt()
return nil
return nil
case user.FieldSoraStorageQuotaBytes:
m.ResetSoraStorageQuotaBytes()
return nil
case user.FieldSoraStorageUsedBytes:
m.ResetSoraStorageUsedBytes()
return nil
}
}
return fmt.Errorf("unknown User field %s", name)
return fmt.Errorf("unknown User field %s", name)
}
}
...
...
backend/ent/predicate/predicate.go
View file @
bb664d9b
...
@@ -27,6 +27,9 @@ type ErrorPassthroughRule func(*sql.Selector)
...
@@ -27,6 +27,9 @@ type ErrorPassthroughRule func(*sql.Selector)
// Group is the predicate function for group builders.
// Group is the predicate function for group builders.
type
Group
func
(
*
sql
.
Selector
)
type
Group
func
(
*
sql
.
Selector
)
// IdempotencyRecord is the predicate function for idempotencyrecord builders.
type
IdempotencyRecord
func
(
*
sql
.
Selector
)
// PromoCode is the predicate function for promocode builders.
// PromoCode is the predicate function for promocode builders.
type
PromoCode
func
(
*
sql
.
Selector
)
type
PromoCode
func
(
*
sql
.
Selector
)
...
...
backend/ent/runtime/runtime.go
View file @
bb664d9b
...
@@ -12,6 +12,7 @@ import (
...
@@ -12,6 +12,7 @@ import (
"github.com/Wei-Shaw/sub2api/ent/apikey"
"github.com/Wei-Shaw/sub2api/ent/apikey"
"github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
"github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
"github.com/Wei-Shaw/sub2api/ent/group"
"github.com/Wei-Shaw/sub2api/ent/group"
"github.com/Wei-Shaw/sub2api/ent/idempotencyrecord"
"github.com/Wei-Shaw/sub2api/ent/promocode"
"github.com/Wei-Shaw/sub2api/ent/promocode"
"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"
...
@@ -209,7 +210,7 @@ func init() {
...
@@ -209,7 +210,7 @@ func init() {
// account.DefaultSchedulable holds the default value on creation for the schedulable field.
// account.DefaultSchedulable holds the default value on creation for the schedulable field.
account
.
DefaultSchedulable
=
accountDescSchedulable
.
Default
.
(
bool
)
account
.
DefaultSchedulable
=
accountDescSchedulable
.
Default
.
(
bool
)
// accountDescSessionWindowStatus is the schema descriptor for session_window_status field.
// accountDescSessionWindowStatus is the schema descriptor for session_window_status field.
accountDescSessionWindowStatus
:=
accountFields
[
2
1
]
.
Descriptor
()
accountDescSessionWindowStatus
:=
accountFields
[
2
3
]
.
Descriptor
()
// account.SessionWindowStatusValidator is a validator for the "session_window_status" field. It is called by the builders before save.
// account.SessionWindowStatusValidator is a validator for the "session_window_status" field. It is called by the builders before save.
account
.
SessionWindowStatusValidator
=
accountDescSessionWindowStatus
.
Validators
[
0
]
.
(
func
(
string
)
error
)
account
.
SessionWindowStatusValidator
=
accountDescSessionWindowStatus
.
Validators
[
0
]
.
(
func
(
string
)
error
)
accountgroupFields
:=
schema
.
AccountGroup
{}
.
Fields
()
accountgroupFields
:=
schema
.
AccountGroup
{}
.
Fields
()
...
@@ -398,26 +399,65 @@ func init() {
...
@@ -398,26 +399,65 @@ func init() {
groupDescDefaultValidityDays
:=
groupFields
[
10
]
.
Descriptor
()
groupDescDefaultValidityDays
:=
groupFields
[
10
]
.
Descriptor
()
// group.DefaultDefaultValidityDays holds the default value on creation for the default_validity_days field.
// group.DefaultDefaultValidityDays holds the default value on creation for the default_validity_days field.
group
.
DefaultDefaultValidityDays
=
groupDescDefaultValidityDays
.
Default
.
(
int
)
group
.
DefaultDefaultValidityDays
=
groupDescDefaultValidityDays
.
Default
.
(
int
)
// groupDescSoraStorageQuotaBytes is the schema descriptor for sora_storage_quota_bytes field.
groupDescSoraStorageQuotaBytes
:=
groupFields
[
18
]
.
Descriptor
()
// group.DefaultSoraStorageQuotaBytes holds the default value on creation for the sora_storage_quota_bytes field.
group
.
DefaultSoraStorageQuotaBytes
=
groupDescSoraStorageQuotaBytes
.
Default
.
(
int64
)
// groupDescClaudeCodeOnly is the schema descriptor for claude_code_only field.
// groupDescClaudeCodeOnly is the schema descriptor for claude_code_only field.
groupDescClaudeCodeOnly
:=
groupFields
[
1
8
]
.
Descriptor
()
groupDescClaudeCodeOnly
:=
groupFields
[
1
9
]
.
Descriptor
()
// group.DefaultClaudeCodeOnly holds the default value on creation for the claude_code_only field.
// group.DefaultClaudeCodeOnly holds the default value on creation for the claude_code_only field.
group
.
DefaultClaudeCodeOnly
=
groupDescClaudeCodeOnly
.
Default
.
(
bool
)
group
.
DefaultClaudeCodeOnly
=
groupDescClaudeCodeOnly
.
Default
.
(
bool
)
// groupDescModelRoutingEnabled is the schema descriptor for model_routing_enabled field.
// groupDescModelRoutingEnabled is the schema descriptor for model_routing_enabled field.
groupDescModelRoutingEnabled
:=
groupFields
[
2
2
]
.
Descriptor
()
groupDescModelRoutingEnabled
:=
groupFields
[
2
3
]
.
Descriptor
()
// group.DefaultModelRoutingEnabled holds the default value on creation for the model_routing_enabled field.
// group.DefaultModelRoutingEnabled holds the default value on creation for the model_routing_enabled field.
group
.
DefaultModelRoutingEnabled
=
groupDescModelRoutingEnabled
.
Default
.
(
bool
)
group
.
DefaultModelRoutingEnabled
=
groupDescModelRoutingEnabled
.
Default
.
(
bool
)
// groupDescMcpXMLInject is the schema descriptor for mcp_xml_inject field.
// groupDescMcpXMLInject is the schema descriptor for mcp_xml_inject field.
groupDescMcpXMLInject
:=
groupFields
[
2
3
]
.
Descriptor
()
groupDescMcpXMLInject
:=
groupFields
[
2
4
]
.
Descriptor
()
// group.DefaultMcpXMLInject holds the default value on creation for the mcp_xml_inject field.
// group.DefaultMcpXMLInject holds the default value on creation for the mcp_xml_inject field.
group
.
DefaultMcpXMLInject
=
groupDescMcpXMLInject
.
Default
.
(
bool
)
group
.
DefaultMcpXMLInject
=
groupDescMcpXMLInject
.
Default
.
(
bool
)
// groupDescSupportedModelScopes is the schema descriptor for supported_model_scopes field.
// groupDescSupportedModelScopes is the schema descriptor for supported_model_scopes field.
groupDescSupportedModelScopes
:=
groupFields
[
2
4
]
.
Descriptor
()
groupDescSupportedModelScopes
:=
groupFields
[
2
5
]
.
Descriptor
()
// group.DefaultSupportedModelScopes holds the default value on creation for the supported_model_scopes field.
// group.DefaultSupportedModelScopes holds the default value on creation for the supported_model_scopes field.
group
.
DefaultSupportedModelScopes
=
groupDescSupportedModelScopes
.
Default
.
([]
string
)
group
.
DefaultSupportedModelScopes
=
groupDescSupportedModelScopes
.
Default
.
([]
string
)
// groupDescSortOrder is the schema descriptor for sort_order field.
// groupDescSortOrder is the schema descriptor for sort_order field.
groupDescSortOrder
:=
groupFields
[
2
5
]
.
Descriptor
()
groupDescSortOrder
:=
groupFields
[
2
6
]
.
Descriptor
()
// group.DefaultSortOrder holds the default value on creation for the sort_order field.
// group.DefaultSortOrder holds the default value on creation for the sort_order field.
group
.
DefaultSortOrder
=
groupDescSortOrder
.
Default
.
(
int
)
group
.
DefaultSortOrder
=
groupDescSortOrder
.
Default
.
(
int
)
idempotencyrecordMixin
:=
schema
.
IdempotencyRecord
{}
.
Mixin
()
idempotencyrecordMixinFields0
:=
idempotencyrecordMixin
[
0
]
.
Fields
()
_
=
idempotencyrecordMixinFields0
idempotencyrecordFields
:=
schema
.
IdempotencyRecord
{}
.
Fields
()
_
=
idempotencyrecordFields
// idempotencyrecordDescCreatedAt is the schema descriptor for created_at field.
idempotencyrecordDescCreatedAt
:=
idempotencyrecordMixinFields0
[
0
]
.
Descriptor
()
// idempotencyrecord.DefaultCreatedAt holds the default value on creation for the created_at field.
idempotencyrecord
.
DefaultCreatedAt
=
idempotencyrecordDescCreatedAt
.
Default
.
(
func
()
time
.
Time
)
// idempotencyrecordDescUpdatedAt is the schema descriptor for updated_at field.
idempotencyrecordDescUpdatedAt
:=
idempotencyrecordMixinFields0
[
1
]
.
Descriptor
()
// idempotencyrecord.DefaultUpdatedAt holds the default value on creation for the updated_at field.
idempotencyrecord
.
DefaultUpdatedAt
=
idempotencyrecordDescUpdatedAt
.
Default
.
(
func
()
time
.
Time
)
// idempotencyrecord.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
idempotencyrecord
.
UpdateDefaultUpdatedAt
=
idempotencyrecordDescUpdatedAt
.
UpdateDefault
.
(
func
()
time
.
Time
)
// idempotencyrecordDescScope is the schema descriptor for scope field.
idempotencyrecordDescScope
:=
idempotencyrecordFields
[
0
]
.
Descriptor
()
// idempotencyrecord.ScopeValidator is a validator for the "scope" field. It is called by the builders before save.
idempotencyrecord
.
ScopeValidator
=
idempotencyrecordDescScope
.
Validators
[
0
]
.
(
func
(
string
)
error
)
// idempotencyrecordDescIdempotencyKeyHash is the schema descriptor for idempotency_key_hash field.
idempotencyrecordDescIdempotencyKeyHash
:=
idempotencyrecordFields
[
1
]
.
Descriptor
()
// idempotencyrecord.IdempotencyKeyHashValidator is a validator for the "idempotency_key_hash" field. It is called by the builders before save.
idempotencyrecord
.
IdempotencyKeyHashValidator
=
idempotencyrecordDescIdempotencyKeyHash
.
Validators
[
0
]
.
(
func
(
string
)
error
)
// idempotencyrecordDescRequestFingerprint is the schema descriptor for request_fingerprint field.
idempotencyrecordDescRequestFingerprint
:=
idempotencyrecordFields
[
2
]
.
Descriptor
()
// idempotencyrecord.RequestFingerprintValidator is a validator for the "request_fingerprint" field. It is called by the builders before save.
idempotencyrecord
.
RequestFingerprintValidator
=
idempotencyrecordDescRequestFingerprint
.
Validators
[
0
]
.
(
func
(
string
)
error
)
// idempotencyrecordDescStatus is the schema descriptor for status field.
idempotencyrecordDescStatus
:=
idempotencyrecordFields
[
3
]
.
Descriptor
()
// idempotencyrecord.StatusValidator is a validator for the "status" field. It is called by the builders before save.
idempotencyrecord
.
StatusValidator
=
idempotencyrecordDescStatus
.
Validators
[
0
]
.
(
func
(
string
)
error
)
// idempotencyrecordDescErrorReason is the schema descriptor for error_reason field.
idempotencyrecordDescErrorReason
:=
idempotencyrecordFields
[
6
]
.
Descriptor
()
// idempotencyrecord.ErrorReasonValidator is a validator for the "error_reason" field. It is called by the builders before save.
idempotencyrecord
.
ErrorReasonValidator
=
idempotencyrecordDescErrorReason
.
Validators
[
0
]
.
(
func
(
string
)
error
)
promocodeFields
:=
schema
.
PromoCode
{}
.
Fields
()
promocodeFields
:=
schema
.
PromoCode
{}
.
Fields
()
_
=
promocodeFields
_
=
promocodeFields
// promocodeDescCode is the schema descriptor for code field.
// promocodeDescCode is the schema descriptor for code field.
...
@@ -918,6 +958,14 @@ func init() {
...
@@ -918,6 +958,14 @@ func init() {
userDescTotpEnabled
:=
userFields
[
9
]
.
Descriptor
()
userDescTotpEnabled
:=
userFields
[
9
]
.
Descriptor
()
// user.DefaultTotpEnabled holds the default value on creation for the totp_enabled field.
// user.DefaultTotpEnabled holds the default value on creation for the totp_enabled field.
user
.
DefaultTotpEnabled
=
userDescTotpEnabled
.
Default
.
(
bool
)
user
.
DefaultTotpEnabled
=
userDescTotpEnabled
.
Default
.
(
bool
)
// userDescSoraStorageQuotaBytes is the schema descriptor for sora_storage_quota_bytes field.
userDescSoraStorageQuotaBytes
:=
userFields
[
11
]
.
Descriptor
()
// user.DefaultSoraStorageQuotaBytes holds the default value on creation for the sora_storage_quota_bytes field.
user
.
DefaultSoraStorageQuotaBytes
=
userDescSoraStorageQuotaBytes
.
Default
.
(
int64
)
// userDescSoraStorageUsedBytes is the schema descriptor for sora_storage_used_bytes field.
userDescSoraStorageUsedBytes
:=
userFields
[
12
]
.
Descriptor
()
// user.DefaultSoraStorageUsedBytes holds the default value on creation for the sora_storage_used_bytes field.
user
.
DefaultSoraStorageUsedBytes
=
userDescSoraStorageUsedBytes
.
Default
.
(
int64
)
userallowedgroupFields
:=
schema
.
UserAllowedGroup
{}
.
Fields
()
userallowedgroupFields
:=
schema
.
UserAllowedGroup
{}
.
Fields
()
_
=
userallowedgroupFields
_
=
userallowedgroupFields
// userallowedgroupDescCreatedAt is the schema descriptor for created_at field.
// userallowedgroupDescCreatedAt is the schema descriptor for created_at field.
...
...
backend/ent/schema/account.go
View file @
bb664d9b
...
@@ -164,6 +164,19 @@ func (Account) Fields() []ent.Field {
...
@@ -164,6 +164,19 @@ func (Account) Fields() []ent.Field {
Nillable
()
.
Nillable
()
.
SchemaType
(
map
[
string
]
string
{
dialect
.
Postgres
:
"timestamptz"
}),
SchemaType
(
map
[
string
]
string
{
dialect
.
Postgres
:
"timestamptz"
}),
// temp_unschedulable_until: 临时不可调度状态解除时间
// 当命中临时不可调度规则时设置,在此时间前调度器应跳过该账号
field
.
Time
(
"temp_unschedulable_until"
)
.
Optional
()
.
Nillable
()
.
SchemaType
(
map
[
string
]
string
{
dialect
.
Postgres
:
"timestamptz"
}),
// temp_unschedulable_reason: 临时不可调度原因,便于排障审计
field
.
String
(
"temp_unschedulable_reason"
)
.
Optional
()
.
Nillable
()
.
SchemaType
(
map
[
string
]
string
{
dialect
.
Postgres
:
"text"
}),
// session_window_*: 会话窗口相关字段
// session_window_*: 会话窗口相关字段
// 用于管理某些需要会话时间窗口的 API(如 Claude Pro)
// 用于管理某些需要会话时间窗口的 API(如 Claude Pro)
field
.
Time
(
"session_window_start"
)
.
field
.
Time
(
"session_window_start"
)
.
...
@@ -213,6 +226,9 @@ func (Account) Indexes() []ent.Index {
...
@@ -213,6 +226,9 @@ func (Account) Indexes() []ent.Index {
index
.
Fields
(
"rate_limited_at"
),
// 筛选速率限制账户
index
.
Fields
(
"rate_limited_at"
),
// 筛选速率限制账户
index
.
Fields
(
"rate_limit_reset_at"
),
// 筛选速率限制解除时间
index
.
Fields
(
"rate_limit_reset_at"
),
// 筛选速率限制解除时间
index
.
Fields
(
"overload_until"
),
// 筛选过载账户
index
.
Fields
(
"overload_until"
),
// 筛选过载账户
index
.
Fields
(
"deleted_at"
),
// 软删除查询优化
// 调度热路径复合索引(线上由 SQL 迁移创建部分索引,schema 仅用于模型可读性对齐)
index
.
Fields
(
"platform"
,
"priority"
),
index
.
Fields
(
"priority"
,
"status"
),
index
.
Fields
(
"deleted_at"
),
// 软删除查询优化
}
}
}
}
backend/ent/schema/group.go
View file @
bb664d9b
...
@@ -105,6 +105,10 @@ func (Group) Fields() []ent.Field {
...
@@ -105,6 +105,10 @@ func (Group) Fields() []ent.Field {
Nillable
()
.
Nillable
()
.
SchemaType
(
map
[
string
]
string
{
dialect
.
Postgres
:
"decimal(20,8)"
}),
SchemaType
(
map
[
string
]
string
{
dialect
.
Postgres
:
"decimal(20,8)"
}),
// Sora 存储配额
field
.
Int64
(
"sora_storage_quota_bytes"
)
.
Default
(
0
),
// Claude Code 客户端限制 (added by migration 029)
// Claude Code 客户端限制 (added by migration 029)
field
.
Bool
(
"claude_code_only"
)
.
field
.
Bool
(
"claude_code_only"
)
.
Default
(
false
)
.
Default
(
false
)
.
...
...
backend/ent/schema/usage_log.go
View file @
bb664d9b
...
@@ -179,5 +179,7 @@ func (UsageLog) Indexes() []ent.Index {
...
@@ -179,5 +179,7 @@ func (UsageLog) Indexes() []ent.Index {
// 复合索引用于时间范围查询
// 复合索引用于时间范围查询
index
.
Fields
(
"user_id"
,
"created_at"
),
index
.
Fields
(
"user_id"
,
"created_at"
),
index
.
Fields
(
"api_key_id"
,
"created_at"
),
index
.
Fields
(
"api_key_id"
,
"created_at"
),
// 分组维度时间范围查询(线上由 SQL 迁移创建 group_id IS NOT NULL 的部分索引)
index
.
Fields
(
"group_id"
,
"created_at"
),
}
}
}
}
Prev
1
2
3
4
5
6
…
13
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