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
2a5ef6d3
Commit
2a5ef6d3
authored
Jan 15, 2026
by
shaw
Browse files
Merge PR #279: feat(计费): 账号计费倍率快照与账号口径费用统计
parents
99cbfa15
ec24a3c3
Changes
51
Hide whitespace changes
Inline
Side-by-side
backend/ent/account.go
View file @
2a5ef6d3
...
@@ -43,6 +43,8 @@ type Account struct {
...
@@ -43,6 +43,8 @@ type Account struct {
Concurrency
int
`json:"concurrency,omitempty"`
Concurrency
int
`json:"concurrency,omitempty"`
// Priority holds the value of the "priority" field.
// Priority holds the value of the "priority" field.
Priority
int
`json:"priority,omitempty"`
Priority
int
`json:"priority,omitempty"`
// RateMultiplier holds the value of the "rate_multiplier" field.
RateMultiplier
float64
`json:"rate_multiplier,omitempty"`
// Status holds the value of the "status" field.
// Status holds the value of the "status" field.
Status
string
`json:"status,omitempty"`
Status
string
`json:"status,omitempty"`
// ErrorMessage holds the value of the "error_message" field.
// ErrorMessage holds the value of the "error_message" field.
...
@@ -135,6 +137,8 @@ func (*Account) scanValues(columns []string) ([]any, error) {
...
@@ -135,6 +137,8 @@ func (*Account) scanValues(columns []string) ([]any, error) {
values
[
i
]
=
new
([]
byte
)
values
[
i
]
=
new
([]
byte
)
case
account
.
FieldAutoPauseOnExpired
,
account
.
FieldSchedulable
:
case
account
.
FieldAutoPauseOnExpired
,
account
.
FieldSchedulable
:
values
[
i
]
=
new
(
sql
.
NullBool
)
values
[
i
]
=
new
(
sql
.
NullBool
)
case
account
.
FieldRateMultiplier
:
values
[
i
]
=
new
(
sql
.
NullFloat64
)
case
account
.
FieldID
,
account
.
FieldProxyID
,
account
.
FieldConcurrency
,
account
.
FieldPriority
:
case
account
.
FieldID
,
account
.
FieldProxyID
,
account
.
FieldConcurrency
,
account
.
FieldPriority
:
values
[
i
]
=
new
(
sql
.
NullInt64
)
values
[
i
]
=
new
(
sql
.
NullInt64
)
case
account
.
FieldName
,
account
.
FieldNotes
,
account
.
FieldPlatform
,
account
.
FieldType
,
account
.
FieldStatus
,
account
.
FieldErrorMessage
,
account
.
FieldSessionWindowStatus
:
case
account
.
FieldName
,
account
.
FieldNotes
,
account
.
FieldPlatform
,
account
.
FieldType
,
account
.
FieldStatus
,
account
.
FieldErrorMessage
,
account
.
FieldSessionWindowStatus
:
...
@@ -241,6 +245,12 @@ func (_m *Account) assignValues(columns []string, values []any) error {
...
@@ -241,6 +245,12 @@ func (_m *Account) assignValues(columns []string, values []any) error {
}
else
if
value
.
Valid
{
}
else
if
value
.
Valid
{
_m
.
Priority
=
int
(
value
.
Int64
)
_m
.
Priority
=
int
(
value
.
Int64
)
}
}
case
account
.
FieldRateMultiplier
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullFloat64
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field rate_multiplier"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
RateMultiplier
=
value
.
Float64
}
case
account
.
FieldStatus
:
case
account
.
FieldStatus
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field status"
,
values
[
i
])
return
fmt
.
Errorf
(
"unexpected type %T for field status"
,
values
[
i
])
...
@@ -420,6 +430,9 @@ func (_m *Account) String() string {
...
@@ -420,6 +430,9 @@ func (_m *Account) String() string {
builder
.
WriteString
(
"priority="
)
builder
.
WriteString
(
"priority="
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"%v"
,
_m
.
Priority
))
builder
.
WriteString
(
fmt
.
Sprintf
(
"%v"
,
_m
.
Priority
))
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"rate_multiplier="
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"%v"
,
_m
.
RateMultiplier
))
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"status="
)
builder
.
WriteString
(
"status="
)
builder
.
WriteString
(
_m
.
Status
)
builder
.
WriteString
(
_m
.
Status
)
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
", "
)
...
...
backend/ent/account/account.go
View file @
2a5ef6d3
...
@@ -39,6 +39,8 @@ const (
...
@@ -39,6 +39,8 @@ const (
FieldConcurrency
=
"concurrency"
FieldConcurrency
=
"concurrency"
// FieldPriority holds the string denoting the priority field in the database.
// FieldPriority holds the string denoting the priority field in the database.
FieldPriority
=
"priority"
FieldPriority
=
"priority"
// FieldRateMultiplier holds the string denoting the rate_multiplier field in the database.
FieldRateMultiplier
=
"rate_multiplier"
// FieldStatus holds the string denoting the status field in the database.
// FieldStatus holds the string denoting the status field in the database.
FieldStatus
=
"status"
FieldStatus
=
"status"
// FieldErrorMessage holds the string denoting the error_message field in the database.
// FieldErrorMessage holds the string denoting the error_message field in the database.
...
@@ -116,6 +118,7 @@ var Columns = []string{
...
@@ -116,6 +118,7 @@ var Columns = []string{
FieldProxyID
,
FieldProxyID
,
FieldConcurrency
,
FieldConcurrency
,
FieldPriority
,
FieldPriority
,
FieldRateMultiplier
,
FieldStatus
,
FieldStatus
,
FieldErrorMessage
,
FieldErrorMessage
,
FieldLastUsedAt
,
FieldLastUsedAt
,
...
@@ -174,6 +177,8 @@ var (
...
@@ -174,6 +177,8 @@ var (
DefaultConcurrency
int
DefaultConcurrency
int
// DefaultPriority holds the default value on creation for the "priority" field.
// DefaultPriority holds the default value on creation for the "priority" field.
DefaultPriority
int
DefaultPriority
int
// DefaultRateMultiplier holds the default value on creation for the "rate_multiplier" field.
DefaultRateMultiplier
float64
// DefaultStatus holds the default value on creation for the "status" field.
// DefaultStatus holds the default value on creation for the "status" field.
DefaultStatus
string
DefaultStatus
string
// StatusValidator is a validator for the "status" field. It is called by the builders before save.
// StatusValidator is a validator for the "status" field. It is called by the builders before save.
...
@@ -244,6 +249,11 @@ func ByPriority(opts ...sql.OrderTermOption) OrderOption {
...
@@ -244,6 +249,11 @@ func ByPriority(opts ...sql.OrderTermOption) OrderOption {
return
sql
.
OrderByField
(
FieldPriority
,
opts
...
)
.
ToFunc
()
return
sql
.
OrderByField
(
FieldPriority
,
opts
...
)
.
ToFunc
()
}
}
// ByRateMultiplier orders the results by the rate_multiplier field.
func
ByRateMultiplier
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldRateMultiplier
,
opts
...
)
.
ToFunc
()
}
// ByStatus orders the results by the status field.
// ByStatus orders the results by the status field.
func
ByStatus
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
func
ByStatus
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldStatus
,
opts
...
)
.
ToFunc
()
return
sql
.
OrderByField
(
FieldStatus
,
opts
...
)
.
ToFunc
()
...
...
backend/ent/account/where.go
View file @
2a5ef6d3
...
@@ -105,6 +105,11 @@ func Priority(v int) predicate.Account {
...
@@ -105,6 +105,11 @@ func Priority(v int) predicate.Account {
return
predicate
.
Account
(
sql
.
FieldEQ
(
FieldPriority
,
v
))
return
predicate
.
Account
(
sql
.
FieldEQ
(
FieldPriority
,
v
))
}
}
// RateMultiplier applies equality check predicate on the "rate_multiplier" field. It's identical to RateMultiplierEQ.
func
RateMultiplier
(
v
float64
)
predicate
.
Account
{
return
predicate
.
Account
(
sql
.
FieldEQ
(
FieldRateMultiplier
,
v
))
}
// Status applies equality check predicate on the "status" field. It's identical to StatusEQ.
// Status applies equality check predicate on the "status" field. It's identical to StatusEQ.
func
Status
(
v
string
)
predicate
.
Account
{
func
Status
(
v
string
)
predicate
.
Account
{
return
predicate
.
Account
(
sql
.
FieldEQ
(
FieldStatus
,
v
))
return
predicate
.
Account
(
sql
.
FieldEQ
(
FieldStatus
,
v
))
...
@@ -675,6 +680,46 @@ func PriorityLTE(v int) predicate.Account {
...
@@ -675,6 +680,46 @@ func PriorityLTE(v int) predicate.Account {
return
predicate
.
Account
(
sql
.
FieldLTE
(
FieldPriority
,
v
))
return
predicate
.
Account
(
sql
.
FieldLTE
(
FieldPriority
,
v
))
}
}
// RateMultiplierEQ applies the EQ predicate on the "rate_multiplier" field.
func
RateMultiplierEQ
(
v
float64
)
predicate
.
Account
{
return
predicate
.
Account
(
sql
.
FieldEQ
(
FieldRateMultiplier
,
v
))
}
// RateMultiplierNEQ applies the NEQ predicate on the "rate_multiplier" field.
func
RateMultiplierNEQ
(
v
float64
)
predicate
.
Account
{
return
predicate
.
Account
(
sql
.
FieldNEQ
(
FieldRateMultiplier
,
v
))
}
// RateMultiplierIn applies the In predicate on the "rate_multiplier" field.
func
RateMultiplierIn
(
vs
...
float64
)
predicate
.
Account
{
return
predicate
.
Account
(
sql
.
FieldIn
(
FieldRateMultiplier
,
vs
...
))
}
// RateMultiplierNotIn applies the NotIn predicate on the "rate_multiplier" field.
func
RateMultiplierNotIn
(
vs
...
float64
)
predicate
.
Account
{
return
predicate
.
Account
(
sql
.
FieldNotIn
(
FieldRateMultiplier
,
vs
...
))
}
// RateMultiplierGT applies the GT predicate on the "rate_multiplier" field.
func
RateMultiplierGT
(
v
float64
)
predicate
.
Account
{
return
predicate
.
Account
(
sql
.
FieldGT
(
FieldRateMultiplier
,
v
))
}
// RateMultiplierGTE applies the GTE predicate on the "rate_multiplier" field.
func
RateMultiplierGTE
(
v
float64
)
predicate
.
Account
{
return
predicate
.
Account
(
sql
.
FieldGTE
(
FieldRateMultiplier
,
v
))
}
// RateMultiplierLT applies the LT predicate on the "rate_multiplier" field.
func
RateMultiplierLT
(
v
float64
)
predicate
.
Account
{
return
predicate
.
Account
(
sql
.
FieldLT
(
FieldRateMultiplier
,
v
))
}
// RateMultiplierLTE applies the LTE predicate on the "rate_multiplier" field.
func
RateMultiplierLTE
(
v
float64
)
predicate
.
Account
{
return
predicate
.
Account
(
sql
.
FieldLTE
(
FieldRateMultiplier
,
v
))
}
// StatusEQ applies the EQ predicate on the "status" field.
// StatusEQ applies the EQ predicate on the "status" field.
func
StatusEQ
(
v
string
)
predicate
.
Account
{
func
StatusEQ
(
v
string
)
predicate
.
Account
{
return
predicate
.
Account
(
sql
.
FieldEQ
(
FieldStatus
,
v
))
return
predicate
.
Account
(
sql
.
FieldEQ
(
FieldStatus
,
v
))
...
...
backend/ent/account_create.go
View file @
2a5ef6d3
...
@@ -153,6 +153,20 @@ func (_c *AccountCreate) SetNillablePriority(v *int) *AccountCreate {
...
@@ -153,6 +153,20 @@ func (_c *AccountCreate) SetNillablePriority(v *int) *AccountCreate {
return
_c
return
_c
}
}
// SetRateMultiplier sets the "rate_multiplier" field.
func
(
_c
*
AccountCreate
)
SetRateMultiplier
(
v
float64
)
*
AccountCreate
{
_c
.
mutation
.
SetRateMultiplier
(
v
)
return
_c
}
// SetNillableRateMultiplier sets the "rate_multiplier" field if the given value is not nil.
func
(
_c
*
AccountCreate
)
SetNillableRateMultiplier
(
v
*
float64
)
*
AccountCreate
{
if
v
!=
nil
{
_c
.
SetRateMultiplier
(
*
v
)
}
return
_c
}
// SetStatus sets the "status" field.
// SetStatus sets the "status" field.
func
(
_c
*
AccountCreate
)
SetStatus
(
v
string
)
*
AccountCreate
{
func
(
_c
*
AccountCreate
)
SetStatus
(
v
string
)
*
AccountCreate
{
_c
.
mutation
.
SetStatus
(
v
)
_c
.
mutation
.
SetStatus
(
v
)
...
@@ -429,6 +443,10 @@ func (_c *AccountCreate) defaults() error {
...
@@ -429,6 +443,10 @@ func (_c *AccountCreate) defaults() error {
v
:=
account
.
DefaultPriority
v
:=
account
.
DefaultPriority
_c
.
mutation
.
SetPriority
(
v
)
_c
.
mutation
.
SetPriority
(
v
)
}
}
if
_
,
ok
:=
_c
.
mutation
.
RateMultiplier
();
!
ok
{
v
:=
account
.
DefaultRateMultiplier
_c
.
mutation
.
SetRateMultiplier
(
v
)
}
if
_
,
ok
:=
_c
.
mutation
.
Status
();
!
ok
{
if
_
,
ok
:=
_c
.
mutation
.
Status
();
!
ok
{
v
:=
account
.
DefaultStatus
v
:=
account
.
DefaultStatus
_c
.
mutation
.
SetStatus
(
v
)
_c
.
mutation
.
SetStatus
(
v
)
...
@@ -488,6 +506,9 @@ func (_c *AccountCreate) check() error {
...
@@ -488,6 +506,9 @@ func (_c *AccountCreate) check() error {
if
_
,
ok
:=
_c
.
mutation
.
Priority
();
!
ok
{
if
_
,
ok
:=
_c
.
mutation
.
Priority
();
!
ok
{
return
&
ValidationError
{
Name
:
"priority"
,
err
:
errors
.
New
(
`ent: missing required field "Account.priority"`
)}
return
&
ValidationError
{
Name
:
"priority"
,
err
:
errors
.
New
(
`ent: missing required field "Account.priority"`
)}
}
}
if
_
,
ok
:=
_c
.
mutation
.
RateMultiplier
();
!
ok
{
return
&
ValidationError
{
Name
:
"rate_multiplier"
,
err
:
errors
.
New
(
`ent: missing required field "Account.rate_multiplier"`
)}
}
if
_
,
ok
:=
_c
.
mutation
.
Status
();
!
ok
{
if
_
,
ok
:=
_c
.
mutation
.
Status
();
!
ok
{
return
&
ValidationError
{
Name
:
"status"
,
err
:
errors
.
New
(
`ent: missing required field "Account.status"`
)}
return
&
ValidationError
{
Name
:
"status"
,
err
:
errors
.
New
(
`ent: missing required field "Account.status"`
)}
}
}
...
@@ -578,6 +599,10 @@ func (_c *AccountCreate) createSpec() (*Account, *sqlgraph.CreateSpec) {
...
@@ -578,6 +599,10 @@ func (_c *AccountCreate) createSpec() (*Account, *sqlgraph.CreateSpec) {
_spec
.
SetField
(
account
.
FieldPriority
,
field
.
TypeInt
,
value
)
_spec
.
SetField
(
account
.
FieldPriority
,
field
.
TypeInt
,
value
)
_node
.
Priority
=
value
_node
.
Priority
=
value
}
}
if
value
,
ok
:=
_c
.
mutation
.
RateMultiplier
();
ok
{
_spec
.
SetField
(
account
.
FieldRateMultiplier
,
field
.
TypeFloat64
,
value
)
_node
.
RateMultiplier
=
value
}
if
value
,
ok
:=
_c
.
mutation
.
Status
();
ok
{
if
value
,
ok
:=
_c
.
mutation
.
Status
();
ok
{
_spec
.
SetField
(
account
.
FieldStatus
,
field
.
TypeString
,
value
)
_spec
.
SetField
(
account
.
FieldStatus
,
field
.
TypeString
,
value
)
_node
.
Status
=
value
_node
.
Status
=
value
...
@@ -893,6 +918,24 @@ func (u *AccountUpsert) AddPriority(v int) *AccountUpsert {
...
@@ -893,6 +918,24 @@ func (u *AccountUpsert) AddPriority(v int) *AccountUpsert {
return
u
return
u
}
}
// SetRateMultiplier sets the "rate_multiplier" field.
func
(
u
*
AccountUpsert
)
SetRateMultiplier
(
v
float64
)
*
AccountUpsert
{
u
.
Set
(
account
.
FieldRateMultiplier
,
v
)
return
u
}
// UpdateRateMultiplier sets the "rate_multiplier" field to the value that was provided on create.
func
(
u
*
AccountUpsert
)
UpdateRateMultiplier
()
*
AccountUpsert
{
u
.
SetExcluded
(
account
.
FieldRateMultiplier
)
return
u
}
// AddRateMultiplier adds v to the "rate_multiplier" field.
func
(
u
*
AccountUpsert
)
AddRateMultiplier
(
v
float64
)
*
AccountUpsert
{
u
.
Add
(
account
.
FieldRateMultiplier
,
v
)
return
u
}
// SetStatus sets the "status" field.
// SetStatus sets the "status" field.
func
(
u
*
AccountUpsert
)
SetStatus
(
v
string
)
*
AccountUpsert
{
func
(
u
*
AccountUpsert
)
SetStatus
(
v
string
)
*
AccountUpsert
{
u
.
Set
(
account
.
FieldStatus
,
v
)
u
.
Set
(
account
.
FieldStatus
,
v
)
...
@@ -1325,6 +1368,27 @@ func (u *AccountUpsertOne) UpdatePriority() *AccountUpsertOne {
...
@@ -1325,6 +1368,27 @@ func (u *AccountUpsertOne) UpdatePriority() *AccountUpsertOne {
})
})
}
}
// SetRateMultiplier sets the "rate_multiplier" field.
func
(
u
*
AccountUpsertOne
)
SetRateMultiplier
(
v
float64
)
*
AccountUpsertOne
{
return
u
.
Update
(
func
(
s
*
AccountUpsert
)
{
s
.
SetRateMultiplier
(
v
)
})
}
// AddRateMultiplier adds v to the "rate_multiplier" field.
func
(
u
*
AccountUpsertOne
)
AddRateMultiplier
(
v
float64
)
*
AccountUpsertOne
{
return
u
.
Update
(
func
(
s
*
AccountUpsert
)
{
s
.
AddRateMultiplier
(
v
)
})
}
// UpdateRateMultiplier sets the "rate_multiplier" field to the value that was provided on create.
func
(
u
*
AccountUpsertOne
)
UpdateRateMultiplier
()
*
AccountUpsertOne
{
return
u
.
Update
(
func
(
s
*
AccountUpsert
)
{
s
.
UpdateRateMultiplier
()
})
}
// SetStatus sets the "status" field.
// SetStatus sets the "status" field.
func
(
u
*
AccountUpsertOne
)
SetStatus
(
v
string
)
*
AccountUpsertOne
{
func
(
u
*
AccountUpsertOne
)
SetStatus
(
v
string
)
*
AccountUpsertOne
{
return
u
.
Update
(
func
(
s
*
AccountUpsert
)
{
return
u
.
Update
(
func
(
s
*
AccountUpsert
)
{
...
@@ -1956,6 +2020,27 @@ func (u *AccountUpsertBulk) UpdatePriority() *AccountUpsertBulk {
...
@@ -1956,6 +2020,27 @@ func (u *AccountUpsertBulk) UpdatePriority() *AccountUpsertBulk {
})
})
}
}
// SetRateMultiplier sets the "rate_multiplier" field.
func
(
u
*
AccountUpsertBulk
)
SetRateMultiplier
(
v
float64
)
*
AccountUpsertBulk
{
return
u
.
Update
(
func
(
s
*
AccountUpsert
)
{
s
.
SetRateMultiplier
(
v
)
})
}
// AddRateMultiplier adds v to the "rate_multiplier" field.
func
(
u
*
AccountUpsertBulk
)
AddRateMultiplier
(
v
float64
)
*
AccountUpsertBulk
{
return
u
.
Update
(
func
(
s
*
AccountUpsert
)
{
s
.
AddRateMultiplier
(
v
)
})
}
// UpdateRateMultiplier sets the "rate_multiplier" field to the value that was provided on create.
func
(
u
*
AccountUpsertBulk
)
UpdateRateMultiplier
()
*
AccountUpsertBulk
{
return
u
.
Update
(
func
(
s
*
AccountUpsert
)
{
s
.
UpdateRateMultiplier
()
})
}
// SetStatus sets the "status" field.
// SetStatus sets the "status" field.
func
(
u
*
AccountUpsertBulk
)
SetStatus
(
v
string
)
*
AccountUpsertBulk
{
func
(
u
*
AccountUpsertBulk
)
SetStatus
(
v
string
)
*
AccountUpsertBulk
{
return
u
.
Update
(
func
(
s
*
AccountUpsert
)
{
return
u
.
Update
(
func
(
s
*
AccountUpsert
)
{
...
...
backend/ent/account_update.go
View file @
2a5ef6d3
...
@@ -193,6 +193,27 @@ func (_u *AccountUpdate) AddPriority(v int) *AccountUpdate {
...
@@ -193,6 +193,27 @@ func (_u *AccountUpdate) AddPriority(v int) *AccountUpdate {
return
_u
return
_u
}
}
// SetRateMultiplier sets the "rate_multiplier" field.
func
(
_u
*
AccountUpdate
)
SetRateMultiplier
(
v
float64
)
*
AccountUpdate
{
_u
.
mutation
.
ResetRateMultiplier
()
_u
.
mutation
.
SetRateMultiplier
(
v
)
return
_u
}
// SetNillableRateMultiplier sets the "rate_multiplier" field if the given value is not nil.
func
(
_u
*
AccountUpdate
)
SetNillableRateMultiplier
(
v
*
float64
)
*
AccountUpdate
{
if
v
!=
nil
{
_u
.
SetRateMultiplier
(
*
v
)
}
return
_u
}
// AddRateMultiplier adds value to the "rate_multiplier" field.
func
(
_u
*
AccountUpdate
)
AddRateMultiplier
(
v
float64
)
*
AccountUpdate
{
_u
.
mutation
.
AddRateMultiplier
(
v
)
return
_u
}
// SetStatus sets the "status" field.
// SetStatus sets the "status" field.
func
(
_u
*
AccountUpdate
)
SetStatus
(
v
string
)
*
AccountUpdate
{
func
(
_u
*
AccountUpdate
)
SetStatus
(
v
string
)
*
AccountUpdate
{
_u
.
mutation
.
SetStatus
(
v
)
_u
.
mutation
.
SetStatus
(
v
)
...
@@ -629,6 +650,12 @@ func (_u *AccountUpdate) sqlSave(ctx context.Context) (_node int, err error) {
...
@@ -629,6 +650,12 @@ func (_u *AccountUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if
value
,
ok
:=
_u
.
mutation
.
AddedPriority
();
ok
{
if
value
,
ok
:=
_u
.
mutation
.
AddedPriority
();
ok
{
_spec
.
AddField
(
account
.
FieldPriority
,
field
.
TypeInt
,
value
)
_spec
.
AddField
(
account
.
FieldPriority
,
field
.
TypeInt
,
value
)
}
}
if
value
,
ok
:=
_u
.
mutation
.
RateMultiplier
();
ok
{
_spec
.
SetField
(
account
.
FieldRateMultiplier
,
field
.
TypeFloat64
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
AddedRateMultiplier
();
ok
{
_spec
.
AddField
(
account
.
FieldRateMultiplier
,
field
.
TypeFloat64
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
Status
();
ok
{
if
value
,
ok
:=
_u
.
mutation
.
Status
();
ok
{
_spec
.
SetField
(
account
.
FieldStatus
,
field
.
TypeString
,
value
)
_spec
.
SetField
(
account
.
FieldStatus
,
field
.
TypeString
,
value
)
}
}
...
@@ -1005,6 +1032,27 @@ func (_u *AccountUpdateOne) AddPriority(v int) *AccountUpdateOne {
...
@@ -1005,6 +1032,27 @@ func (_u *AccountUpdateOne) AddPriority(v int) *AccountUpdateOne {
return
_u
return
_u
}
}
// SetRateMultiplier sets the "rate_multiplier" field.
func
(
_u
*
AccountUpdateOne
)
SetRateMultiplier
(
v
float64
)
*
AccountUpdateOne
{
_u
.
mutation
.
ResetRateMultiplier
()
_u
.
mutation
.
SetRateMultiplier
(
v
)
return
_u
}
// SetNillableRateMultiplier sets the "rate_multiplier" field if the given value is not nil.
func
(
_u
*
AccountUpdateOne
)
SetNillableRateMultiplier
(
v
*
float64
)
*
AccountUpdateOne
{
if
v
!=
nil
{
_u
.
SetRateMultiplier
(
*
v
)
}
return
_u
}
// AddRateMultiplier adds value to the "rate_multiplier" field.
func
(
_u
*
AccountUpdateOne
)
AddRateMultiplier
(
v
float64
)
*
AccountUpdateOne
{
_u
.
mutation
.
AddRateMultiplier
(
v
)
return
_u
}
// SetStatus sets the "status" field.
// SetStatus sets the "status" field.
func
(
_u
*
AccountUpdateOne
)
SetStatus
(
v
string
)
*
AccountUpdateOne
{
func
(
_u
*
AccountUpdateOne
)
SetStatus
(
v
string
)
*
AccountUpdateOne
{
_u
.
mutation
.
SetStatus
(
v
)
_u
.
mutation
.
SetStatus
(
v
)
...
@@ -1471,6 +1519,12 @@ func (_u *AccountUpdateOne) sqlSave(ctx context.Context) (_node *Account, err er
...
@@ -1471,6 +1519,12 @@ func (_u *AccountUpdateOne) sqlSave(ctx context.Context) (_node *Account, err er
if
value
,
ok
:=
_u
.
mutation
.
AddedPriority
();
ok
{
if
value
,
ok
:=
_u
.
mutation
.
AddedPriority
();
ok
{
_spec
.
AddField
(
account
.
FieldPriority
,
field
.
TypeInt
,
value
)
_spec
.
AddField
(
account
.
FieldPriority
,
field
.
TypeInt
,
value
)
}
}
if
value
,
ok
:=
_u
.
mutation
.
RateMultiplier
();
ok
{
_spec
.
SetField
(
account
.
FieldRateMultiplier
,
field
.
TypeFloat64
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
AddedRateMultiplier
();
ok
{
_spec
.
AddField
(
account
.
FieldRateMultiplier
,
field
.
TypeFloat64
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
Status
();
ok
{
if
value
,
ok
:=
_u
.
mutation
.
Status
();
ok
{
_spec
.
SetField
(
account
.
FieldStatus
,
field
.
TypeString
,
value
)
_spec
.
SetField
(
account
.
FieldStatus
,
field
.
TypeString
,
value
)
}
}
...
...
backend/ent/migrate/schema.go
View file @
2a5ef6d3
...
@@ -79,6 +79,7 @@ var (
...
@@ -79,6 +79,7 @@ var (
{
Name
:
"extra"
,
Type
:
field
.
TypeJSON
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"jsonb"
}},
{
Name
:
"extra"
,
Type
:
field
.
TypeJSON
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"jsonb"
}},
{
Name
:
"concurrency"
,
Type
:
field
.
TypeInt
,
Default
:
3
},
{
Name
:
"concurrency"
,
Type
:
field
.
TypeInt
,
Default
:
3
},
{
Name
:
"priority"
,
Type
:
field
.
TypeInt
,
Default
:
50
},
{
Name
:
"priority"
,
Type
:
field
.
TypeInt
,
Default
:
50
},
{
Name
:
"rate_multiplier"
,
Type
:
field
.
TypeFloat64
,
Default
:
1
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"decimal(10,4)"
}},
{
Name
:
"status"
,
Type
:
field
.
TypeString
,
Size
:
20
,
Default
:
"active"
},
{
Name
:
"status"
,
Type
:
field
.
TypeString
,
Size
:
20
,
Default
:
"active"
},
{
Name
:
"error_message"
,
Type
:
field
.
TypeString
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"text"
}},
{
Name
:
"error_message"
,
Type
:
field
.
TypeString
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"text"
}},
{
Name
:
"last_used_at"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"timestamptz"
}},
{
Name
:
"last_used_at"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"timestamptz"
}},
...
@@ -101,7 +102,7 @@ var (
...
@@ -101,7 +102,7 @@ var (
ForeignKeys
:
[]
*
schema
.
ForeignKey
{
ForeignKeys
:
[]
*
schema
.
ForeignKey
{
{
{
Symbol
:
"accounts_proxies_proxy"
,
Symbol
:
"accounts_proxies_proxy"
,
Columns
:
[]
*
schema
.
Column
{
AccountsColumns
[
2
4
]},
Columns
:
[]
*
schema
.
Column
{
AccountsColumns
[
2
5
]},
RefColumns
:
[]
*
schema
.
Column
{
ProxiesColumns
[
0
]},
RefColumns
:
[]
*
schema
.
Column
{
ProxiesColumns
[
0
]},
OnDelete
:
schema
.
SetNull
,
OnDelete
:
schema
.
SetNull
,
},
},
...
@@ -120,12 +121,12 @@ var (
...
@@ -120,12 +121,12 @@ var (
{
{
Name
:
"account_status"
,
Name
:
"account_status"
,
Unique
:
false
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
AccountsColumns
[
1
2
]},
Columns
:
[]
*
schema
.
Column
{
AccountsColumns
[
1
3
]},
},
},
{
{
Name
:
"account_proxy_id"
,
Name
:
"account_proxy_id"
,
Unique
:
false
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
AccountsColumns
[
2
4
]},
Columns
:
[]
*
schema
.
Column
{
AccountsColumns
[
2
5
]},
},
},
{
{
Name
:
"account_priority"
,
Name
:
"account_priority"
,
...
@@ -135,27 +136,27 @@ var (
...
@@ -135,27 +136,27 @@ var (
{
{
Name
:
"account_last_used_at"
,
Name
:
"account_last_used_at"
,
Unique
:
false
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
AccountsColumns
[
1
4
]},
Columns
:
[]
*
schema
.
Column
{
AccountsColumns
[
1
5
]},
},
},
{
{
Name
:
"account_schedulable"
,
Name
:
"account_schedulable"
,
Unique
:
false
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
AccountsColumns
[
1
7
]},
Columns
:
[]
*
schema
.
Column
{
AccountsColumns
[
1
8
]},
},
},
{
{
Name
:
"account_rate_limited_at"
,
Name
:
"account_rate_limited_at"
,
Unique
:
false
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
AccountsColumns
[
1
8
]},
Columns
:
[]
*
schema
.
Column
{
AccountsColumns
[
1
9
]},
},
},
{
{
Name
:
"account_rate_limit_reset_at"
,
Name
:
"account_rate_limit_reset_at"
,
Unique
:
false
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
AccountsColumns
[
19
]},
Columns
:
[]
*
schema
.
Column
{
AccountsColumns
[
20
]},
},
},
{
{
Name
:
"account_overload_until"
,
Name
:
"account_overload_until"
,
Unique
:
false
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
AccountsColumns
[
2
0
]},
Columns
:
[]
*
schema
.
Column
{
AccountsColumns
[
2
1
]},
},
},
{
{
Name
:
"account_deleted_at"
,
Name
:
"account_deleted_at"
,
...
@@ -449,6 +450,7 @@ var (
...
@@ -449,6 +450,7 @@ var (
{
Name
:
"total_cost"
,
Type
:
field
.
TypeFloat64
,
Default
:
0
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"decimal(20,10)"
}},
{
Name
:
"total_cost"
,
Type
:
field
.
TypeFloat64
,
Default
:
0
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"decimal(20,10)"
}},
{
Name
:
"actual_cost"
,
Type
:
field
.
TypeFloat64
,
Default
:
0
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"decimal(20,10)"
}},
{
Name
:
"actual_cost"
,
Type
:
field
.
TypeFloat64
,
Default
:
0
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"decimal(20,10)"
}},
{
Name
:
"rate_multiplier"
,
Type
:
field
.
TypeFloat64
,
Default
:
1
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"decimal(10,4)"
}},
{
Name
:
"rate_multiplier"
,
Type
:
field
.
TypeFloat64
,
Default
:
1
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"decimal(10,4)"
}},
{
Name
:
"account_rate_multiplier"
,
Type
:
field
.
TypeFloat64
,
Nullable
:
true
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"decimal(10,4)"
}},
{
Name
:
"billing_type"
,
Type
:
field
.
TypeInt8
,
Default
:
0
},
{
Name
:
"billing_type"
,
Type
:
field
.
TypeInt8
,
Default
:
0
},
{
Name
:
"stream"
,
Type
:
field
.
TypeBool
,
Default
:
false
},
{
Name
:
"stream"
,
Type
:
field
.
TypeBool
,
Default
:
false
},
{
Name
:
"duration_ms"
,
Type
:
field
.
TypeInt
,
Nullable
:
true
},
{
Name
:
"duration_ms"
,
Type
:
field
.
TypeInt
,
Nullable
:
true
},
...
@@ -472,31 +474,31 @@ var (
...
@@ -472,31 +474,31 @@ var (
ForeignKeys
:
[]
*
schema
.
ForeignKey
{
ForeignKeys
:
[]
*
schema
.
ForeignKey
{
{
{
Symbol
:
"usage_logs_api_keys_usage_logs"
,
Symbol
:
"usage_logs_api_keys_usage_logs"
,
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
2
5
]},
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
2
6
]},
RefColumns
:
[]
*
schema
.
Column
{
APIKeysColumns
[
0
]},
RefColumns
:
[]
*
schema
.
Column
{
APIKeysColumns
[
0
]},
OnDelete
:
schema
.
NoAction
,
OnDelete
:
schema
.
NoAction
,
},
},
{
{
Symbol
:
"usage_logs_accounts_usage_logs"
,
Symbol
:
"usage_logs_accounts_usage_logs"
,
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
2
6
]},
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
2
7
]},
RefColumns
:
[]
*
schema
.
Column
{
AccountsColumns
[
0
]},
RefColumns
:
[]
*
schema
.
Column
{
AccountsColumns
[
0
]},
OnDelete
:
schema
.
NoAction
,
OnDelete
:
schema
.
NoAction
,
},
},
{
{
Symbol
:
"usage_logs_groups_usage_logs"
,
Symbol
:
"usage_logs_groups_usage_logs"
,
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
2
7
]},
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
2
8
]},
RefColumns
:
[]
*
schema
.
Column
{
GroupsColumns
[
0
]},
RefColumns
:
[]
*
schema
.
Column
{
GroupsColumns
[
0
]},
OnDelete
:
schema
.
SetNull
,
OnDelete
:
schema
.
SetNull
,
},
},
{
{
Symbol
:
"usage_logs_users_usage_logs"
,
Symbol
:
"usage_logs_users_usage_logs"
,
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
2
8
]},
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
2
9
]},
RefColumns
:
[]
*
schema
.
Column
{
UsersColumns
[
0
]},
RefColumns
:
[]
*
schema
.
Column
{
UsersColumns
[
0
]},
OnDelete
:
schema
.
NoAction
,
OnDelete
:
schema
.
NoAction
,
},
},
{
{
Symbol
:
"usage_logs_user_subscriptions_usage_logs"
,
Symbol
:
"usage_logs_user_subscriptions_usage_logs"
,
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
29
]},
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
30
]},
RefColumns
:
[]
*
schema
.
Column
{
UserSubscriptionsColumns
[
0
]},
RefColumns
:
[]
*
schema
.
Column
{
UserSubscriptionsColumns
[
0
]},
OnDelete
:
schema
.
SetNull
,
OnDelete
:
schema
.
SetNull
,
},
},
...
@@ -505,32 +507,32 @@ var (
...
@@ -505,32 +507,32 @@ var (
{
{
Name
:
"usagelog_user_id"
,
Name
:
"usagelog_user_id"
,
Unique
:
false
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
2
8
]},
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
2
9
]},
},
},
{
{
Name
:
"usagelog_api_key_id"
,
Name
:
"usagelog_api_key_id"
,
Unique
:
false
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
2
5
]},
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
2
6
]},
},
},
{
{
Name
:
"usagelog_account_id"
,
Name
:
"usagelog_account_id"
,
Unique
:
false
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
2
6
]},
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
2
7
]},
},
},
{
{
Name
:
"usagelog_group_id"
,
Name
:
"usagelog_group_id"
,
Unique
:
false
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
2
7
]},
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
2
8
]},
},
},
{
{
Name
:
"usagelog_subscription_id"
,
Name
:
"usagelog_subscription_id"
,
Unique
:
false
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
29
]},
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
30
]},
},
},
{
{
Name
:
"usagelog_created_at"
,
Name
:
"usagelog_created_at"
,
Unique
:
false
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
2
4
]},
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
2
5
]},
},
},
{
{
Name
:
"usagelog_model"
,
Name
:
"usagelog_model"
,
...
@@ -545,12 +547,12 @@ var (
...
@@ -545,12 +547,12 @@ var (
{
{
Name
:
"usagelog_user_id_created_at"
,
Name
:
"usagelog_user_id_created_at"
,
Unique
:
false
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
2
8
],
UsageLogsColumns
[
2
4
]},
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
2
9
],
UsageLogsColumns
[
2
5
]},
},
},
{
{
Name
:
"usagelog_api_key_id_created_at"
,
Name
:
"usagelog_api_key_id_created_at"
,
Unique
:
false
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
2
5
],
UsageLogsColumns
[
2
4
]},
Columns
:
[]
*
schema
.
Column
{
UsageLogsColumns
[
2
6
],
UsageLogsColumns
[
2
5
]},
},
},
},
},
}
}
...
...
backend/ent/mutation.go
View file @
2a5ef6d3
...
@@ -1187,6 +1187,8 @@ type AccountMutation struct {
...
@@ -1187,6 +1187,8 @@ type AccountMutation struct {
addconcurrency *int
addconcurrency *int
priority *int
priority *int
addpriority *int
addpriority *int
rate_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
...
@@ -1822,6 +1824,62 @@ func (m *AccountMutation) ResetPriority() {
...
@@ -1822,6 +1824,62 @@ func (m *AccountMutation) ResetPriority() {
m.addpriority = nil
m.addpriority = nil
}
}
// SetRateMultiplier sets the "rate_multiplier" field.
func (m *AccountMutation) SetRateMultiplier(f float64) {
m.rate_multiplier = &f
m.addrate_multiplier = nil
}
// RateMultiplier returns the value of the "rate_multiplier" field in the mutation.
func (m *AccountMutation) RateMultiplier() (r float64, exists bool) {
v := m.rate_multiplier
if v == nil {
return
}
return *v, true
}
// OldRateMultiplier returns the old "rate_multiplier" 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) OldRateMultiplier(ctx context.Context) (v float64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRateMultiplier is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRateMultiplier requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRateMultiplier: %w", err)
}
return oldValue.RateMultiplier, nil
}
// AddRateMultiplier adds f to the "rate_multiplier" field.
func (m *AccountMutation) AddRateMultiplier(f float64) {
if m.addrate_multiplier != nil {
*m.addrate_multiplier += f
} else {
m.addrate_multiplier = &f
}
}
// AddedRateMultiplier returns the value that was added to the "rate_multiplier" field in this mutation.
func (m *AccountMutation) AddedRateMultiplier() (r float64, exists bool) {
v := m.addrate_multiplier
if v == nil {
return
}
return *v, true
}
// ResetRateMultiplier resets all changes to the "rate_multiplier" field.
func (m *AccountMutation) ResetRateMultiplier() {
m.rate_multiplier = nil
m.addrate_multiplier = nil
}
// SetStatus sets the "status" field.
// SetStatus sets the "status" field.
func (m *AccountMutation) SetStatus(s string) {
func (m *AccountMutation) SetStatus(s string) {
m.status = &s
m.status = &s
...
@@ -2540,7 +2598,7 @@ func (m *AccountMutation) Type() string {
...
@@ -2540,7 +2598,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
4
)
fields := make([]string, 0, 2
5
)
if m.created_at != nil {
if m.created_at != nil {
fields = append(fields, account.FieldCreatedAt)
fields = append(fields, account.FieldCreatedAt)
}
}
...
@@ -2577,6 +2635,9 @@ func (m *AccountMutation) Fields() []string {
...
@@ -2577,6 +2635,9 @@ func (m *AccountMutation) Fields() []string {
if m.priority != nil {
if m.priority != nil {
fields = append(fields, account.FieldPriority)
fields = append(fields, account.FieldPriority)
}
}
if m.rate_multiplier != nil {
fields = append(fields, account.FieldRateMultiplier)
}
if m.status != nil {
if m.status != nil {
fields = append(fields, account.FieldStatus)
fields = append(fields, account.FieldStatus)
}
}
...
@@ -2645,6 +2706,8 @@ func (m *AccountMutation) Field(name string) (ent.Value, bool) {
...
@@ -2645,6 +2706,8 @@ func (m *AccountMutation) Field(name string) (ent.Value, bool) {
return m.Concurrency()
return m.Concurrency()
case account.FieldPriority:
case account.FieldPriority:
return m.Priority()
return m.Priority()
case account.FieldRateMultiplier:
return m.RateMultiplier()
case account.FieldStatus:
case account.FieldStatus:
return m.Status()
return m.Status()
case account.FieldErrorMessage:
case account.FieldErrorMessage:
...
@@ -2702,6 +2765,8 @@ func (m *AccountMutation) OldField(ctx context.Context, name string) (ent.Value,
...
@@ -2702,6 +2765,8 @@ func (m *AccountMutation) OldField(ctx context.Context, name string) (ent.Value,
return m.OldConcurrency(ctx)
return m.OldConcurrency(ctx)
case account.FieldPriority:
case account.FieldPriority:
return m.OldPriority(ctx)
return m.OldPriority(ctx)
case account.FieldRateMultiplier:
return m.OldRateMultiplier(ctx)
case account.FieldStatus:
case account.FieldStatus:
return m.OldStatus(ctx)
return m.OldStatus(ctx)
case account.FieldErrorMessage:
case account.FieldErrorMessage:
...
@@ -2819,6 +2884,13 @@ func (m *AccountMutation) SetField(name string, value ent.Value) error {
...
@@ -2819,6 +2884,13 @@ func (m *AccountMutation) SetField(name string, value ent.Value) error {
}
}
m.SetPriority(v)
m.SetPriority(v)
return nil
return nil
case account.FieldRateMultiplier:
v, ok := value.(float64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRateMultiplier(v)
return nil
case account.FieldStatus:
case account.FieldStatus:
v, ok := value.(string)
v, ok := value.(string)
if !ok {
if !ok {
...
@@ -2917,6 +2989,9 @@ func (m *AccountMutation) AddedFields() []string {
...
@@ -2917,6 +2989,9 @@ func (m *AccountMutation) AddedFields() []string {
if m.addpriority != nil {
if m.addpriority != nil {
fields = append(fields, account.FieldPriority)
fields = append(fields, account.FieldPriority)
}
}
if m.addrate_multiplier != nil {
fields = append(fields, account.FieldRateMultiplier)
}
return fields
return fields
}
}
...
@@ -2929,6 +3004,8 @@ func (m *AccountMutation) AddedField(name string) (ent.Value, bool) {
...
@@ -2929,6 +3004,8 @@ func (m *AccountMutation) AddedField(name string) (ent.Value, bool) {
return m.AddedConcurrency()
return m.AddedConcurrency()
case account.FieldPriority:
case account.FieldPriority:
return m.AddedPriority()
return m.AddedPriority()
case account.FieldRateMultiplier:
return m.AddedRateMultiplier()
}
}
return nil, false
return nil, false
}
}
...
@@ -2952,6 +3029,13 @@ func (m *AccountMutation) AddField(name string, value ent.Value) error {
...
@@ -2952,6 +3029,13 @@ func (m *AccountMutation) AddField(name string, value ent.Value) error {
}
}
m.AddPriority(v)
m.AddPriority(v)
return nil
return nil
case account.FieldRateMultiplier:
v, ok := value.(float64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddRateMultiplier(v)
return nil
}
}
return fmt.Errorf("unknown Account numeric field %s", name)
return fmt.Errorf("unknown Account numeric field %s", name)
}
}
...
@@ -3090,6 +3174,9 @@ func (m *AccountMutation) ResetField(name string) error {
...
@@ -3090,6 +3174,9 @@ func (m *AccountMutation) ResetField(name string) error {
case account.FieldPriority:
case account.FieldPriority:
m.ResetPriority()
m.ResetPriority()
return nil
return nil
case account.FieldRateMultiplier:
m.ResetRateMultiplier()
return nil
case account.FieldStatus:
case account.FieldStatus:
m.ResetStatus()
m.ResetStatus()
return nil
return nil
...
@@ -10190,6 +10277,8 @@ type UsageLogMutation struct {
...
@@ -10190,6 +10277,8 @@ type UsageLogMutation struct {
addactual_cost *float64
addactual_cost *float64
rate_multiplier *float64
rate_multiplier *float64
addrate_multiplier *float64
addrate_multiplier *float64
account_rate_multiplier *float64
addaccount_rate_multiplier *float64
billing_type *int8
billing_type *int8
addbilling_type *int8
addbilling_type *int8
stream *bool
stream *bool
...
@@ -11323,6 +11412,76 @@ func (m *UsageLogMutation) ResetRateMultiplier() {
...
@@ -11323,6 +11412,76 @@ func (m *UsageLogMutation) ResetRateMultiplier() {
m.addrate_multiplier = nil
m.addrate_multiplier = nil
}
}
// SetAccountRateMultiplier sets the "account_rate_multiplier" field.
func (m *UsageLogMutation) SetAccountRateMultiplier(f float64) {
m.account_rate_multiplier = &f
m.addaccount_rate_multiplier = nil
}
// AccountRateMultiplier returns the value of the "account_rate_multiplier" field in the mutation.
func (m *UsageLogMutation) AccountRateMultiplier() (r float64, exists bool) {
v := m.account_rate_multiplier
if v == nil {
return
}
return *v, true
}
// OldAccountRateMultiplier returns the old "account_rate_multiplier" field's value of the UsageLog entity.
// If the UsageLog 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 *UsageLogMutation) OldAccountRateMultiplier(ctx context.Context) (v *float64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldAccountRateMultiplier is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldAccountRateMultiplier requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldAccountRateMultiplier: %w", err)
}
return oldValue.AccountRateMultiplier, nil
}
// AddAccountRateMultiplier adds f to the "account_rate_multiplier" field.
func (m *UsageLogMutation) AddAccountRateMultiplier(f float64) {
if m.addaccount_rate_multiplier != nil {
*m.addaccount_rate_multiplier += f
} else {
m.addaccount_rate_multiplier = &f
}
}
// AddedAccountRateMultiplier returns the value that was added to the "account_rate_multiplier" field in this mutation.
func (m *UsageLogMutation) AddedAccountRateMultiplier() (r float64, exists bool) {
v := m.addaccount_rate_multiplier
if v == nil {
return
}
return *v, true
}
// ClearAccountRateMultiplier clears the value of the "account_rate_multiplier" field.
func (m *UsageLogMutation) ClearAccountRateMultiplier() {
m.account_rate_multiplier = nil
m.addaccount_rate_multiplier = nil
m.clearedFields[usagelog.FieldAccountRateMultiplier] = struct{}{}
}
// AccountRateMultiplierCleared returns if the "account_rate_multiplier" field was cleared in this mutation.
func (m *UsageLogMutation) AccountRateMultiplierCleared() bool {
_, ok := m.clearedFields[usagelog.FieldAccountRateMultiplier]
return ok
}
// ResetAccountRateMultiplier resets all changes to the "account_rate_multiplier" field.
func (m *UsageLogMutation) ResetAccountRateMultiplier() {
m.account_rate_multiplier = nil
m.addaccount_rate_multiplier = nil
delete(m.clearedFields, usagelog.FieldAccountRateMultiplier)
}
// SetBillingType sets the "billing_type" field.
// SetBillingType sets the "billing_type" field.
func (m *UsageLogMutation) SetBillingType(i int8) {
func (m *UsageLogMutation) SetBillingType(i int8) {
m.billing_type = &i
m.billing_type = &i
...
@@ -11963,7 +12122,7 @@ func (m *UsageLogMutation) Type() string {
...
@@ -11963,7 +12122,7 @@ func (m *UsageLogMutation) 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 *UsageLogMutation) Fields() []string {
func (m *UsageLogMutation) Fields() []string {
fields := make([]string, 0,
29
)
fields := make([]string, 0,
30
)
if m.user != nil {
if m.user != nil {
fields = append(fields, usagelog.FieldUserID)
fields = append(fields, usagelog.FieldUserID)
}
}
...
@@ -12024,6 +12183,9 @@ func (m *UsageLogMutation) Fields() []string {
...
@@ -12024,6 +12183,9 @@ func (m *UsageLogMutation) Fields() []string {
if m.rate_multiplier != nil {
if m.rate_multiplier != nil {
fields = append(fields, usagelog.FieldRateMultiplier)
fields = append(fields, usagelog.FieldRateMultiplier)
}
}
if m.account_rate_multiplier != nil {
fields = append(fields, usagelog.FieldAccountRateMultiplier)
}
if m.billing_type != nil {
if m.billing_type != nil {
fields = append(fields, usagelog.FieldBillingType)
fields = append(fields, usagelog.FieldBillingType)
}
}
...
@@ -12099,6 +12261,8 @@ func (m *UsageLogMutation) Field(name string) (ent.Value, bool) {
...
@@ -12099,6 +12261,8 @@ func (m *UsageLogMutation) Field(name string) (ent.Value, bool) {
return m.ActualCost()
return m.ActualCost()
case usagelog.FieldRateMultiplier:
case usagelog.FieldRateMultiplier:
return m.RateMultiplier()
return m.RateMultiplier()
case usagelog.FieldAccountRateMultiplier:
return m.AccountRateMultiplier()
case usagelog.FieldBillingType:
case usagelog.FieldBillingType:
return m.BillingType()
return m.BillingType()
case usagelog.FieldStream:
case usagelog.FieldStream:
...
@@ -12166,6 +12330,8 @@ func (m *UsageLogMutation) OldField(ctx context.Context, name string) (ent.Value
...
@@ -12166,6 +12330,8 @@ func (m *UsageLogMutation) OldField(ctx context.Context, name string) (ent.Value
return m.OldActualCost(ctx)
return m.OldActualCost(ctx)
case usagelog.FieldRateMultiplier:
case usagelog.FieldRateMultiplier:
return m.OldRateMultiplier(ctx)
return m.OldRateMultiplier(ctx)
case usagelog.FieldAccountRateMultiplier:
return m.OldAccountRateMultiplier(ctx)
case usagelog.FieldBillingType:
case usagelog.FieldBillingType:
return m.OldBillingType(ctx)
return m.OldBillingType(ctx)
case usagelog.FieldStream:
case usagelog.FieldStream:
...
@@ -12333,6 +12499,13 @@ func (m *UsageLogMutation) SetField(name string, value ent.Value) error {
...
@@ -12333,6 +12499,13 @@ func (m *UsageLogMutation) SetField(name string, value ent.Value) error {
}
}
m.SetRateMultiplier(v)
m.SetRateMultiplier(v)
return nil
return nil
case usagelog.FieldAccountRateMultiplier:
v, ok := value.(float64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetAccountRateMultiplier(v)
return nil
case usagelog.FieldBillingType:
case usagelog.FieldBillingType:
v, ok := value.(int8)
v, ok := value.(int8)
if !ok {
if !ok {
...
@@ -12443,6 +12616,9 @@ func (m *UsageLogMutation) AddedFields() []string {
...
@@ -12443,6 +12616,9 @@ func (m *UsageLogMutation) AddedFields() []string {
if m.addrate_multiplier != nil {
if m.addrate_multiplier != nil {
fields = append(fields, usagelog.FieldRateMultiplier)
fields = append(fields, usagelog.FieldRateMultiplier)
}
}
if m.addaccount_rate_multiplier != nil {
fields = append(fields, usagelog.FieldAccountRateMultiplier)
}
if m.addbilling_type != nil {
if m.addbilling_type != nil {
fields = append(fields, usagelog.FieldBillingType)
fields = append(fields, usagelog.FieldBillingType)
}
}
...
@@ -12489,6 +12665,8 @@ func (m *UsageLogMutation) AddedField(name string) (ent.Value, bool) {
...
@@ -12489,6 +12665,8 @@ func (m *UsageLogMutation) AddedField(name string) (ent.Value, bool) {
return m.AddedActualCost()
return m.AddedActualCost()
case usagelog.FieldRateMultiplier:
case usagelog.FieldRateMultiplier:
return m.AddedRateMultiplier()
return m.AddedRateMultiplier()
case usagelog.FieldAccountRateMultiplier:
return m.AddedAccountRateMultiplier()
case usagelog.FieldBillingType:
case usagelog.FieldBillingType:
return m.AddedBillingType()
return m.AddedBillingType()
case usagelog.FieldDurationMs:
case usagelog.FieldDurationMs:
...
@@ -12597,6 +12775,13 @@ func (m *UsageLogMutation) AddField(name string, value ent.Value) error {
...
@@ -12597,6 +12775,13 @@ func (m *UsageLogMutation) AddField(name string, value ent.Value) error {
}
}
m.AddRateMultiplier(v)
m.AddRateMultiplier(v)
return nil
return nil
case usagelog.FieldAccountRateMultiplier:
v, ok := value.(float64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddAccountRateMultiplier(v)
return nil
case usagelog.FieldBillingType:
case usagelog.FieldBillingType:
v, ok := value.(int8)
v, ok := value.(int8)
if !ok {
if !ok {
...
@@ -12639,6 +12824,9 @@ func (m *UsageLogMutation) ClearedFields() []string {
...
@@ -12639,6 +12824,9 @@ func (m *UsageLogMutation) ClearedFields() []string {
if m.FieldCleared(usagelog.FieldSubscriptionID) {
if m.FieldCleared(usagelog.FieldSubscriptionID) {
fields = append(fields, usagelog.FieldSubscriptionID)
fields = append(fields, usagelog.FieldSubscriptionID)
}
}
if m.FieldCleared(usagelog.FieldAccountRateMultiplier) {
fields = append(fields, usagelog.FieldAccountRateMultiplier)
}
if m.FieldCleared(usagelog.FieldDurationMs) {
if m.FieldCleared(usagelog.FieldDurationMs) {
fields = append(fields, usagelog.FieldDurationMs)
fields = append(fields, usagelog.FieldDurationMs)
}
}
...
@@ -12674,6 +12862,9 @@ func (m *UsageLogMutation) ClearField(name string) error {
...
@@ -12674,6 +12862,9 @@ func (m *UsageLogMutation) ClearField(name string) error {
case usagelog.FieldSubscriptionID:
case usagelog.FieldSubscriptionID:
m.ClearSubscriptionID()
m.ClearSubscriptionID()
return nil
return nil
case usagelog.FieldAccountRateMultiplier:
m.ClearAccountRateMultiplier()
return nil
case usagelog.FieldDurationMs:
case usagelog.FieldDurationMs:
m.ClearDurationMs()
m.ClearDurationMs()
return nil
return nil
...
@@ -12757,6 +12948,9 @@ func (m *UsageLogMutation) ResetField(name string) error {
...
@@ -12757,6 +12948,9 @@ func (m *UsageLogMutation) ResetField(name string) error {
case usagelog.FieldRateMultiplier:
case usagelog.FieldRateMultiplier:
m.ResetRateMultiplier()
m.ResetRateMultiplier()
return nil
return nil
case usagelog.FieldAccountRateMultiplier:
m.ResetAccountRateMultiplier()
return nil
case usagelog.FieldBillingType:
case usagelog.FieldBillingType:
m.ResetBillingType()
m.ResetBillingType()
return nil
return nil
...
...
backend/ent/runtime/runtime.go
View file @
2a5ef6d3
...
@@ -177,22 +177,26 @@ func init() {
...
@@ -177,22 +177,26 @@ func init() {
accountDescPriority
:=
accountFields
[
8
]
.
Descriptor
()
accountDescPriority
:=
accountFields
[
8
]
.
Descriptor
()
// account.DefaultPriority holds the default value on creation for the priority field.
// account.DefaultPriority holds the default value on creation for the priority field.
account
.
DefaultPriority
=
accountDescPriority
.
Default
.
(
int
)
account
.
DefaultPriority
=
accountDescPriority
.
Default
.
(
int
)
// accountDescRateMultiplier is the schema descriptor for rate_multiplier field.
accountDescRateMultiplier
:=
accountFields
[
9
]
.
Descriptor
()
// account.DefaultRateMultiplier holds the default value on creation for the rate_multiplier field.
account
.
DefaultRateMultiplier
=
accountDescRateMultiplier
.
Default
.
(
float64
)
// accountDescStatus is the schema descriptor for status field.
// accountDescStatus is the schema descriptor for status field.
accountDescStatus
:=
accountFields
[
9
]
.
Descriptor
()
accountDescStatus
:=
accountFields
[
10
]
.
Descriptor
()
// account.DefaultStatus holds the default value on creation for the status field.
// account.DefaultStatus holds the default value on creation for the status field.
account
.
DefaultStatus
=
accountDescStatus
.
Default
.
(
string
)
account
.
DefaultStatus
=
accountDescStatus
.
Default
.
(
string
)
// account.StatusValidator is a validator for the "status" field. It is called by the builders before save.
// account.StatusValidator is a validator for the "status" field. It is called by the builders before save.
account
.
StatusValidator
=
accountDescStatus
.
Validators
[
0
]
.
(
func
(
string
)
error
)
account
.
StatusValidator
=
accountDescStatus
.
Validators
[
0
]
.
(
func
(
string
)
error
)
// accountDescAutoPauseOnExpired is the schema descriptor for auto_pause_on_expired field.
// accountDescAutoPauseOnExpired is the schema descriptor for auto_pause_on_expired field.
accountDescAutoPauseOnExpired
:=
accountFields
[
1
3
]
.
Descriptor
()
accountDescAutoPauseOnExpired
:=
accountFields
[
1
4
]
.
Descriptor
()
// account.DefaultAutoPauseOnExpired holds the default value on creation for the auto_pause_on_expired field.
// account.DefaultAutoPauseOnExpired holds the default value on creation for the auto_pause_on_expired field.
account
.
DefaultAutoPauseOnExpired
=
accountDescAutoPauseOnExpired
.
Default
.
(
bool
)
account
.
DefaultAutoPauseOnExpired
=
accountDescAutoPauseOnExpired
.
Default
.
(
bool
)
// accountDescSchedulable is the schema descriptor for schedulable field.
// accountDescSchedulable is the schema descriptor for schedulable field.
accountDescSchedulable
:=
accountFields
[
1
4
]
.
Descriptor
()
accountDescSchedulable
:=
accountFields
[
1
5
]
.
Descriptor
()
// 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
0
]
.
Descriptor
()
accountDescSessionWindowStatus
:=
accountFields
[
2
1
]
.
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
()
...
@@ -578,31 +582,31 @@ func init() {
...
@@ -578,31 +582,31 @@ func init() {
// usagelog.DefaultRateMultiplier holds the default value on creation for the rate_multiplier field.
// usagelog.DefaultRateMultiplier holds the default value on creation for the rate_multiplier field.
usagelog
.
DefaultRateMultiplier
=
usagelogDescRateMultiplier
.
Default
.
(
float64
)
usagelog
.
DefaultRateMultiplier
=
usagelogDescRateMultiplier
.
Default
.
(
float64
)
// usagelogDescBillingType is the schema descriptor for billing_type field.
// usagelogDescBillingType is the schema descriptor for billing_type field.
usagelogDescBillingType
:=
usagelogFields
[
2
0
]
.
Descriptor
()
usagelogDescBillingType
:=
usagelogFields
[
2
1
]
.
Descriptor
()
// usagelog.DefaultBillingType holds the default value on creation for the billing_type field.
// usagelog.DefaultBillingType holds the default value on creation for the billing_type field.
usagelog
.
DefaultBillingType
=
usagelogDescBillingType
.
Default
.
(
int8
)
usagelog
.
DefaultBillingType
=
usagelogDescBillingType
.
Default
.
(
int8
)
// usagelogDescStream is the schema descriptor for stream field.
// usagelogDescStream is the schema descriptor for stream field.
usagelogDescStream
:=
usagelogFields
[
2
1
]
.
Descriptor
()
usagelogDescStream
:=
usagelogFields
[
2
2
]
.
Descriptor
()
// usagelog.DefaultStream holds the default value on creation for the stream field.
// usagelog.DefaultStream holds the default value on creation for the stream field.
usagelog
.
DefaultStream
=
usagelogDescStream
.
Default
.
(
bool
)
usagelog
.
DefaultStream
=
usagelogDescStream
.
Default
.
(
bool
)
// usagelogDescUserAgent is the schema descriptor for user_agent field.
// usagelogDescUserAgent is the schema descriptor for user_agent field.
usagelogDescUserAgent
:=
usagelogFields
[
2
4
]
.
Descriptor
()
usagelogDescUserAgent
:=
usagelogFields
[
2
5
]
.
Descriptor
()
// usagelog.UserAgentValidator is a validator for the "user_agent" field. It is called by the builders before save.
// usagelog.UserAgentValidator is a validator for the "user_agent" field. It is called by the builders before save.
usagelog
.
UserAgentValidator
=
usagelogDescUserAgent
.
Validators
[
0
]
.
(
func
(
string
)
error
)
usagelog
.
UserAgentValidator
=
usagelogDescUserAgent
.
Validators
[
0
]
.
(
func
(
string
)
error
)
// usagelogDescIPAddress is the schema descriptor for ip_address field.
// usagelogDescIPAddress is the schema descriptor for ip_address field.
usagelogDescIPAddress
:=
usagelogFields
[
2
5
]
.
Descriptor
()
usagelogDescIPAddress
:=
usagelogFields
[
2
6
]
.
Descriptor
()
// usagelog.IPAddressValidator is a validator for the "ip_address" field. It is called by the builders before save.
// usagelog.IPAddressValidator is a validator for the "ip_address" field. It is called by the builders before save.
usagelog
.
IPAddressValidator
=
usagelogDescIPAddress
.
Validators
[
0
]
.
(
func
(
string
)
error
)
usagelog
.
IPAddressValidator
=
usagelogDescIPAddress
.
Validators
[
0
]
.
(
func
(
string
)
error
)
// usagelogDescImageCount is the schema descriptor for image_count field.
// usagelogDescImageCount is the schema descriptor for image_count field.
usagelogDescImageCount
:=
usagelogFields
[
2
6
]
.
Descriptor
()
usagelogDescImageCount
:=
usagelogFields
[
2
7
]
.
Descriptor
()
// usagelog.DefaultImageCount holds the default value on creation for the image_count field.
// usagelog.DefaultImageCount holds the default value on creation for the image_count field.
usagelog
.
DefaultImageCount
=
usagelogDescImageCount
.
Default
.
(
int
)
usagelog
.
DefaultImageCount
=
usagelogDescImageCount
.
Default
.
(
int
)
// usagelogDescImageSize is the schema descriptor for image_size field.
// usagelogDescImageSize is the schema descriptor for image_size field.
usagelogDescImageSize
:=
usagelogFields
[
2
7
]
.
Descriptor
()
usagelogDescImageSize
:=
usagelogFields
[
2
8
]
.
Descriptor
()
// usagelog.ImageSizeValidator is a validator for the "image_size" field. It is called by the builders before save.
// usagelog.ImageSizeValidator is a validator for the "image_size" field. It is called by the builders before save.
usagelog
.
ImageSizeValidator
=
usagelogDescImageSize
.
Validators
[
0
]
.
(
func
(
string
)
error
)
usagelog
.
ImageSizeValidator
=
usagelogDescImageSize
.
Validators
[
0
]
.
(
func
(
string
)
error
)
// usagelogDescCreatedAt is the schema descriptor for created_at field.
// usagelogDescCreatedAt is the schema descriptor for created_at field.
usagelogDescCreatedAt
:=
usagelogFields
[
2
8
]
.
Descriptor
()
usagelogDescCreatedAt
:=
usagelogFields
[
2
9
]
.
Descriptor
()
// usagelog.DefaultCreatedAt holds the default value on creation for the created_at field.
// usagelog.DefaultCreatedAt holds the default value on creation for the created_at field.
usagelog
.
DefaultCreatedAt
=
usagelogDescCreatedAt
.
Default
.
(
func
()
time
.
Time
)
usagelog
.
DefaultCreatedAt
=
usagelogDescCreatedAt
.
Default
.
(
func
()
time
.
Time
)
userMixin
:=
schema
.
User
{}
.
Mixin
()
userMixin
:=
schema
.
User
{}
.
Mixin
()
...
...
backend/ent/schema/account.go
View file @
2a5ef6d3
...
@@ -102,6 +102,12 @@ func (Account) Fields() []ent.Field {
...
@@ -102,6 +102,12 @@ func (Account) Fields() []ent.Field {
field
.
Int
(
"priority"
)
.
field
.
Int
(
"priority"
)
.
Default
(
50
),
Default
(
50
),
// rate_multiplier: 账号计费倍率(>=0,允许 0 表示该账号计费为 0)
// 仅影响账号维度计费口径,不影响用户/API Key 扣费(分组倍率)
field
.
Float
(
"rate_multiplier"
)
.
SchemaType
(
map
[
string
]
string
{
dialect
.
Postgres
:
"decimal(10,4)"
})
.
Default
(
1.0
),
// status: 账户状态,如 "active", "error", "disabled"
// status: 账户状态,如 "active", "error", "disabled"
field
.
String
(
"status"
)
.
field
.
String
(
"status"
)
.
MaxLen
(
20
)
.
MaxLen
(
20
)
.
...
...
backend/ent/schema/usage_log.go
View file @
2a5ef6d3
...
@@ -85,6 +85,12 @@ func (UsageLog) Fields() []ent.Field {
...
@@ -85,6 +85,12 @@ func (UsageLog) Fields() []ent.Field {
Default
(
1
)
.
Default
(
1
)
.
SchemaType
(
map
[
string
]
string
{
dialect
.
Postgres
:
"decimal(10,4)"
}),
SchemaType
(
map
[
string
]
string
{
dialect
.
Postgres
:
"decimal(10,4)"
}),
// account_rate_multiplier: 账号计费倍率快照(NULL 表示按 1.0 处理)
field
.
Float
(
"account_rate_multiplier"
)
.
Optional
()
.
Nillable
()
.
SchemaType
(
map
[
string
]
string
{
dialect
.
Postgres
:
"decimal(10,4)"
}),
// 其他字段
// 其他字段
field
.
Int8
(
"billing_type"
)
.
field
.
Int8
(
"billing_type"
)
.
Default
(
0
),
Default
(
0
),
...
...
backend/ent/usagelog.go
View file @
2a5ef6d3
...
@@ -62,6 +62,8 @@ type UsageLog struct {
...
@@ -62,6 +62,8 @@ type UsageLog struct {
ActualCost
float64
`json:"actual_cost,omitempty"`
ActualCost
float64
`json:"actual_cost,omitempty"`
// RateMultiplier holds the value of the "rate_multiplier" field.
// RateMultiplier holds the value of the "rate_multiplier" field.
RateMultiplier
float64
`json:"rate_multiplier,omitempty"`
RateMultiplier
float64
`json:"rate_multiplier,omitempty"`
// AccountRateMultiplier holds the value of the "account_rate_multiplier" field.
AccountRateMultiplier
*
float64
`json:"account_rate_multiplier,omitempty"`
// BillingType holds the value of the "billing_type" field.
// BillingType holds the value of the "billing_type" field.
BillingType
int8
`json:"billing_type,omitempty"`
BillingType
int8
`json:"billing_type,omitempty"`
// Stream holds the value of the "stream" field.
// Stream holds the value of the "stream" field.
...
@@ -165,7 +167,7 @@ func (*UsageLog) scanValues(columns []string) ([]any, error) {
...
@@ -165,7 +167,7 @@ func (*UsageLog) scanValues(columns []string) ([]any, error) {
switch
columns
[
i
]
{
switch
columns
[
i
]
{
case
usagelog
.
FieldStream
:
case
usagelog
.
FieldStream
:
values
[
i
]
=
new
(
sql
.
NullBool
)
values
[
i
]
=
new
(
sql
.
NullBool
)
case
usagelog
.
FieldInputCost
,
usagelog
.
FieldOutputCost
,
usagelog
.
FieldCacheCreationCost
,
usagelog
.
FieldCacheReadCost
,
usagelog
.
FieldTotalCost
,
usagelog
.
FieldActualCost
,
usagelog
.
FieldRateMultiplier
:
case
usagelog
.
FieldInputCost
,
usagelog
.
FieldOutputCost
,
usagelog
.
FieldCacheCreationCost
,
usagelog
.
FieldCacheReadCost
,
usagelog
.
FieldTotalCost
,
usagelog
.
FieldActualCost
,
usagelog
.
FieldRateMultiplier
,
usagelog
.
FieldAccountRateMultiplier
:
values
[
i
]
=
new
(
sql
.
NullFloat64
)
values
[
i
]
=
new
(
sql
.
NullFloat64
)
case
usagelog
.
FieldID
,
usagelog
.
FieldUserID
,
usagelog
.
FieldAPIKeyID
,
usagelog
.
FieldAccountID
,
usagelog
.
FieldGroupID
,
usagelog
.
FieldSubscriptionID
,
usagelog
.
FieldInputTokens
,
usagelog
.
FieldOutputTokens
,
usagelog
.
FieldCacheCreationTokens
,
usagelog
.
FieldCacheReadTokens
,
usagelog
.
FieldCacheCreation5mTokens
,
usagelog
.
FieldCacheCreation1hTokens
,
usagelog
.
FieldBillingType
,
usagelog
.
FieldDurationMs
,
usagelog
.
FieldFirstTokenMs
,
usagelog
.
FieldImageCount
:
case
usagelog
.
FieldID
,
usagelog
.
FieldUserID
,
usagelog
.
FieldAPIKeyID
,
usagelog
.
FieldAccountID
,
usagelog
.
FieldGroupID
,
usagelog
.
FieldSubscriptionID
,
usagelog
.
FieldInputTokens
,
usagelog
.
FieldOutputTokens
,
usagelog
.
FieldCacheCreationTokens
,
usagelog
.
FieldCacheReadTokens
,
usagelog
.
FieldCacheCreation5mTokens
,
usagelog
.
FieldCacheCreation1hTokens
,
usagelog
.
FieldBillingType
,
usagelog
.
FieldDurationMs
,
usagelog
.
FieldFirstTokenMs
,
usagelog
.
FieldImageCount
:
values
[
i
]
=
new
(
sql
.
NullInt64
)
values
[
i
]
=
new
(
sql
.
NullInt64
)
...
@@ -316,6 +318,13 @@ func (_m *UsageLog) assignValues(columns []string, values []any) error {
...
@@ -316,6 +318,13 @@ func (_m *UsageLog) assignValues(columns []string, values []any) error {
}
else
if
value
.
Valid
{
}
else
if
value
.
Valid
{
_m
.
RateMultiplier
=
value
.
Float64
_m
.
RateMultiplier
=
value
.
Float64
}
}
case
usagelog
.
FieldAccountRateMultiplier
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullFloat64
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field account_rate_multiplier"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
AccountRateMultiplier
=
new
(
float64
)
*
_m
.
AccountRateMultiplier
=
value
.
Float64
}
case
usagelog
.
FieldBillingType
:
case
usagelog
.
FieldBillingType
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullInt64
);
!
ok
{
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullInt64
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field billing_type"
,
values
[
i
])
return
fmt
.
Errorf
(
"unexpected type %T for field billing_type"
,
values
[
i
])
...
@@ -500,6 +509,11 @@ func (_m *UsageLog) String() string {
...
@@ -500,6 +509,11 @@ func (_m *UsageLog) String() string {
builder
.
WriteString
(
"rate_multiplier="
)
builder
.
WriteString
(
"rate_multiplier="
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"%v"
,
_m
.
RateMultiplier
))
builder
.
WriteString
(
fmt
.
Sprintf
(
"%v"
,
_m
.
RateMultiplier
))
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
", "
)
if
v
:=
_m
.
AccountRateMultiplier
;
v
!=
nil
{
builder
.
WriteString
(
"account_rate_multiplier="
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"%v"
,
*
v
))
}
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"billing_type="
)
builder
.
WriteString
(
"billing_type="
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"%v"
,
_m
.
BillingType
))
builder
.
WriteString
(
fmt
.
Sprintf
(
"%v"
,
_m
.
BillingType
))
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
", "
)
...
...
backend/ent/usagelog/usagelog.go
View file @
2a5ef6d3
...
@@ -54,6 +54,8 @@ const (
...
@@ -54,6 +54,8 @@ const (
FieldActualCost
=
"actual_cost"
FieldActualCost
=
"actual_cost"
// FieldRateMultiplier holds the string denoting the rate_multiplier field in the database.
// FieldRateMultiplier holds the string denoting the rate_multiplier field in the database.
FieldRateMultiplier
=
"rate_multiplier"
FieldRateMultiplier
=
"rate_multiplier"
// FieldAccountRateMultiplier holds the string denoting the account_rate_multiplier field in the database.
FieldAccountRateMultiplier
=
"account_rate_multiplier"
// FieldBillingType holds the string denoting the billing_type field in the database.
// FieldBillingType holds the string denoting the billing_type field in the database.
FieldBillingType
=
"billing_type"
FieldBillingType
=
"billing_type"
// FieldStream holds the string denoting the stream field in the database.
// FieldStream holds the string denoting the stream field in the database.
...
@@ -144,6 +146,7 @@ var Columns = []string{
...
@@ -144,6 +146,7 @@ var Columns = []string{
FieldTotalCost
,
FieldTotalCost
,
FieldActualCost
,
FieldActualCost
,
FieldRateMultiplier
,
FieldRateMultiplier
,
FieldAccountRateMultiplier
,
FieldBillingType
,
FieldBillingType
,
FieldStream
,
FieldStream
,
FieldDurationMs
,
FieldDurationMs
,
...
@@ -320,6 +323,11 @@ func ByRateMultiplier(opts ...sql.OrderTermOption) OrderOption {
...
@@ -320,6 +323,11 @@ func ByRateMultiplier(opts ...sql.OrderTermOption) OrderOption {
return
sql
.
OrderByField
(
FieldRateMultiplier
,
opts
...
)
.
ToFunc
()
return
sql
.
OrderByField
(
FieldRateMultiplier
,
opts
...
)
.
ToFunc
()
}
}
// ByAccountRateMultiplier orders the results by the account_rate_multiplier field.
func
ByAccountRateMultiplier
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldAccountRateMultiplier
,
opts
...
)
.
ToFunc
()
}
// ByBillingType orders the results by the billing_type field.
// ByBillingType orders the results by the billing_type field.
func
ByBillingType
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
func
ByBillingType
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldBillingType
,
opts
...
)
.
ToFunc
()
return
sql
.
OrderByField
(
FieldBillingType
,
opts
...
)
.
ToFunc
()
...
...
backend/ent/usagelog/where.go
View file @
2a5ef6d3
...
@@ -155,6 +155,11 @@ func RateMultiplier(v float64) predicate.UsageLog {
...
@@ -155,6 +155,11 @@ func RateMultiplier(v float64) predicate.UsageLog {
return
predicate
.
UsageLog
(
sql
.
FieldEQ
(
FieldRateMultiplier
,
v
))
return
predicate
.
UsageLog
(
sql
.
FieldEQ
(
FieldRateMultiplier
,
v
))
}
}
// AccountRateMultiplier applies equality check predicate on the "account_rate_multiplier" field. It's identical to AccountRateMultiplierEQ.
func
AccountRateMultiplier
(
v
float64
)
predicate
.
UsageLog
{
return
predicate
.
UsageLog
(
sql
.
FieldEQ
(
FieldAccountRateMultiplier
,
v
))
}
// BillingType applies equality check predicate on the "billing_type" field. It's identical to BillingTypeEQ.
// BillingType applies equality check predicate on the "billing_type" field. It's identical to BillingTypeEQ.
func
BillingType
(
v
int8
)
predicate
.
UsageLog
{
func
BillingType
(
v
int8
)
predicate
.
UsageLog
{
return
predicate
.
UsageLog
(
sql
.
FieldEQ
(
FieldBillingType
,
v
))
return
predicate
.
UsageLog
(
sql
.
FieldEQ
(
FieldBillingType
,
v
))
...
@@ -970,6 +975,56 @@ func RateMultiplierLTE(v float64) predicate.UsageLog {
...
@@ -970,6 +975,56 @@ func RateMultiplierLTE(v float64) predicate.UsageLog {
return
predicate
.
UsageLog
(
sql
.
FieldLTE
(
FieldRateMultiplier
,
v
))
return
predicate
.
UsageLog
(
sql
.
FieldLTE
(
FieldRateMultiplier
,
v
))
}
}
// AccountRateMultiplierEQ applies the EQ predicate on the "account_rate_multiplier" field.
func
AccountRateMultiplierEQ
(
v
float64
)
predicate
.
UsageLog
{
return
predicate
.
UsageLog
(
sql
.
FieldEQ
(
FieldAccountRateMultiplier
,
v
))
}
// AccountRateMultiplierNEQ applies the NEQ predicate on the "account_rate_multiplier" field.
func
AccountRateMultiplierNEQ
(
v
float64
)
predicate
.
UsageLog
{
return
predicate
.
UsageLog
(
sql
.
FieldNEQ
(
FieldAccountRateMultiplier
,
v
))
}
// AccountRateMultiplierIn applies the In predicate on the "account_rate_multiplier" field.
func
AccountRateMultiplierIn
(
vs
...
float64
)
predicate
.
UsageLog
{
return
predicate
.
UsageLog
(
sql
.
FieldIn
(
FieldAccountRateMultiplier
,
vs
...
))
}
// AccountRateMultiplierNotIn applies the NotIn predicate on the "account_rate_multiplier" field.
func
AccountRateMultiplierNotIn
(
vs
...
float64
)
predicate
.
UsageLog
{
return
predicate
.
UsageLog
(
sql
.
FieldNotIn
(
FieldAccountRateMultiplier
,
vs
...
))
}
// AccountRateMultiplierGT applies the GT predicate on the "account_rate_multiplier" field.
func
AccountRateMultiplierGT
(
v
float64
)
predicate
.
UsageLog
{
return
predicate
.
UsageLog
(
sql
.
FieldGT
(
FieldAccountRateMultiplier
,
v
))
}
// AccountRateMultiplierGTE applies the GTE predicate on the "account_rate_multiplier" field.
func
AccountRateMultiplierGTE
(
v
float64
)
predicate
.
UsageLog
{
return
predicate
.
UsageLog
(
sql
.
FieldGTE
(
FieldAccountRateMultiplier
,
v
))
}
// AccountRateMultiplierLT applies the LT predicate on the "account_rate_multiplier" field.
func
AccountRateMultiplierLT
(
v
float64
)
predicate
.
UsageLog
{
return
predicate
.
UsageLog
(
sql
.
FieldLT
(
FieldAccountRateMultiplier
,
v
))
}
// AccountRateMultiplierLTE applies the LTE predicate on the "account_rate_multiplier" field.
func
AccountRateMultiplierLTE
(
v
float64
)
predicate
.
UsageLog
{
return
predicate
.
UsageLog
(
sql
.
FieldLTE
(
FieldAccountRateMultiplier
,
v
))
}
// AccountRateMultiplierIsNil applies the IsNil predicate on the "account_rate_multiplier" field.
func
AccountRateMultiplierIsNil
()
predicate
.
UsageLog
{
return
predicate
.
UsageLog
(
sql
.
FieldIsNull
(
FieldAccountRateMultiplier
))
}
// AccountRateMultiplierNotNil applies the NotNil predicate on the "account_rate_multiplier" field.
func
AccountRateMultiplierNotNil
()
predicate
.
UsageLog
{
return
predicate
.
UsageLog
(
sql
.
FieldNotNull
(
FieldAccountRateMultiplier
))
}
// BillingTypeEQ applies the EQ predicate on the "billing_type" field.
// BillingTypeEQ applies the EQ predicate on the "billing_type" field.
func
BillingTypeEQ
(
v
int8
)
predicate
.
UsageLog
{
func
BillingTypeEQ
(
v
int8
)
predicate
.
UsageLog
{
return
predicate
.
UsageLog
(
sql
.
FieldEQ
(
FieldBillingType
,
v
))
return
predicate
.
UsageLog
(
sql
.
FieldEQ
(
FieldBillingType
,
v
))
...
...
backend/ent/usagelog_create.go
View file @
2a5ef6d3
...
@@ -267,6 +267,20 @@ func (_c *UsageLogCreate) SetNillableRateMultiplier(v *float64) *UsageLogCreate
...
@@ -267,6 +267,20 @@ func (_c *UsageLogCreate) SetNillableRateMultiplier(v *float64) *UsageLogCreate
return
_c
return
_c
}
}
// SetAccountRateMultiplier sets the "account_rate_multiplier" field.
func
(
_c
*
UsageLogCreate
)
SetAccountRateMultiplier
(
v
float64
)
*
UsageLogCreate
{
_c
.
mutation
.
SetAccountRateMultiplier
(
v
)
return
_c
}
// SetNillableAccountRateMultiplier sets the "account_rate_multiplier" field if the given value is not nil.
func
(
_c
*
UsageLogCreate
)
SetNillableAccountRateMultiplier
(
v
*
float64
)
*
UsageLogCreate
{
if
v
!=
nil
{
_c
.
SetAccountRateMultiplier
(
*
v
)
}
return
_c
}
// SetBillingType sets the "billing_type" field.
// SetBillingType sets the "billing_type" field.
func
(
_c
*
UsageLogCreate
)
SetBillingType
(
v
int8
)
*
UsageLogCreate
{
func
(
_c
*
UsageLogCreate
)
SetBillingType
(
v
int8
)
*
UsageLogCreate
{
_c
.
mutation
.
SetBillingType
(
v
)
_c
.
mutation
.
SetBillingType
(
v
)
...
@@ -712,6 +726,10 @@ func (_c *UsageLogCreate) createSpec() (*UsageLog, *sqlgraph.CreateSpec) {
...
@@ -712,6 +726,10 @@ func (_c *UsageLogCreate) createSpec() (*UsageLog, *sqlgraph.CreateSpec) {
_spec
.
SetField
(
usagelog
.
FieldRateMultiplier
,
field
.
TypeFloat64
,
value
)
_spec
.
SetField
(
usagelog
.
FieldRateMultiplier
,
field
.
TypeFloat64
,
value
)
_node
.
RateMultiplier
=
value
_node
.
RateMultiplier
=
value
}
}
if
value
,
ok
:=
_c
.
mutation
.
AccountRateMultiplier
();
ok
{
_spec
.
SetField
(
usagelog
.
FieldAccountRateMultiplier
,
field
.
TypeFloat64
,
value
)
_node
.
AccountRateMultiplier
=
&
value
}
if
value
,
ok
:=
_c
.
mutation
.
BillingType
();
ok
{
if
value
,
ok
:=
_c
.
mutation
.
BillingType
();
ok
{
_spec
.
SetField
(
usagelog
.
FieldBillingType
,
field
.
TypeInt8
,
value
)
_spec
.
SetField
(
usagelog
.
FieldBillingType
,
field
.
TypeInt8
,
value
)
_node
.
BillingType
=
value
_node
.
BillingType
=
value
...
@@ -1215,6 +1233,30 @@ func (u *UsageLogUpsert) AddRateMultiplier(v float64) *UsageLogUpsert {
...
@@ -1215,6 +1233,30 @@ func (u *UsageLogUpsert) AddRateMultiplier(v float64) *UsageLogUpsert {
return
u
return
u
}
}
// SetAccountRateMultiplier sets the "account_rate_multiplier" field.
func
(
u
*
UsageLogUpsert
)
SetAccountRateMultiplier
(
v
float64
)
*
UsageLogUpsert
{
u
.
Set
(
usagelog
.
FieldAccountRateMultiplier
,
v
)
return
u
}
// UpdateAccountRateMultiplier sets the "account_rate_multiplier" field to the value that was provided on create.
func
(
u
*
UsageLogUpsert
)
UpdateAccountRateMultiplier
()
*
UsageLogUpsert
{
u
.
SetExcluded
(
usagelog
.
FieldAccountRateMultiplier
)
return
u
}
// AddAccountRateMultiplier adds v to the "account_rate_multiplier" field.
func
(
u
*
UsageLogUpsert
)
AddAccountRateMultiplier
(
v
float64
)
*
UsageLogUpsert
{
u
.
Add
(
usagelog
.
FieldAccountRateMultiplier
,
v
)
return
u
}
// ClearAccountRateMultiplier clears the value of the "account_rate_multiplier" field.
func
(
u
*
UsageLogUpsert
)
ClearAccountRateMultiplier
()
*
UsageLogUpsert
{
u
.
SetNull
(
usagelog
.
FieldAccountRateMultiplier
)
return
u
}
// SetBillingType sets the "billing_type" field.
// SetBillingType sets the "billing_type" field.
func
(
u
*
UsageLogUpsert
)
SetBillingType
(
v
int8
)
*
UsageLogUpsert
{
func
(
u
*
UsageLogUpsert
)
SetBillingType
(
v
int8
)
*
UsageLogUpsert
{
u
.
Set
(
usagelog
.
FieldBillingType
,
v
)
u
.
Set
(
usagelog
.
FieldBillingType
,
v
)
...
@@ -1795,6 +1837,34 @@ func (u *UsageLogUpsertOne) UpdateRateMultiplier() *UsageLogUpsertOne {
...
@@ -1795,6 +1837,34 @@ func (u *UsageLogUpsertOne) UpdateRateMultiplier() *UsageLogUpsertOne {
})
})
}
}
// SetAccountRateMultiplier sets the "account_rate_multiplier" field.
func
(
u
*
UsageLogUpsertOne
)
SetAccountRateMultiplier
(
v
float64
)
*
UsageLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
UsageLogUpsert
)
{
s
.
SetAccountRateMultiplier
(
v
)
})
}
// AddAccountRateMultiplier adds v to the "account_rate_multiplier" field.
func
(
u
*
UsageLogUpsertOne
)
AddAccountRateMultiplier
(
v
float64
)
*
UsageLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
UsageLogUpsert
)
{
s
.
AddAccountRateMultiplier
(
v
)
})
}
// UpdateAccountRateMultiplier sets the "account_rate_multiplier" field to the value that was provided on create.
func
(
u
*
UsageLogUpsertOne
)
UpdateAccountRateMultiplier
()
*
UsageLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
UsageLogUpsert
)
{
s
.
UpdateAccountRateMultiplier
()
})
}
// ClearAccountRateMultiplier clears the value of the "account_rate_multiplier" field.
func
(
u
*
UsageLogUpsertOne
)
ClearAccountRateMultiplier
()
*
UsageLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
UsageLogUpsert
)
{
s
.
ClearAccountRateMultiplier
()
})
}
// SetBillingType sets the "billing_type" field.
// SetBillingType sets the "billing_type" field.
func
(
u
*
UsageLogUpsertOne
)
SetBillingType
(
v
int8
)
*
UsageLogUpsertOne
{
func
(
u
*
UsageLogUpsertOne
)
SetBillingType
(
v
int8
)
*
UsageLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
UsageLogUpsert
)
{
return
u
.
Update
(
func
(
s
*
UsageLogUpsert
)
{
...
@@ -2566,6 +2636,34 @@ func (u *UsageLogUpsertBulk) UpdateRateMultiplier() *UsageLogUpsertBulk {
...
@@ -2566,6 +2636,34 @@ func (u *UsageLogUpsertBulk) UpdateRateMultiplier() *UsageLogUpsertBulk {
})
})
}
}
// SetAccountRateMultiplier sets the "account_rate_multiplier" field.
func
(
u
*
UsageLogUpsertBulk
)
SetAccountRateMultiplier
(
v
float64
)
*
UsageLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
UsageLogUpsert
)
{
s
.
SetAccountRateMultiplier
(
v
)
})
}
// AddAccountRateMultiplier adds v to the "account_rate_multiplier" field.
func
(
u
*
UsageLogUpsertBulk
)
AddAccountRateMultiplier
(
v
float64
)
*
UsageLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
UsageLogUpsert
)
{
s
.
AddAccountRateMultiplier
(
v
)
})
}
// UpdateAccountRateMultiplier sets the "account_rate_multiplier" field to the value that was provided on create.
func
(
u
*
UsageLogUpsertBulk
)
UpdateAccountRateMultiplier
()
*
UsageLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
UsageLogUpsert
)
{
s
.
UpdateAccountRateMultiplier
()
})
}
// ClearAccountRateMultiplier clears the value of the "account_rate_multiplier" field.
func
(
u
*
UsageLogUpsertBulk
)
ClearAccountRateMultiplier
()
*
UsageLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
UsageLogUpsert
)
{
s
.
ClearAccountRateMultiplier
()
})
}
// SetBillingType sets the "billing_type" field.
// SetBillingType sets the "billing_type" field.
func
(
u
*
UsageLogUpsertBulk
)
SetBillingType
(
v
int8
)
*
UsageLogUpsertBulk
{
func
(
u
*
UsageLogUpsertBulk
)
SetBillingType
(
v
int8
)
*
UsageLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
UsageLogUpsert
)
{
return
u
.
Update
(
func
(
s
*
UsageLogUpsert
)
{
...
...
backend/ent/usagelog_update.go
View file @
2a5ef6d3
...
@@ -415,6 +415,33 @@ func (_u *UsageLogUpdate) AddRateMultiplier(v float64) *UsageLogUpdate {
...
@@ -415,6 +415,33 @@ func (_u *UsageLogUpdate) AddRateMultiplier(v float64) *UsageLogUpdate {
return
_u
return
_u
}
}
// SetAccountRateMultiplier sets the "account_rate_multiplier" field.
func
(
_u
*
UsageLogUpdate
)
SetAccountRateMultiplier
(
v
float64
)
*
UsageLogUpdate
{
_u
.
mutation
.
ResetAccountRateMultiplier
()
_u
.
mutation
.
SetAccountRateMultiplier
(
v
)
return
_u
}
// SetNillableAccountRateMultiplier sets the "account_rate_multiplier" field if the given value is not nil.
func
(
_u
*
UsageLogUpdate
)
SetNillableAccountRateMultiplier
(
v
*
float64
)
*
UsageLogUpdate
{
if
v
!=
nil
{
_u
.
SetAccountRateMultiplier
(
*
v
)
}
return
_u
}
// AddAccountRateMultiplier adds value to the "account_rate_multiplier" field.
func
(
_u
*
UsageLogUpdate
)
AddAccountRateMultiplier
(
v
float64
)
*
UsageLogUpdate
{
_u
.
mutation
.
AddAccountRateMultiplier
(
v
)
return
_u
}
// ClearAccountRateMultiplier clears the value of the "account_rate_multiplier" field.
func
(
_u
*
UsageLogUpdate
)
ClearAccountRateMultiplier
()
*
UsageLogUpdate
{
_u
.
mutation
.
ClearAccountRateMultiplier
()
return
_u
}
// SetBillingType sets the "billing_type" field.
// SetBillingType sets the "billing_type" field.
func
(
_u
*
UsageLogUpdate
)
SetBillingType
(
v
int8
)
*
UsageLogUpdate
{
func
(
_u
*
UsageLogUpdate
)
SetBillingType
(
v
int8
)
*
UsageLogUpdate
{
_u
.
mutation
.
ResetBillingType
()
_u
.
mutation
.
ResetBillingType
()
...
@@ -807,6 +834,15 @@ func (_u *UsageLogUpdate) sqlSave(ctx context.Context) (_node int, err error) {
...
@@ -807,6 +834,15 @@ func (_u *UsageLogUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if
value
,
ok
:=
_u
.
mutation
.
AddedRateMultiplier
();
ok
{
if
value
,
ok
:=
_u
.
mutation
.
AddedRateMultiplier
();
ok
{
_spec
.
AddField
(
usagelog
.
FieldRateMultiplier
,
field
.
TypeFloat64
,
value
)
_spec
.
AddField
(
usagelog
.
FieldRateMultiplier
,
field
.
TypeFloat64
,
value
)
}
}
if
value
,
ok
:=
_u
.
mutation
.
AccountRateMultiplier
();
ok
{
_spec
.
SetField
(
usagelog
.
FieldAccountRateMultiplier
,
field
.
TypeFloat64
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
AddedAccountRateMultiplier
();
ok
{
_spec
.
AddField
(
usagelog
.
FieldAccountRateMultiplier
,
field
.
TypeFloat64
,
value
)
}
if
_u
.
mutation
.
AccountRateMultiplierCleared
()
{
_spec
.
ClearField
(
usagelog
.
FieldAccountRateMultiplier
,
field
.
TypeFloat64
)
}
if
value
,
ok
:=
_u
.
mutation
.
BillingType
();
ok
{
if
value
,
ok
:=
_u
.
mutation
.
BillingType
();
ok
{
_spec
.
SetField
(
usagelog
.
FieldBillingType
,
field
.
TypeInt8
,
value
)
_spec
.
SetField
(
usagelog
.
FieldBillingType
,
field
.
TypeInt8
,
value
)
}
}
...
@@ -1406,6 +1442,33 @@ func (_u *UsageLogUpdateOne) AddRateMultiplier(v float64) *UsageLogUpdateOne {
...
@@ -1406,6 +1442,33 @@ func (_u *UsageLogUpdateOne) AddRateMultiplier(v float64) *UsageLogUpdateOne {
return
_u
return
_u
}
}
// SetAccountRateMultiplier sets the "account_rate_multiplier" field.
func
(
_u
*
UsageLogUpdateOne
)
SetAccountRateMultiplier
(
v
float64
)
*
UsageLogUpdateOne
{
_u
.
mutation
.
ResetAccountRateMultiplier
()
_u
.
mutation
.
SetAccountRateMultiplier
(
v
)
return
_u
}
// SetNillableAccountRateMultiplier sets the "account_rate_multiplier" field if the given value is not nil.
func
(
_u
*
UsageLogUpdateOne
)
SetNillableAccountRateMultiplier
(
v
*
float64
)
*
UsageLogUpdateOne
{
if
v
!=
nil
{
_u
.
SetAccountRateMultiplier
(
*
v
)
}
return
_u
}
// AddAccountRateMultiplier adds value to the "account_rate_multiplier" field.
func
(
_u
*
UsageLogUpdateOne
)
AddAccountRateMultiplier
(
v
float64
)
*
UsageLogUpdateOne
{
_u
.
mutation
.
AddAccountRateMultiplier
(
v
)
return
_u
}
// ClearAccountRateMultiplier clears the value of the "account_rate_multiplier" field.
func
(
_u
*
UsageLogUpdateOne
)
ClearAccountRateMultiplier
()
*
UsageLogUpdateOne
{
_u
.
mutation
.
ClearAccountRateMultiplier
()
return
_u
}
// SetBillingType sets the "billing_type" field.
// SetBillingType sets the "billing_type" field.
func
(
_u
*
UsageLogUpdateOne
)
SetBillingType
(
v
int8
)
*
UsageLogUpdateOne
{
func
(
_u
*
UsageLogUpdateOne
)
SetBillingType
(
v
int8
)
*
UsageLogUpdateOne
{
_u
.
mutation
.
ResetBillingType
()
_u
.
mutation
.
ResetBillingType
()
...
@@ -1828,6 +1891,15 @@ func (_u *UsageLogUpdateOne) sqlSave(ctx context.Context) (_node *UsageLog, err
...
@@ -1828,6 +1891,15 @@ func (_u *UsageLogUpdateOne) sqlSave(ctx context.Context) (_node *UsageLog, err
if
value
,
ok
:=
_u
.
mutation
.
AddedRateMultiplier
();
ok
{
if
value
,
ok
:=
_u
.
mutation
.
AddedRateMultiplier
();
ok
{
_spec
.
AddField
(
usagelog
.
FieldRateMultiplier
,
field
.
TypeFloat64
,
value
)
_spec
.
AddField
(
usagelog
.
FieldRateMultiplier
,
field
.
TypeFloat64
,
value
)
}
}
if
value
,
ok
:=
_u
.
mutation
.
AccountRateMultiplier
();
ok
{
_spec
.
SetField
(
usagelog
.
FieldAccountRateMultiplier
,
field
.
TypeFloat64
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
AddedAccountRateMultiplier
();
ok
{
_spec
.
AddField
(
usagelog
.
FieldAccountRateMultiplier
,
field
.
TypeFloat64
,
value
)
}
if
_u
.
mutation
.
AccountRateMultiplierCleared
()
{
_spec
.
ClearField
(
usagelog
.
FieldAccountRateMultiplier
,
field
.
TypeFloat64
)
}
if
value
,
ok
:=
_u
.
mutation
.
BillingType
();
ok
{
if
value
,
ok
:=
_u
.
mutation
.
BillingType
();
ok
{
_spec
.
SetField
(
usagelog
.
FieldBillingType
,
field
.
TypeInt8
,
value
)
_spec
.
SetField
(
usagelog
.
FieldBillingType
,
field
.
TypeInt8
,
value
)
}
}
...
...
backend/internal/handler/admin/account_handler.go
View file @
2a5ef6d3
...
@@ -84,6 +84,7 @@ type CreateAccountRequest struct {
...
@@ -84,6 +84,7 @@ type CreateAccountRequest struct {
ProxyID
*
int64
`json:"proxy_id"`
ProxyID
*
int64
`json:"proxy_id"`
Concurrency
int
`json:"concurrency"`
Concurrency
int
`json:"concurrency"`
Priority
int
`json:"priority"`
Priority
int
`json:"priority"`
RateMultiplier
*
float64
`json:"rate_multiplier"`
GroupIDs
[]
int64
`json:"group_ids"`
GroupIDs
[]
int64
`json:"group_ids"`
ExpiresAt
*
int64
`json:"expires_at"`
ExpiresAt
*
int64
`json:"expires_at"`
AutoPauseOnExpired
*
bool
`json:"auto_pause_on_expired"`
AutoPauseOnExpired
*
bool
`json:"auto_pause_on_expired"`
...
@@ -101,6 +102,7 @@ type UpdateAccountRequest struct {
...
@@ -101,6 +102,7 @@ type UpdateAccountRequest struct {
ProxyID
*
int64
`json:"proxy_id"`
ProxyID
*
int64
`json:"proxy_id"`
Concurrency
*
int
`json:"concurrency"`
Concurrency
*
int
`json:"concurrency"`
Priority
*
int
`json:"priority"`
Priority
*
int
`json:"priority"`
RateMultiplier
*
float64
`json:"rate_multiplier"`
Status
string
`json:"status" binding:"omitempty,oneof=active inactive"`
Status
string
`json:"status" binding:"omitempty,oneof=active inactive"`
GroupIDs
*
[]
int64
`json:"group_ids"`
GroupIDs
*
[]
int64
`json:"group_ids"`
ExpiresAt
*
int64
`json:"expires_at"`
ExpiresAt
*
int64
`json:"expires_at"`
...
@@ -115,6 +117,7 @@ type BulkUpdateAccountsRequest struct {
...
@@ -115,6 +117,7 @@ type BulkUpdateAccountsRequest struct {
ProxyID
*
int64
`json:"proxy_id"`
ProxyID
*
int64
`json:"proxy_id"`
Concurrency
*
int
`json:"concurrency"`
Concurrency
*
int
`json:"concurrency"`
Priority
*
int
`json:"priority"`
Priority
*
int
`json:"priority"`
RateMultiplier
*
float64
`json:"rate_multiplier"`
Status
string
`json:"status" binding:"omitempty,oneof=active inactive error"`
Status
string
`json:"status" binding:"omitempty,oneof=active inactive error"`
Schedulable
*
bool
`json:"schedulable"`
Schedulable
*
bool
`json:"schedulable"`
GroupIDs
*
[]
int64
`json:"group_ids"`
GroupIDs
*
[]
int64
`json:"group_ids"`
...
@@ -199,6 +202,10 @@ func (h *AccountHandler) Create(c *gin.Context) {
...
@@ -199,6 +202,10 @@ func (h *AccountHandler) Create(c *gin.Context) {
response
.
BadRequest
(
c
,
"Invalid request: "
+
err
.
Error
())
response
.
BadRequest
(
c
,
"Invalid request: "
+
err
.
Error
())
return
return
}
}
if
req
.
RateMultiplier
!=
nil
&&
*
req
.
RateMultiplier
<
0
{
response
.
BadRequest
(
c
,
"rate_multiplier must be >= 0"
)
return
}
// 确定是否跳过混合渠道检查
// 确定是否跳过混合渠道检查
skipCheck
:=
req
.
ConfirmMixedChannelRisk
!=
nil
&&
*
req
.
ConfirmMixedChannelRisk
skipCheck
:=
req
.
ConfirmMixedChannelRisk
!=
nil
&&
*
req
.
ConfirmMixedChannelRisk
...
@@ -213,6 +220,7 @@ func (h *AccountHandler) Create(c *gin.Context) {
...
@@ -213,6 +220,7 @@ func (h *AccountHandler) Create(c *gin.Context) {
ProxyID
:
req
.
ProxyID
,
ProxyID
:
req
.
ProxyID
,
Concurrency
:
req
.
Concurrency
,
Concurrency
:
req
.
Concurrency
,
Priority
:
req
.
Priority
,
Priority
:
req
.
Priority
,
RateMultiplier
:
req
.
RateMultiplier
,
GroupIDs
:
req
.
GroupIDs
,
GroupIDs
:
req
.
GroupIDs
,
ExpiresAt
:
req
.
ExpiresAt
,
ExpiresAt
:
req
.
ExpiresAt
,
AutoPauseOnExpired
:
req
.
AutoPauseOnExpired
,
AutoPauseOnExpired
:
req
.
AutoPauseOnExpired
,
...
@@ -258,6 +266,10 @@ func (h *AccountHandler) Update(c *gin.Context) {
...
@@ -258,6 +266,10 @@ func (h *AccountHandler) Update(c *gin.Context) {
response
.
BadRequest
(
c
,
"Invalid request: "
+
err
.
Error
())
response
.
BadRequest
(
c
,
"Invalid request: "
+
err
.
Error
())
return
return
}
}
if
req
.
RateMultiplier
!=
nil
&&
*
req
.
RateMultiplier
<
0
{
response
.
BadRequest
(
c
,
"rate_multiplier must be >= 0"
)
return
}
// 确定是否跳过混合渠道检查
// 确定是否跳过混合渠道检查
skipCheck
:=
req
.
ConfirmMixedChannelRisk
!=
nil
&&
*
req
.
ConfirmMixedChannelRisk
skipCheck
:=
req
.
ConfirmMixedChannelRisk
!=
nil
&&
*
req
.
ConfirmMixedChannelRisk
...
@@ -271,6 +283,7 @@ func (h *AccountHandler) Update(c *gin.Context) {
...
@@ -271,6 +283,7 @@ func (h *AccountHandler) Update(c *gin.Context) {
ProxyID
:
req
.
ProxyID
,
ProxyID
:
req
.
ProxyID
,
Concurrency
:
req
.
Concurrency
,
// 指针类型,nil 表示未提供
Concurrency
:
req
.
Concurrency
,
// 指针类型,nil 表示未提供
Priority
:
req
.
Priority
,
// 指针类型,nil 表示未提供
Priority
:
req
.
Priority
,
// 指针类型,nil 表示未提供
RateMultiplier
:
req
.
RateMultiplier
,
Status
:
req
.
Status
,
Status
:
req
.
Status
,
GroupIDs
:
req
.
GroupIDs
,
GroupIDs
:
req
.
GroupIDs
,
ExpiresAt
:
req
.
ExpiresAt
,
ExpiresAt
:
req
.
ExpiresAt
,
...
@@ -652,6 +665,10 @@ func (h *AccountHandler) BulkUpdate(c *gin.Context) {
...
@@ -652,6 +665,10 @@ func (h *AccountHandler) BulkUpdate(c *gin.Context) {
response
.
BadRequest
(
c
,
"Invalid request: "
+
err
.
Error
())
response
.
BadRequest
(
c
,
"Invalid request: "
+
err
.
Error
())
return
return
}
}
if
req
.
RateMultiplier
!=
nil
&&
*
req
.
RateMultiplier
<
0
{
response
.
BadRequest
(
c
,
"rate_multiplier must be >= 0"
)
return
}
// 确定是否跳过混合渠道检查
// 确定是否跳过混合渠道检查
skipCheck
:=
req
.
ConfirmMixedChannelRisk
!=
nil
&&
*
req
.
ConfirmMixedChannelRisk
skipCheck
:=
req
.
ConfirmMixedChannelRisk
!=
nil
&&
*
req
.
ConfirmMixedChannelRisk
...
@@ -660,6 +677,7 @@ func (h *AccountHandler) BulkUpdate(c *gin.Context) {
...
@@ -660,6 +677,7 @@ func (h *AccountHandler) BulkUpdate(c *gin.Context) {
req
.
ProxyID
!=
nil
||
req
.
ProxyID
!=
nil
||
req
.
Concurrency
!=
nil
||
req
.
Concurrency
!=
nil
||
req
.
Priority
!=
nil
||
req
.
Priority
!=
nil
||
req
.
RateMultiplier
!=
nil
||
req
.
Status
!=
""
||
req
.
Status
!=
""
||
req
.
Schedulable
!=
nil
||
req
.
Schedulable
!=
nil
||
req
.
GroupIDs
!=
nil
||
req
.
GroupIDs
!=
nil
||
...
@@ -677,6 +695,7 @@ func (h *AccountHandler) BulkUpdate(c *gin.Context) {
...
@@ -677,6 +695,7 @@ func (h *AccountHandler) BulkUpdate(c *gin.Context) {
ProxyID
:
req
.
ProxyID
,
ProxyID
:
req
.
ProxyID
,
Concurrency
:
req
.
Concurrency
,
Concurrency
:
req
.
Concurrency
,
Priority
:
req
.
Priority
,
Priority
:
req
.
Priority
,
RateMultiplier
:
req
.
RateMultiplier
,
Status
:
req
.
Status
,
Status
:
req
.
Status
,
Schedulable
:
req
.
Schedulable
,
Schedulable
:
req
.
Schedulable
,
GroupIDs
:
req
.
GroupIDs
,
GroupIDs
:
req
.
GroupIDs
,
...
...
backend/internal/handler/dto/mappers.go
View file @
2a5ef6d3
...
@@ -125,6 +125,7 @@ func AccountFromServiceShallow(a *service.Account) *Account {
...
@@ -125,6 +125,7 @@ func AccountFromServiceShallow(a *service.Account) *Account {
ProxyID
:
a
.
ProxyID
,
ProxyID
:
a
.
ProxyID
,
Concurrency
:
a
.
Concurrency
,
Concurrency
:
a
.
Concurrency
,
Priority
:
a
.
Priority
,
Priority
:
a
.
Priority
,
RateMultiplier
:
a
.
BillingRateMultiplier
(),
Status
:
a
.
Status
,
Status
:
a
.
Status
,
ErrorMessage
:
a
.
ErrorMessage
,
ErrorMessage
:
a
.
ErrorMessage
,
LastUsedAt
:
a
.
LastUsedAt
,
LastUsedAt
:
a
.
LastUsedAt
,
...
@@ -279,6 +280,7 @@ func usageLogFromServiceBase(l *service.UsageLog, account *AccountSummary, inclu
...
@@ -279,6 +280,7 @@ func usageLogFromServiceBase(l *service.UsageLog, account *AccountSummary, inclu
TotalCost
:
l
.
TotalCost
,
TotalCost
:
l
.
TotalCost
,
ActualCost
:
l
.
ActualCost
,
ActualCost
:
l
.
ActualCost
,
RateMultiplier
:
l
.
RateMultiplier
,
RateMultiplier
:
l
.
RateMultiplier
,
AccountRateMultiplier
:
l
.
AccountRateMultiplier
,
BillingType
:
l
.
BillingType
,
BillingType
:
l
.
BillingType
,
Stream
:
l
.
Stream
,
Stream
:
l
.
Stream
,
DurationMs
:
l
.
DurationMs
,
DurationMs
:
l
.
DurationMs
,
...
...
backend/internal/handler/dto/types.go
View file @
2a5ef6d3
...
@@ -76,6 +76,7 @@ type Account struct {
...
@@ -76,6 +76,7 @@ type Account struct {
ProxyID
*
int64
`json:"proxy_id"`
ProxyID
*
int64
`json:"proxy_id"`
Concurrency
int
`json:"concurrency"`
Concurrency
int
`json:"concurrency"`
Priority
int
`json:"priority"`
Priority
int
`json:"priority"`
RateMultiplier
float64
`json:"rate_multiplier"`
Status
string
`json:"status"`
Status
string
`json:"status"`
ErrorMessage
string
`json:"error_message"`
ErrorMessage
string
`json:"error_message"`
LastUsedAt
*
time
.
Time
`json:"last_used_at"`
LastUsedAt
*
time
.
Time
`json:"last_used_at"`
...
@@ -169,13 +170,14 @@ type UsageLog struct {
...
@@ -169,13 +170,14 @@ type UsageLog struct {
CacheCreation5mTokens
int
`json:"cache_creation_5m_tokens"`
CacheCreation5mTokens
int
`json:"cache_creation_5m_tokens"`
CacheCreation1hTokens
int
`json:"cache_creation_1h_tokens"`
CacheCreation1hTokens
int
`json:"cache_creation_1h_tokens"`
InputCost
float64
`json:"input_cost"`
InputCost
float64
`json:"input_cost"`
OutputCost
float64
`json:"output_cost"`
OutputCost
float64
`json:"output_cost"`
CacheCreationCost
float64
`json:"cache_creation_cost"`
CacheCreationCost
float64
`json:"cache_creation_cost"`
CacheReadCost
float64
`json:"cache_read_cost"`
CacheReadCost
float64
`json:"cache_read_cost"`
TotalCost
float64
`json:"total_cost"`
TotalCost
float64
`json:"total_cost"`
ActualCost
float64
`json:"actual_cost"`
ActualCost
float64
`json:"actual_cost"`
RateMultiplier
float64
`json:"rate_multiplier"`
RateMultiplier
float64
`json:"rate_multiplier"`
AccountRateMultiplier
*
float64
`json:"account_rate_multiplier"`
BillingType
int8
`json:"billing_type"`
BillingType
int8
`json:"billing_type"`
Stream
bool
`json:"stream"`
Stream
bool
`json:"stream"`
...
...
backend/internal/pkg/usagestats/account_stats.go
View file @
2a5ef6d3
package
usagestats
package
usagestats
// AccountStats 账号使用统计
// AccountStats 账号使用统计
//
// cost: 账号口径费用(使用 total_cost * account_rate_multiplier)
// standard_cost: 标准费用(使用 total_cost,不含倍率)
// user_cost: 用户/API Key 口径费用(使用 actual_cost,受分组倍率影响)
type
AccountStats
struct
{
type
AccountStats
struct
{
Requests
int64
`json:"requests"`
Requests
int64
`json:"requests"`
Tokens
int64
`json:"tokens"`
Tokens
int64
`json:"tokens"`
Cost
float64
`json:"cost"`
Cost
float64
`json:"cost"`
StandardCost
float64
`json:"standard_cost"`
UserCost
float64
`json:"user_cost"`
}
}
backend/internal/pkg/usagestats/usage_log_types.go
View file @
2a5ef6d3
...
@@ -147,14 +147,15 @@ type UsageLogFilters struct {
...
@@ -147,14 +147,15 @@ type UsageLogFilters struct {
// UsageStats represents usage statistics
// UsageStats represents usage statistics
type
UsageStats
struct
{
type
UsageStats
struct
{
TotalRequests
int64
`json:"total_requests"`
TotalRequests
int64
`json:"total_requests"`
TotalInputTokens
int64
`json:"total_input_tokens"`
TotalInputTokens
int64
`json:"total_input_tokens"`
TotalOutputTokens
int64
`json:"total_output_tokens"`
TotalOutputTokens
int64
`json:"total_output_tokens"`
TotalCacheTokens
int64
`json:"total_cache_tokens"`
TotalCacheTokens
int64
`json:"total_cache_tokens"`
TotalTokens
int64
`json:"total_tokens"`
TotalTokens
int64
`json:"total_tokens"`
TotalCost
float64
`json:"total_cost"`
TotalCost
float64
`json:"total_cost"`
TotalActualCost
float64
`json:"total_actual_cost"`
TotalActualCost
float64
`json:"total_actual_cost"`
AverageDurationMs
float64
`json:"average_duration_ms"`
TotalAccountCost
*
float64
`json:"total_account_cost,omitempty"`
AverageDurationMs
float64
`json:"average_duration_ms"`
}
}
// BatchUserUsageStats represents usage stats for a single user
// BatchUserUsageStats represents usage stats for a single user
...
@@ -177,25 +178,29 @@ type AccountUsageHistory struct {
...
@@ -177,25 +178,29 @@ type AccountUsageHistory struct {
Label
string
`json:"label"`
Label
string
`json:"label"`
Requests
int64
`json:"requests"`
Requests
int64
`json:"requests"`
Tokens
int64
`json:"tokens"`
Tokens
int64
`json:"tokens"`
Cost
float64
`json:"cost"`
Cost
float64
`json:"cost"`
// 标准计费(total_cost)
ActualCost
float64
`json:"actual_cost"`
ActualCost
float64
`json:"actual_cost"`
// 账号口径费用(total_cost * account_rate_multiplier)
UserCost
float64
`json:"user_cost"`
// 用户口径费用(actual_cost,受分组倍率影响)
}
}
// AccountUsageSummary represents summary statistics for an account
// AccountUsageSummary represents summary statistics for an account
type
AccountUsageSummary
struct
{
type
AccountUsageSummary
struct
{
Days
int
`json:"days"`
Days
int
`json:"days"`
ActualDaysUsed
int
`json:"actual_days_used"`
ActualDaysUsed
int
`json:"actual_days_used"`
TotalCost
float64
`json:"total_cost"`
TotalCost
float64
`json:"total_cost"`
// 账号口径费用
TotalUserCost
float64
`json:"total_user_cost"`
// 用户口径费用
TotalStandardCost
float64
`json:"total_standard_cost"`
TotalStandardCost
float64
`json:"total_standard_cost"`
TotalRequests
int64
`json:"total_requests"`
TotalRequests
int64
`json:"total_requests"`
TotalTokens
int64
`json:"total_tokens"`
TotalTokens
int64
`json:"total_tokens"`
AvgDailyCost
float64
`json:"avg_daily_cost"`
AvgDailyCost
float64
`json:"avg_daily_cost"`
// 账号口径日均
AvgDailyUserCost
float64
`json:"avg_daily_user_cost"`
AvgDailyRequests
float64
`json:"avg_daily_requests"`
AvgDailyRequests
float64
`json:"avg_daily_requests"`
AvgDailyTokens
float64
`json:"avg_daily_tokens"`
AvgDailyTokens
float64
`json:"avg_daily_tokens"`
AvgDurationMs
float64
`json:"avg_duration_ms"`
AvgDurationMs
float64
`json:"avg_duration_ms"`
Today
*
struct
{
Today
*
struct
{
Date
string
`json:"date"`
Date
string
`json:"date"`
Cost
float64
`json:"cost"`
Cost
float64
`json:"cost"`
UserCost
float64
`json:"user_cost"`
Requests
int64
`json:"requests"`
Requests
int64
`json:"requests"`
Tokens
int64
`json:"tokens"`
Tokens
int64
`json:"tokens"`
}
`json:"today"`
}
`json:"today"`
...
@@ -203,6 +208,7 @@ type AccountUsageSummary struct {
...
@@ -203,6 +208,7 @@ type AccountUsageSummary struct {
Date
string
`json:"date"`
Date
string
`json:"date"`
Label
string
`json:"label"`
Label
string
`json:"label"`
Cost
float64
`json:"cost"`
Cost
float64
`json:"cost"`
UserCost
float64
`json:"user_cost"`
Requests
int64
`json:"requests"`
Requests
int64
`json:"requests"`
}
`json:"highest_cost_day"`
}
`json:"highest_cost_day"`
HighestRequestDay
*
struct
{
HighestRequestDay
*
struct
{
...
@@ -210,6 +216,7 @@ type AccountUsageSummary struct {
...
@@ -210,6 +216,7 @@ type AccountUsageSummary struct {
Label
string
`json:"label"`
Label
string
`json:"label"`
Requests
int64
`json:"requests"`
Requests
int64
`json:"requests"`
Cost
float64
`json:"cost"`
Cost
float64
`json:"cost"`
UserCost
float64
`json:"user_cost"`
}
`json:"highest_request_day"`
}
`json:"highest_request_day"`
}
}
...
...
Prev
1
2
3
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