feat: 图片生成计费功能
- 新增 Group 图片价格配置(image_price_1k/2k/4k) - BillingService 新增 CalculateImageCost 方法 - AntigravityGatewayService 支持识别图片生成模型并按次计费 - UsageLog 新增 image_count 和 image_size 字段 - 前端分组管理支持配置图片价格(antigravity 和 gemini 平台) - 图片计费复用通用计费能力(余额检查、扣费、倍率、订阅限额)
This commit is contained in:
@@ -45,6 +45,12 @@ type Group struct {
|
||||
MonthlyLimitUsd *float64 `json:"monthly_limit_usd,omitempty"`
|
||||
// DefaultValidityDays holds the value of the "default_validity_days" field.
|
||||
DefaultValidityDays int `json:"default_validity_days,omitempty"`
|
||||
// ImagePrice1k holds the value of the "image_price_1k" field.
|
||||
ImagePrice1k *float64 `json:"image_price_1k,omitempty"`
|
||||
// ImagePrice2k holds the value of the "image_price_2k" field.
|
||||
ImagePrice2k *float64 `json:"image_price_2k,omitempty"`
|
||||
// ImagePrice4k holds the value of the "image_price_4k" field.
|
||||
ImagePrice4k *float64 `json:"image_price_4k,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the GroupQuery when eager-loading is set.
|
||||
Edges GroupEdges `json:"edges"`
|
||||
@@ -153,7 +159,7 @@ func (*Group) scanValues(columns []string) ([]any, error) {
|
||||
switch columns[i] {
|
||||
case group.FieldIsExclusive:
|
||||
values[i] = new(sql.NullBool)
|
||||
case group.FieldRateMultiplier, group.FieldDailyLimitUsd, group.FieldWeeklyLimitUsd, group.FieldMonthlyLimitUsd:
|
||||
case group.FieldRateMultiplier, group.FieldDailyLimitUsd, group.FieldWeeklyLimitUsd, group.FieldMonthlyLimitUsd, group.FieldImagePrice1k, group.FieldImagePrice2k, group.FieldImagePrice4k:
|
||||
values[i] = new(sql.NullFloat64)
|
||||
case group.FieldID, group.FieldDefaultValidityDays:
|
||||
values[i] = new(sql.NullInt64)
|
||||
@@ -271,6 +277,27 @@ func (_m *Group) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
_m.DefaultValidityDays = int(value.Int64)
|
||||
}
|
||||
case group.FieldImagePrice1k:
|
||||
if value, ok := values[i].(*sql.NullFloat64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field image_price_1k", values[i])
|
||||
} else if value.Valid {
|
||||
_m.ImagePrice1k = new(float64)
|
||||
*_m.ImagePrice1k = value.Float64
|
||||
}
|
||||
case group.FieldImagePrice2k:
|
||||
if value, ok := values[i].(*sql.NullFloat64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field image_price_2k", values[i])
|
||||
} else if value.Valid {
|
||||
_m.ImagePrice2k = new(float64)
|
||||
*_m.ImagePrice2k = value.Float64
|
||||
}
|
||||
case group.FieldImagePrice4k:
|
||||
if value, ok := values[i].(*sql.NullFloat64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field image_price_4k", values[i])
|
||||
} else if value.Valid {
|
||||
_m.ImagePrice4k = new(float64)
|
||||
*_m.ImagePrice4k = value.Float64
|
||||
}
|
||||
default:
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
@@ -398,6 +425,21 @@ func (_m *Group) String() string {
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("default_validity_days=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.DefaultValidityDays))
|
||||
builder.WriteString(", ")
|
||||
if v := _m.ImagePrice1k; v != nil {
|
||||
builder.WriteString("image_price_1k=")
|
||||
builder.WriteString(fmt.Sprintf("%v", *v))
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
if v := _m.ImagePrice2k; v != nil {
|
||||
builder.WriteString("image_price_2k=")
|
||||
builder.WriteString(fmt.Sprintf("%v", *v))
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
if v := _m.ImagePrice4k; v != nil {
|
||||
builder.WriteString("image_price_4k=")
|
||||
builder.WriteString(fmt.Sprintf("%v", *v))
|
||||
}
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -43,6 +43,12 @@ const (
|
||||
FieldMonthlyLimitUsd = "monthly_limit_usd"
|
||||
// FieldDefaultValidityDays holds the string denoting the default_validity_days field in the database.
|
||||
FieldDefaultValidityDays = "default_validity_days"
|
||||
// FieldImagePrice1k holds the string denoting the image_price_1k field in the database.
|
||||
FieldImagePrice1k = "image_price_1k"
|
||||
// FieldImagePrice2k holds the string denoting the image_price_2k field in the database.
|
||||
FieldImagePrice2k = "image_price_2k"
|
||||
// FieldImagePrice4k holds the string denoting the image_price_4k field in the database.
|
||||
FieldImagePrice4k = "image_price_4k"
|
||||
// EdgeAPIKeys holds the string denoting the api_keys edge name in mutations.
|
||||
EdgeAPIKeys = "api_keys"
|
||||
// EdgeRedeemCodes holds the string denoting the redeem_codes edge name in mutations.
|
||||
@@ -132,6 +138,9 @@ var Columns = []string{
|
||||
FieldWeeklyLimitUsd,
|
||||
FieldMonthlyLimitUsd,
|
||||
FieldDefaultValidityDays,
|
||||
FieldImagePrice1k,
|
||||
FieldImagePrice2k,
|
||||
FieldImagePrice4k,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -267,6 +276,21 @@ func ByDefaultValidityDays(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDefaultValidityDays, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByImagePrice1k orders the results by the image_price_1k field.
|
||||
func ByImagePrice1k(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldImagePrice1k, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByImagePrice2k orders the results by the image_price_2k field.
|
||||
func ByImagePrice2k(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldImagePrice2k, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByImagePrice4k orders the results by the image_price_4k field.
|
||||
func ByImagePrice4k(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldImagePrice4k, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByAPIKeysCount orders the results by api_keys count.
|
||||
func ByAPIKeysCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
|
||||
@@ -125,6 +125,21 @@ func DefaultValidityDays(v int) predicate.Group {
|
||||
return predicate.Group(sql.FieldEQ(FieldDefaultValidityDays, v))
|
||||
}
|
||||
|
||||
// ImagePrice1k applies equality check predicate on the "image_price_1k" field. It's identical to ImagePrice1kEQ.
|
||||
func ImagePrice1k(v float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldEQ(FieldImagePrice1k, v))
|
||||
}
|
||||
|
||||
// ImagePrice2k applies equality check predicate on the "image_price_2k" field. It's identical to ImagePrice2kEQ.
|
||||
func ImagePrice2k(v float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldEQ(FieldImagePrice2k, v))
|
||||
}
|
||||
|
||||
// ImagePrice4k applies equality check predicate on the "image_price_4k" field. It's identical to ImagePrice4kEQ.
|
||||
func ImagePrice4k(v float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldEQ(FieldImagePrice4k, v))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v time.Time) predicate.Group {
|
||||
return predicate.Group(sql.FieldEQ(FieldCreatedAt, v))
|
||||
@@ -830,6 +845,156 @@ func DefaultValidityDaysLTE(v int) predicate.Group {
|
||||
return predicate.Group(sql.FieldLTE(FieldDefaultValidityDays, v))
|
||||
}
|
||||
|
||||
// ImagePrice1kEQ applies the EQ predicate on the "image_price_1k" field.
|
||||
func ImagePrice1kEQ(v float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldEQ(FieldImagePrice1k, v))
|
||||
}
|
||||
|
||||
// ImagePrice1kNEQ applies the NEQ predicate on the "image_price_1k" field.
|
||||
func ImagePrice1kNEQ(v float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldNEQ(FieldImagePrice1k, v))
|
||||
}
|
||||
|
||||
// ImagePrice1kIn applies the In predicate on the "image_price_1k" field.
|
||||
func ImagePrice1kIn(vs ...float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldIn(FieldImagePrice1k, vs...))
|
||||
}
|
||||
|
||||
// ImagePrice1kNotIn applies the NotIn predicate on the "image_price_1k" field.
|
||||
func ImagePrice1kNotIn(vs ...float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldNotIn(FieldImagePrice1k, vs...))
|
||||
}
|
||||
|
||||
// ImagePrice1kGT applies the GT predicate on the "image_price_1k" field.
|
||||
func ImagePrice1kGT(v float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldGT(FieldImagePrice1k, v))
|
||||
}
|
||||
|
||||
// ImagePrice1kGTE applies the GTE predicate on the "image_price_1k" field.
|
||||
func ImagePrice1kGTE(v float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldGTE(FieldImagePrice1k, v))
|
||||
}
|
||||
|
||||
// ImagePrice1kLT applies the LT predicate on the "image_price_1k" field.
|
||||
func ImagePrice1kLT(v float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldLT(FieldImagePrice1k, v))
|
||||
}
|
||||
|
||||
// ImagePrice1kLTE applies the LTE predicate on the "image_price_1k" field.
|
||||
func ImagePrice1kLTE(v float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldLTE(FieldImagePrice1k, v))
|
||||
}
|
||||
|
||||
// ImagePrice1kIsNil applies the IsNil predicate on the "image_price_1k" field.
|
||||
func ImagePrice1kIsNil() predicate.Group {
|
||||
return predicate.Group(sql.FieldIsNull(FieldImagePrice1k))
|
||||
}
|
||||
|
||||
// ImagePrice1kNotNil applies the NotNil predicate on the "image_price_1k" field.
|
||||
func ImagePrice1kNotNil() predicate.Group {
|
||||
return predicate.Group(sql.FieldNotNull(FieldImagePrice1k))
|
||||
}
|
||||
|
||||
// ImagePrice2kEQ applies the EQ predicate on the "image_price_2k" field.
|
||||
func ImagePrice2kEQ(v float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldEQ(FieldImagePrice2k, v))
|
||||
}
|
||||
|
||||
// ImagePrice2kNEQ applies the NEQ predicate on the "image_price_2k" field.
|
||||
func ImagePrice2kNEQ(v float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldNEQ(FieldImagePrice2k, v))
|
||||
}
|
||||
|
||||
// ImagePrice2kIn applies the In predicate on the "image_price_2k" field.
|
||||
func ImagePrice2kIn(vs ...float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldIn(FieldImagePrice2k, vs...))
|
||||
}
|
||||
|
||||
// ImagePrice2kNotIn applies the NotIn predicate on the "image_price_2k" field.
|
||||
func ImagePrice2kNotIn(vs ...float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldNotIn(FieldImagePrice2k, vs...))
|
||||
}
|
||||
|
||||
// ImagePrice2kGT applies the GT predicate on the "image_price_2k" field.
|
||||
func ImagePrice2kGT(v float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldGT(FieldImagePrice2k, v))
|
||||
}
|
||||
|
||||
// ImagePrice2kGTE applies the GTE predicate on the "image_price_2k" field.
|
||||
func ImagePrice2kGTE(v float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldGTE(FieldImagePrice2k, v))
|
||||
}
|
||||
|
||||
// ImagePrice2kLT applies the LT predicate on the "image_price_2k" field.
|
||||
func ImagePrice2kLT(v float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldLT(FieldImagePrice2k, v))
|
||||
}
|
||||
|
||||
// ImagePrice2kLTE applies the LTE predicate on the "image_price_2k" field.
|
||||
func ImagePrice2kLTE(v float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldLTE(FieldImagePrice2k, v))
|
||||
}
|
||||
|
||||
// ImagePrice2kIsNil applies the IsNil predicate on the "image_price_2k" field.
|
||||
func ImagePrice2kIsNil() predicate.Group {
|
||||
return predicate.Group(sql.FieldIsNull(FieldImagePrice2k))
|
||||
}
|
||||
|
||||
// ImagePrice2kNotNil applies the NotNil predicate on the "image_price_2k" field.
|
||||
func ImagePrice2kNotNil() predicate.Group {
|
||||
return predicate.Group(sql.FieldNotNull(FieldImagePrice2k))
|
||||
}
|
||||
|
||||
// ImagePrice4kEQ applies the EQ predicate on the "image_price_4k" field.
|
||||
func ImagePrice4kEQ(v float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldEQ(FieldImagePrice4k, v))
|
||||
}
|
||||
|
||||
// ImagePrice4kNEQ applies the NEQ predicate on the "image_price_4k" field.
|
||||
func ImagePrice4kNEQ(v float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldNEQ(FieldImagePrice4k, v))
|
||||
}
|
||||
|
||||
// ImagePrice4kIn applies the In predicate on the "image_price_4k" field.
|
||||
func ImagePrice4kIn(vs ...float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldIn(FieldImagePrice4k, vs...))
|
||||
}
|
||||
|
||||
// ImagePrice4kNotIn applies the NotIn predicate on the "image_price_4k" field.
|
||||
func ImagePrice4kNotIn(vs ...float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldNotIn(FieldImagePrice4k, vs...))
|
||||
}
|
||||
|
||||
// ImagePrice4kGT applies the GT predicate on the "image_price_4k" field.
|
||||
func ImagePrice4kGT(v float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldGT(FieldImagePrice4k, v))
|
||||
}
|
||||
|
||||
// ImagePrice4kGTE applies the GTE predicate on the "image_price_4k" field.
|
||||
func ImagePrice4kGTE(v float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldGTE(FieldImagePrice4k, v))
|
||||
}
|
||||
|
||||
// ImagePrice4kLT applies the LT predicate on the "image_price_4k" field.
|
||||
func ImagePrice4kLT(v float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldLT(FieldImagePrice4k, v))
|
||||
}
|
||||
|
||||
// ImagePrice4kLTE applies the LTE predicate on the "image_price_4k" field.
|
||||
func ImagePrice4kLTE(v float64) predicate.Group {
|
||||
return predicate.Group(sql.FieldLTE(FieldImagePrice4k, v))
|
||||
}
|
||||
|
||||
// ImagePrice4kIsNil applies the IsNil predicate on the "image_price_4k" field.
|
||||
func ImagePrice4kIsNil() predicate.Group {
|
||||
return predicate.Group(sql.FieldIsNull(FieldImagePrice4k))
|
||||
}
|
||||
|
||||
// ImagePrice4kNotNil applies the NotNil predicate on the "image_price_4k" field.
|
||||
func ImagePrice4kNotNil() predicate.Group {
|
||||
return predicate.Group(sql.FieldNotNull(FieldImagePrice4k))
|
||||
}
|
||||
|
||||
// HasAPIKeys applies the HasEdge predicate on the "api_keys" edge.
|
||||
func HasAPIKeys() predicate.Group {
|
||||
return predicate.Group(func(s *sql.Selector) {
|
||||
|
||||
@@ -216,6 +216,48 @@ func (_c *GroupCreate) SetNillableDefaultValidityDays(v *int) *GroupCreate {
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetImagePrice1k sets the "image_price_1k" field.
|
||||
func (_c *GroupCreate) SetImagePrice1k(v float64) *GroupCreate {
|
||||
_c.mutation.SetImagePrice1k(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableImagePrice1k sets the "image_price_1k" field if the given value is not nil.
|
||||
func (_c *GroupCreate) SetNillableImagePrice1k(v *float64) *GroupCreate {
|
||||
if v != nil {
|
||||
_c.SetImagePrice1k(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetImagePrice2k sets the "image_price_2k" field.
|
||||
func (_c *GroupCreate) SetImagePrice2k(v float64) *GroupCreate {
|
||||
_c.mutation.SetImagePrice2k(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableImagePrice2k sets the "image_price_2k" field if the given value is not nil.
|
||||
func (_c *GroupCreate) SetNillableImagePrice2k(v *float64) *GroupCreate {
|
||||
if v != nil {
|
||||
_c.SetImagePrice2k(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetImagePrice4k sets the "image_price_4k" field.
|
||||
func (_c *GroupCreate) SetImagePrice4k(v float64) *GroupCreate {
|
||||
_c.mutation.SetImagePrice4k(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableImagePrice4k sets the "image_price_4k" field if the given value is not nil.
|
||||
func (_c *GroupCreate) SetNillableImagePrice4k(v *float64) *GroupCreate {
|
||||
if v != nil {
|
||||
_c.SetImagePrice4k(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddAPIKeyIDs adds the "api_keys" edge to the APIKey entity by IDs.
|
||||
func (_c *GroupCreate) AddAPIKeyIDs(ids ...int64) *GroupCreate {
|
||||
_c.mutation.AddAPIKeyIDs(ids...)
|
||||
@@ -516,6 +558,18 @@ func (_c *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(group.FieldDefaultValidityDays, field.TypeInt, value)
|
||||
_node.DefaultValidityDays = value
|
||||
}
|
||||
if value, ok := _c.mutation.ImagePrice1k(); ok {
|
||||
_spec.SetField(group.FieldImagePrice1k, field.TypeFloat64, value)
|
||||
_node.ImagePrice1k = &value
|
||||
}
|
||||
if value, ok := _c.mutation.ImagePrice2k(); ok {
|
||||
_spec.SetField(group.FieldImagePrice2k, field.TypeFloat64, value)
|
||||
_node.ImagePrice2k = &value
|
||||
}
|
||||
if value, ok := _c.mutation.ImagePrice4k(); ok {
|
||||
_spec.SetField(group.FieldImagePrice4k, field.TypeFloat64, value)
|
||||
_node.ImagePrice4k = &value
|
||||
}
|
||||
if nodes := _c.mutation.APIKeysIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
@@ -888,6 +942,78 @@ func (u *GroupUpsert) AddDefaultValidityDays(v int) *GroupUpsert {
|
||||
return u
|
||||
}
|
||||
|
||||
// SetImagePrice1k sets the "image_price_1k" field.
|
||||
func (u *GroupUpsert) SetImagePrice1k(v float64) *GroupUpsert {
|
||||
u.Set(group.FieldImagePrice1k, v)
|
||||
return u
|
||||
}
|
||||
|
||||
// UpdateImagePrice1k sets the "image_price_1k" field to the value that was provided on create.
|
||||
func (u *GroupUpsert) UpdateImagePrice1k() *GroupUpsert {
|
||||
u.SetExcluded(group.FieldImagePrice1k)
|
||||
return u
|
||||
}
|
||||
|
||||
// AddImagePrice1k adds v to the "image_price_1k" field.
|
||||
func (u *GroupUpsert) AddImagePrice1k(v float64) *GroupUpsert {
|
||||
u.Add(group.FieldImagePrice1k, v)
|
||||
return u
|
||||
}
|
||||
|
||||
// ClearImagePrice1k clears the value of the "image_price_1k" field.
|
||||
func (u *GroupUpsert) ClearImagePrice1k() *GroupUpsert {
|
||||
u.SetNull(group.FieldImagePrice1k)
|
||||
return u
|
||||
}
|
||||
|
||||
// SetImagePrice2k sets the "image_price_2k" field.
|
||||
func (u *GroupUpsert) SetImagePrice2k(v float64) *GroupUpsert {
|
||||
u.Set(group.FieldImagePrice2k, v)
|
||||
return u
|
||||
}
|
||||
|
||||
// UpdateImagePrice2k sets the "image_price_2k" field to the value that was provided on create.
|
||||
func (u *GroupUpsert) UpdateImagePrice2k() *GroupUpsert {
|
||||
u.SetExcluded(group.FieldImagePrice2k)
|
||||
return u
|
||||
}
|
||||
|
||||
// AddImagePrice2k adds v to the "image_price_2k" field.
|
||||
func (u *GroupUpsert) AddImagePrice2k(v float64) *GroupUpsert {
|
||||
u.Add(group.FieldImagePrice2k, v)
|
||||
return u
|
||||
}
|
||||
|
||||
// ClearImagePrice2k clears the value of the "image_price_2k" field.
|
||||
func (u *GroupUpsert) ClearImagePrice2k() *GroupUpsert {
|
||||
u.SetNull(group.FieldImagePrice2k)
|
||||
return u
|
||||
}
|
||||
|
||||
// SetImagePrice4k sets the "image_price_4k" field.
|
||||
func (u *GroupUpsert) SetImagePrice4k(v float64) *GroupUpsert {
|
||||
u.Set(group.FieldImagePrice4k, v)
|
||||
return u
|
||||
}
|
||||
|
||||
// UpdateImagePrice4k sets the "image_price_4k" field to the value that was provided on create.
|
||||
func (u *GroupUpsert) UpdateImagePrice4k() *GroupUpsert {
|
||||
u.SetExcluded(group.FieldImagePrice4k)
|
||||
return u
|
||||
}
|
||||
|
||||
// AddImagePrice4k adds v to the "image_price_4k" field.
|
||||
func (u *GroupUpsert) AddImagePrice4k(v float64) *GroupUpsert {
|
||||
u.Add(group.FieldImagePrice4k, v)
|
||||
return u
|
||||
}
|
||||
|
||||
// ClearImagePrice4k clears the value of the "image_price_4k" field.
|
||||
func (u *GroupUpsert) ClearImagePrice4k() *GroupUpsert {
|
||||
u.SetNull(group.FieldImagePrice4k)
|
||||
return u
|
||||
}
|
||||
|
||||
// UpdateNewValues updates the mutable fields using the new values that were set on create.
|
||||
// Using this option is equivalent to using:
|
||||
//
|
||||
@@ -1185,6 +1311,90 @@ func (u *GroupUpsertOne) UpdateDefaultValidityDays() *GroupUpsertOne {
|
||||
})
|
||||
}
|
||||
|
||||
// SetImagePrice1k sets the "image_price_1k" field.
|
||||
func (u *GroupUpsertOne) SetImagePrice1k(v float64) *GroupUpsertOne {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.SetImagePrice1k(v)
|
||||
})
|
||||
}
|
||||
|
||||
// AddImagePrice1k adds v to the "image_price_1k" field.
|
||||
func (u *GroupUpsertOne) AddImagePrice1k(v float64) *GroupUpsertOne {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.AddImagePrice1k(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateImagePrice1k sets the "image_price_1k" field to the value that was provided on create.
|
||||
func (u *GroupUpsertOne) UpdateImagePrice1k() *GroupUpsertOne {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.UpdateImagePrice1k()
|
||||
})
|
||||
}
|
||||
|
||||
// ClearImagePrice1k clears the value of the "image_price_1k" field.
|
||||
func (u *GroupUpsertOne) ClearImagePrice1k() *GroupUpsertOne {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.ClearImagePrice1k()
|
||||
})
|
||||
}
|
||||
|
||||
// SetImagePrice2k sets the "image_price_2k" field.
|
||||
func (u *GroupUpsertOne) SetImagePrice2k(v float64) *GroupUpsertOne {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.SetImagePrice2k(v)
|
||||
})
|
||||
}
|
||||
|
||||
// AddImagePrice2k adds v to the "image_price_2k" field.
|
||||
func (u *GroupUpsertOne) AddImagePrice2k(v float64) *GroupUpsertOne {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.AddImagePrice2k(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateImagePrice2k sets the "image_price_2k" field to the value that was provided on create.
|
||||
func (u *GroupUpsertOne) UpdateImagePrice2k() *GroupUpsertOne {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.UpdateImagePrice2k()
|
||||
})
|
||||
}
|
||||
|
||||
// ClearImagePrice2k clears the value of the "image_price_2k" field.
|
||||
func (u *GroupUpsertOne) ClearImagePrice2k() *GroupUpsertOne {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.ClearImagePrice2k()
|
||||
})
|
||||
}
|
||||
|
||||
// SetImagePrice4k sets the "image_price_4k" field.
|
||||
func (u *GroupUpsertOne) SetImagePrice4k(v float64) *GroupUpsertOne {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.SetImagePrice4k(v)
|
||||
})
|
||||
}
|
||||
|
||||
// AddImagePrice4k adds v to the "image_price_4k" field.
|
||||
func (u *GroupUpsertOne) AddImagePrice4k(v float64) *GroupUpsertOne {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.AddImagePrice4k(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateImagePrice4k sets the "image_price_4k" field to the value that was provided on create.
|
||||
func (u *GroupUpsertOne) UpdateImagePrice4k() *GroupUpsertOne {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.UpdateImagePrice4k()
|
||||
})
|
||||
}
|
||||
|
||||
// ClearImagePrice4k clears the value of the "image_price_4k" field.
|
||||
func (u *GroupUpsertOne) ClearImagePrice4k() *GroupUpsertOne {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.ClearImagePrice4k()
|
||||
})
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (u *GroupUpsertOne) Exec(ctx context.Context) error {
|
||||
if len(u.create.conflict) == 0 {
|
||||
@@ -1648,6 +1858,90 @@ func (u *GroupUpsertBulk) UpdateDefaultValidityDays() *GroupUpsertBulk {
|
||||
})
|
||||
}
|
||||
|
||||
// SetImagePrice1k sets the "image_price_1k" field.
|
||||
func (u *GroupUpsertBulk) SetImagePrice1k(v float64) *GroupUpsertBulk {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.SetImagePrice1k(v)
|
||||
})
|
||||
}
|
||||
|
||||
// AddImagePrice1k adds v to the "image_price_1k" field.
|
||||
func (u *GroupUpsertBulk) AddImagePrice1k(v float64) *GroupUpsertBulk {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.AddImagePrice1k(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateImagePrice1k sets the "image_price_1k" field to the value that was provided on create.
|
||||
func (u *GroupUpsertBulk) UpdateImagePrice1k() *GroupUpsertBulk {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.UpdateImagePrice1k()
|
||||
})
|
||||
}
|
||||
|
||||
// ClearImagePrice1k clears the value of the "image_price_1k" field.
|
||||
func (u *GroupUpsertBulk) ClearImagePrice1k() *GroupUpsertBulk {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.ClearImagePrice1k()
|
||||
})
|
||||
}
|
||||
|
||||
// SetImagePrice2k sets the "image_price_2k" field.
|
||||
func (u *GroupUpsertBulk) SetImagePrice2k(v float64) *GroupUpsertBulk {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.SetImagePrice2k(v)
|
||||
})
|
||||
}
|
||||
|
||||
// AddImagePrice2k adds v to the "image_price_2k" field.
|
||||
func (u *GroupUpsertBulk) AddImagePrice2k(v float64) *GroupUpsertBulk {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.AddImagePrice2k(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateImagePrice2k sets the "image_price_2k" field to the value that was provided on create.
|
||||
func (u *GroupUpsertBulk) UpdateImagePrice2k() *GroupUpsertBulk {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.UpdateImagePrice2k()
|
||||
})
|
||||
}
|
||||
|
||||
// ClearImagePrice2k clears the value of the "image_price_2k" field.
|
||||
func (u *GroupUpsertBulk) ClearImagePrice2k() *GroupUpsertBulk {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.ClearImagePrice2k()
|
||||
})
|
||||
}
|
||||
|
||||
// SetImagePrice4k sets the "image_price_4k" field.
|
||||
func (u *GroupUpsertBulk) SetImagePrice4k(v float64) *GroupUpsertBulk {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.SetImagePrice4k(v)
|
||||
})
|
||||
}
|
||||
|
||||
// AddImagePrice4k adds v to the "image_price_4k" field.
|
||||
func (u *GroupUpsertBulk) AddImagePrice4k(v float64) *GroupUpsertBulk {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.AddImagePrice4k(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateImagePrice4k sets the "image_price_4k" field to the value that was provided on create.
|
||||
func (u *GroupUpsertBulk) UpdateImagePrice4k() *GroupUpsertBulk {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.UpdateImagePrice4k()
|
||||
})
|
||||
}
|
||||
|
||||
// ClearImagePrice4k clears the value of the "image_price_4k" field.
|
||||
func (u *GroupUpsertBulk) ClearImagePrice4k() *GroupUpsertBulk {
|
||||
return u.Update(func(s *GroupUpsert) {
|
||||
s.ClearImagePrice4k()
|
||||
})
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (u *GroupUpsertBulk) Exec(ctx context.Context) error {
|
||||
if u.create.err != nil {
|
||||
|
||||
@@ -273,6 +273,87 @@ func (_u *GroupUpdate) AddDefaultValidityDays(v int) *GroupUpdate {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetImagePrice1k sets the "image_price_1k" field.
|
||||
func (_u *GroupUpdate) SetImagePrice1k(v float64) *GroupUpdate {
|
||||
_u.mutation.ResetImagePrice1k()
|
||||
_u.mutation.SetImagePrice1k(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableImagePrice1k sets the "image_price_1k" field if the given value is not nil.
|
||||
func (_u *GroupUpdate) SetNillableImagePrice1k(v *float64) *GroupUpdate {
|
||||
if v != nil {
|
||||
_u.SetImagePrice1k(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddImagePrice1k adds value to the "image_price_1k" field.
|
||||
func (_u *GroupUpdate) AddImagePrice1k(v float64) *GroupUpdate {
|
||||
_u.mutation.AddImagePrice1k(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearImagePrice1k clears the value of the "image_price_1k" field.
|
||||
func (_u *GroupUpdate) ClearImagePrice1k() *GroupUpdate {
|
||||
_u.mutation.ClearImagePrice1k()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetImagePrice2k sets the "image_price_2k" field.
|
||||
func (_u *GroupUpdate) SetImagePrice2k(v float64) *GroupUpdate {
|
||||
_u.mutation.ResetImagePrice2k()
|
||||
_u.mutation.SetImagePrice2k(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableImagePrice2k sets the "image_price_2k" field if the given value is not nil.
|
||||
func (_u *GroupUpdate) SetNillableImagePrice2k(v *float64) *GroupUpdate {
|
||||
if v != nil {
|
||||
_u.SetImagePrice2k(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddImagePrice2k adds value to the "image_price_2k" field.
|
||||
func (_u *GroupUpdate) AddImagePrice2k(v float64) *GroupUpdate {
|
||||
_u.mutation.AddImagePrice2k(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearImagePrice2k clears the value of the "image_price_2k" field.
|
||||
func (_u *GroupUpdate) ClearImagePrice2k() *GroupUpdate {
|
||||
_u.mutation.ClearImagePrice2k()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetImagePrice4k sets the "image_price_4k" field.
|
||||
func (_u *GroupUpdate) SetImagePrice4k(v float64) *GroupUpdate {
|
||||
_u.mutation.ResetImagePrice4k()
|
||||
_u.mutation.SetImagePrice4k(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableImagePrice4k sets the "image_price_4k" field if the given value is not nil.
|
||||
func (_u *GroupUpdate) SetNillableImagePrice4k(v *float64) *GroupUpdate {
|
||||
if v != nil {
|
||||
_u.SetImagePrice4k(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddImagePrice4k adds value to the "image_price_4k" field.
|
||||
func (_u *GroupUpdate) AddImagePrice4k(v float64) *GroupUpdate {
|
||||
_u.mutation.AddImagePrice4k(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearImagePrice4k clears the value of the "image_price_4k" field.
|
||||
func (_u *GroupUpdate) ClearImagePrice4k() *GroupUpdate {
|
||||
_u.mutation.ClearImagePrice4k()
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddAPIKeyIDs adds the "api_keys" edge to the APIKey entity by IDs.
|
||||
func (_u *GroupUpdate) AddAPIKeyIDs(ids ...int64) *GroupUpdate {
|
||||
_u.mutation.AddAPIKeyIDs(ids...)
|
||||
@@ -642,6 +723,33 @@ func (_u *GroupUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if value, ok := _u.mutation.AddedDefaultValidityDays(); ok {
|
||||
_spec.AddField(group.FieldDefaultValidityDays, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.ImagePrice1k(); ok {
|
||||
_spec.SetField(group.FieldImagePrice1k, field.TypeFloat64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedImagePrice1k(); ok {
|
||||
_spec.AddField(group.FieldImagePrice1k, field.TypeFloat64, value)
|
||||
}
|
||||
if _u.mutation.ImagePrice1kCleared() {
|
||||
_spec.ClearField(group.FieldImagePrice1k, field.TypeFloat64)
|
||||
}
|
||||
if value, ok := _u.mutation.ImagePrice2k(); ok {
|
||||
_spec.SetField(group.FieldImagePrice2k, field.TypeFloat64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedImagePrice2k(); ok {
|
||||
_spec.AddField(group.FieldImagePrice2k, field.TypeFloat64, value)
|
||||
}
|
||||
if _u.mutation.ImagePrice2kCleared() {
|
||||
_spec.ClearField(group.FieldImagePrice2k, field.TypeFloat64)
|
||||
}
|
||||
if value, ok := _u.mutation.ImagePrice4k(); ok {
|
||||
_spec.SetField(group.FieldImagePrice4k, field.TypeFloat64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedImagePrice4k(); ok {
|
||||
_spec.AddField(group.FieldImagePrice4k, field.TypeFloat64, value)
|
||||
}
|
||||
if _u.mutation.ImagePrice4kCleared() {
|
||||
_spec.ClearField(group.FieldImagePrice4k, field.TypeFloat64)
|
||||
}
|
||||
if _u.mutation.APIKeysCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
@@ -1195,6 +1303,87 @@ func (_u *GroupUpdateOne) AddDefaultValidityDays(v int) *GroupUpdateOne {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetImagePrice1k sets the "image_price_1k" field.
|
||||
func (_u *GroupUpdateOne) SetImagePrice1k(v float64) *GroupUpdateOne {
|
||||
_u.mutation.ResetImagePrice1k()
|
||||
_u.mutation.SetImagePrice1k(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableImagePrice1k sets the "image_price_1k" field if the given value is not nil.
|
||||
func (_u *GroupUpdateOne) SetNillableImagePrice1k(v *float64) *GroupUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetImagePrice1k(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddImagePrice1k adds value to the "image_price_1k" field.
|
||||
func (_u *GroupUpdateOne) AddImagePrice1k(v float64) *GroupUpdateOne {
|
||||
_u.mutation.AddImagePrice1k(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearImagePrice1k clears the value of the "image_price_1k" field.
|
||||
func (_u *GroupUpdateOne) ClearImagePrice1k() *GroupUpdateOne {
|
||||
_u.mutation.ClearImagePrice1k()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetImagePrice2k sets the "image_price_2k" field.
|
||||
func (_u *GroupUpdateOne) SetImagePrice2k(v float64) *GroupUpdateOne {
|
||||
_u.mutation.ResetImagePrice2k()
|
||||
_u.mutation.SetImagePrice2k(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableImagePrice2k sets the "image_price_2k" field if the given value is not nil.
|
||||
func (_u *GroupUpdateOne) SetNillableImagePrice2k(v *float64) *GroupUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetImagePrice2k(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddImagePrice2k adds value to the "image_price_2k" field.
|
||||
func (_u *GroupUpdateOne) AddImagePrice2k(v float64) *GroupUpdateOne {
|
||||
_u.mutation.AddImagePrice2k(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearImagePrice2k clears the value of the "image_price_2k" field.
|
||||
func (_u *GroupUpdateOne) ClearImagePrice2k() *GroupUpdateOne {
|
||||
_u.mutation.ClearImagePrice2k()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetImagePrice4k sets the "image_price_4k" field.
|
||||
func (_u *GroupUpdateOne) SetImagePrice4k(v float64) *GroupUpdateOne {
|
||||
_u.mutation.ResetImagePrice4k()
|
||||
_u.mutation.SetImagePrice4k(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableImagePrice4k sets the "image_price_4k" field if the given value is not nil.
|
||||
func (_u *GroupUpdateOne) SetNillableImagePrice4k(v *float64) *GroupUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetImagePrice4k(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddImagePrice4k adds value to the "image_price_4k" field.
|
||||
func (_u *GroupUpdateOne) AddImagePrice4k(v float64) *GroupUpdateOne {
|
||||
_u.mutation.AddImagePrice4k(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearImagePrice4k clears the value of the "image_price_4k" field.
|
||||
func (_u *GroupUpdateOne) ClearImagePrice4k() *GroupUpdateOne {
|
||||
_u.mutation.ClearImagePrice4k()
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddAPIKeyIDs adds the "api_keys" edge to the APIKey entity by IDs.
|
||||
func (_u *GroupUpdateOne) AddAPIKeyIDs(ids ...int64) *GroupUpdateOne {
|
||||
_u.mutation.AddAPIKeyIDs(ids...)
|
||||
@@ -1594,6 +1783,33 @@ func (_u *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error)
|
||||
if value, ok := _u.mutation.AddedDefaultValidityDays(); ok {
|
||||
_spec.AddField(group.FieldDefaultValidityDays, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.ImagePrice1k(); ok {
|
||||
_spec.SetField(group.FieldImagePrice1k, field.TypeFloat64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedImagePrice1k(); ok {
|
||||
_spec.AddField(group.FieldImagePrice1k, field.TypeFloat64, value)
|
||||
}
|
||||
if _u.mutation.ImagePrice1kCleared() {
|
||||
_spec.ClearField(group.FieldImagePrice1k, field.TypeFloat64)
|
||||
}
|
||||
if value, ok := _u.mutation.ImagePrice2k(); ok {
|
||||
_spec.SetField(group.FieldImagePrice2k, field.TypeFloat64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedImagePrice2k(); ok {
|
||||
_spec.AddField(group.FieldImagePrice2k, field.TypeFloat64, value)
|
||||
}
|
||||
if _u.mutation.ImagePrice2kCleared() {
|
||||
_spec.ClearField(group.FieldImagePrice2k, field.TypeFloat64)
|
||||
}
|
||||
if value, ok := _u.mutation.ImagePrice4k(); ok {
|
||||
_spec.SetField(group.FieldImagePrice4k, field.TypeFloat64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedImagePrice4k(); ok {
|
||||
_spec.AddField(group.FieldImagePrice4k, field.TypeFloat64, value)
|
||||
}
|
||||
if _u.mutation.ImagePrice4kCleared() {
|
||||
_spec.ClearField(group.FieldImagePrice4k, field.TypeFloat64)
|
||||
}
|
||||
if _u.mutation.APIKeysCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
|
||||
@@ -215,6 +215,9 @@ var (
|
||||
{Name: "weekly_limit_usd", Type: field.TypeFloat64, Nullable: true, SchemaType: map[string]string{"postgres": "decimal(20,8)"}},
|
||||
{Name: "monthly_limit_usd", Type: field.TypeFloat64, Nullable: true, SchemaType: map[string]string{"postgres": "decimal(20,8)"}},
|
||||
{Name: "default_validity_days", Type: field.TypeInt, Default: 30},
|
||||
{Name: "image_price_1k", Type: field.TypeFloat64, Nullable: true, SchemaType: map[string]string{"postgres": "decimal(20,8)"}},
|
||||
{Name: "image_price_2k", Type: field.TypeFloat64, Nullable: true, SchemaType: map[string]string{"postgres": "decimal(20,8)"}},
|
||||
{Name: "image_price_4k", Type: field.TypeFloat64, Nullable: true, SchemaType: map[string]string{"postgres": "decimal(20,8)"}},
|
||||
}
|
||||
// GroupsTable holds the schema information for the "groups" table.
|
||||
GroupsTable = &schema.Table{
|
||||
@@ -367,6 +370,8 @@ var (
|
||||
{Name: "stream", Type: field.TypeBool, Default: false},
|
||||
{Name: "duration_ms", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "first_token_ms", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "image_count", Type: field.TypeInt, Default: 0},
|
||||
{Name: "image_size", Type: field.TypeString, Nullable: true, Size: 10},
|
||||
{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "timestamptz"}},
|
||||
{Name: "api_key_id", Type: field.TypeInt64},
|
||||
{Name: "account_id", Type: field.TypeInt64},
|
||||
@@ -382,31 +387,31 @@ var (
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "usage_logs_api_keys_usage_logs",
|
||||
Columns: []*schema.Column{UsageLogsColumns[21]},
|
||||
Columns: []*schema.Column{UsageLogsColumns[23]},
|
||||
RefColumns: []*schema.Column{APIKeysColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
{
|
||||
Symbol: "usage_logs_accounts_usage_logs",
|
||||
Columns: []*schema.Column{UsageLogsColumns[22]},
|
||||
Columns: []*schema.Column{UsageLogsColumns[24]},
|
||||
RefColumns: []*schema.Column{AccountsColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
{
|
||||
Symbol: "usage_logs_groups_usage_logs",
|
||||
Columns: []*schema.Column{UsageLogsColumns[23]},
|
||||
Columns: []*schema.Column{UsageLogsColumns[25]},
|
||||
RefColumns: []*schema.Column{GroupsColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
{
|
||||
Symbol: "usage_logs_users_usage_logs",
|
||||
Columns: []*schema.Column{UsageLogsColumns[24]},
|
||||
Columns: []*schema.Column{UsageLogsColumns[26]},
|
||||
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
{
|
||||
Symbol: "usage_logs_user_subscriptions_usage_logs",
|
||||
Columns: []*schema.Column{UsageLogsColumns[25]},
|
||||
Columns: []*schema.Column{UsageLogsColumns[27]},
|
||||
RefColumns: []*schema.Column{UserSubscriptionsColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
@@ -415,32 +420,32 @@ var (
|
||||
{
|
||||
Name: "usagelog_user_id",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{UsageLogsColumns[24]},
|
||||
Columns: []*schema.Column{UsageLogsColumns[26]},
|
||||
},
|
||||
{
|
||||
Name: "usagelog_api_key_id",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{UsageLogsColumns[21]},
|
||||
Columns: []*schema.Column{UsageLogsColumns[23]},
|
||||
},
|
||||
{
|
||||
Name: "usagelog_account_id",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{UsageLogsColumns[22]},
|
||||
Columns: []*schema.Column{UsageLogsColumns[24]},
|
||||
},
|
||||
{
|
||||
Name: "usagelog_group_id",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{UsageLogsColumns[23]},
|
||||
Columns: []*schema.Column{UsageLogsColumns[25]},
|
||||
},
|
||||
{
|
||||
Name: "usagelog_subscription_id",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{UsageLogsColumns[25]},
|
||||
Columns: []*schema.Column{UsageLogsColumns[27]},
|
||||
},
|
||||
{
|
||||
Name: "usagelog_created_at",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{UsageLogsColumns[20]},
|
||||
Columns: []*schema.Column{UsageLogsColumns[22]},
|
||||
},
|
||||
{
|
||||
Name: "usagelog_model",
|
||||
@@ -455,12 +460,12 @@ var (
|
||||
{
|
||||
Name: "usagelog_user_id_created_at",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{UsageLogsColumns[24], UsageLogsColumns[20]},
|
||||
Columns: []*schema.Column{UsageLogsColumns[26], UsageLogsColumns[22]},
|
||||
},
|
||||
{
|
||||
Name: "usagelog_api_key_id_created_at",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{UsageLogsColumns[21], UsageLogsColumns[20]},
|
||||
Columns: []*schema.Column{UsageLogsColumns[23], UsageLogsColumns[22]},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -3384,6 +3384,12 @@ type GroupMutation struct {
|
||||
addmonthly_limit_usd *float64
|
||||
default_validity_days *int
|
||||
adddefault_validity_days *int
|
||||
image_price_1k *float64
|
||||
addimage_price_1k *float64
|
||||
image_price_2k *float64
|
||||
addimage_price_2k *float64
|
||||
image_price_4k *float64
|
||||
addimage_price_4k *float64
|
||||
clearedFields map[string]struct{}
|
||||
api_keys map[int64]struct{}
|
||||
removedapi_keys map[int64]struct{}
|
||||
@@ -4178,6 +4184,216 @@ func (m *GroupMutation) ResetDefaultValidityDays() {
|
||||
m.adddefault_validity_days = nil
|
||||
}
|
||||
|
||||
// SetImagePrice1k sets the "image_price_1k" field.
|
||||
func (m *GroupMutation) SetImagePrice1k(f float64) {
|
||||
m.image_price_1k = &f
|
||||
m.addimage_price_1k = nil
|
||||
}
|
||||
|
||||
// ImagePrice1k returns the value of the "image_price_1k" field in the mutation.
|
||||
func (m *GroupMutation) ImagePrice1k() (r float64, exists bool) {
|
||||
v := m.image_price_1k
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldImagePrice1k returns the old "image_price_1k" field's value of the Group entity.
|
||||
// If the Group object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *GroupMutation) OldImagePrice1k(ctx context.Context) (v *float64, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldImagePrice1k is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldImagePrice1k requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldImagePrice1k: %w", err)
|
||||
}
|
||||
return oldValue.ImagePrice1k, nil
|
||||
}
|
||||
|
||||
// AddImagePrice1k adds f to the "image_price_1k" field.
|
||||
func (m *GroupMutation) AddImagePrice1k(f float64) {
|
||||
if m.addimage_price_1k != nil {
|
||||
*m.addimage_price_1k += f
|
||||
} else {
|
||||
m.addimage_price_1k = &f
|
||||
}
|
||||
}
|
||||
|
||||
// AddedImagePrice1k returns the value that was added to the "image_price_1k" field in this mutation.
|
||||
func (m *GroupMutation) AddedImagePrice1k() (r float64, exists bool) {
|
||||
v := m.addimage_price_1k
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// ClearImagePrice1k clears the value of the "image_price_1k" field.
|
||||
func (m *GroupMutation) ClearImagePrice1k() {
|
||||
m.image_price_1k = nil
|
||||
m.addimage_price_1k = nil
|
||||
m.clearedFields[group.FieldImagePrice1k] = struct{}{}
|
||||
}
|
||||
|
||||
// ImagePrice1kCleared returns if the "image_price_1k" field was cleared in this mutation.
|
||||
func (m *GroupMutation) ImagePrice1kCleared() bool {
|
||||
_, ok := m.clearedFields[group.FieldImagePrice1k]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetImagePrice1k resets all changes to the "image_price_1k" field.
|
||||
func (m *GroupMutation) ResetImagePrice1k() {
|
||||
m.image_price_1k = nil
|
||||
m.addimage_price_1k = nil
|
||||
delete(m.clearedFields, group.FieldImagePrice1k)
|
||||
}
|
||||
|
||||
// SetImagePrice2k sets the "image_price_2k" field.
|
||||
func (m *GroupMutation) SetImagePrice2k(f float64) {
|
||||
m.image_price_2k = &f
|
||||
m.addimage_price_2k = nil
|
||||
}
|
||||
|
||||
// ImagePrice2k returns the value of the "image_price_2k" field in the mutation.
|
||||
func (m *GroupMutation) ImagePrice2k() (r float64, exists bool) {
|
||||
v := m.image_price_2k
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldImagePrice2k returns the old "image_price_2k" field's value of the Group entity.
|
||||
// If the Group object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *GroupMutation) OldImagePrice2k(ctx context.Context) (v *float64, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldImagePrice2k is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldImagePrice2k requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldImagePrice2k: %w", err)
|
||||
}
|
||||
return oldValue.ImagePrice2k, nil
|
||||
}
|
||||
|
||||
// AddImagePrice2k adds f to the "image_price_2k" field.
|
||||
func (m *GroupMutation) AddImagePrice2k(f float64) {
|
||||
if m.addimage_price_2k != nil {
|
||||
*m.addimage_price_2k += f
|
||||
} else {
|
||||
m.addimage_price_2k = &f
|
||||
}
|
||||
}
|
||||
|
||||
// AddedImagePrice2k returns the value that was added to the "image_price_2k" field in this mutation.
|
||||
func (m *GroupMutation) AddedImagePrice2k() (r float64, exists bool) {
|
||||
v := m.addimage_price_2k
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// ClearImagePrice2k clears the value of the "image_price_2k" field.
|
||||
func (m *GroupMutation) ClearImagePrice2k() {
|
||||
m.image_price_2k = nil
|
||||
m.addimage_price_2k = nil
|
||||
m.clearedFields[group.FieldImagePrice2k] = struct{}{}
|
||||
}
|
||||
|
||||
// ImagePrice2kCleared returns if the "image_price_2k" field was cleared in this mutation.
|
||||
func (m *GroupMutation) ImagePrice2kCleared() bool {
|
||||
_, ok := m.clearedFields[group.FieldImagePrice2k]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetImagePrice2k resets all changes to the "image_price_2k" field.
|
||||
func (m *GroupMutation) ResetImagePrice2k() {
|
||||
m.image_price_2k = nil
|
||||
m.addimage_price_2k = nil
|
||||
delete(m.clearedFields, group.FieldImagePrice2k)
|
||||
}
|
||||
|
||||
// SetImagePrice4k sets the "image_price_4k" field.
|
||||
func (m *GroupMutation) SetImagePrice4k(f float64) {
|
||||
m.image_price_4k = &f
|
||||
m.addimage_price_4k = nil
|
||||
}
|
||||
|
||||
// ImagePrice4k returns the value of the "image_price_4k" field in the mutation.
|
||||
func (m *GroupMutation) ImagePrice4k() (r float64, exists bool) {
|
||||
v := m.image_price_4k
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldImagePrice4k returns the old "image_price_4k" field's value of the Group entity.
|
||||
// If the Group object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *GroupMutation) OldImagePrice4k(ctx context.Context) (v *float64, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldImagePrice4k is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldImagePrice4k requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldImagePrice4k: %w", err)
|
||||
}
|
||||
return oldValue.ImagePrice4k, nil
|
||||
}
|
||||
|
||||
// AddImagePrice4k adds f to the "image_price_4k" field.
|
||||
func (m *GroupMutation) AddImagePrice4k(f float64) {
|
||||
if m.addimage_price_4k != nil {
|
||||
*m.addimage_price_4k += f
|
||||
} else {
|
||||
m.addimage_price_4k = &f
|
||||
}
|
||||
}
|
||||
|
||||
// AddedImagePrice4k returns the value that was added to the "image_price_4k" field in this mutation.
|
||||
func (m *GroupMutation) AddedImagePrice4k() (r float64, exists bool) {
|
||||
v := m.addimage_price_4k
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// ClearImagePrice4k clears the value of the "image_price_4k" field.
|
||||
func (m *GroupMutation) ClearImagePrice4k() {
|
||||
m.image_price_4k = nil
|
||||
m.addimage_price_4k = nil
|
||||
m.clearedFields[group.FieldImagePrice4k] = struct{}{}
|
||||
}
|
||||
|
||||
// ImagePrice4kCleared returns if the "image_price_4k" field was cleared in this mutation.
|
||||
func (m *GroupMutation) ImagePrice4kCleared() bool {
|
||||
_, ok := m.clearedFields[group.FieldImagePrice4k]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetImagePrice4k resets all changes to the "image_price_4k" field.
|
||||
func (m *GroupMutation) ResetImagePrice4k() {
|
||||
m.image_price_4k = nil
|
||||
m.addimage_price_4k = nil
|
||||
delete(m.clearedFields, group.FieldImagePrice4k)
|
||||
}
|
||||
|
||||
// AddAPIKeyIDs adds the "api_keys" edge to the APIKey entity by ids.
|
||||
func (m *GroupMutation) AddAPIKeyIDs(ids ...int64) {
|
||||
if m.api_keys == nil {
|
||||
@@ -4536,7 +4752,7 @@ func (m *GroupMutation) Type() string {
|
||||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *GroupMutation) Fields() []string {
|
||||
fields := make([]string, 0, 14)
|
||||
fields := make([]string, 0, 17)
|
||||
if m.created_at != nil {
|
||||
fields = append(fields, group.FieldCreatedAt)
|
||||
}
|
||||
@@ -4579,6 +4795,15 @@ func (m *GroupMutation) Fields() []string {
|
||||
if m.default_validity_days != nil {
|
||||
fields = append(fields, group.FieldDefaultValidityDays)
|
||||
}
|
||||
if m.image_price_1k != nil {
|
||||
fields = append(fields, group.FieldImagePrice1k)
|
||||
}
|
||||
if m.image_price_2k != nil {
|
||||
fields = append(fields, group.FieldImagePrice2k)
|
||||
}
|
||||
if m.image_price_4k != nil {
|
||||
fields = append(fields, group.FieldImagePrice4k)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
@@ -4615,6 +4840,12 @@ func (m *GroupMutation) Field(name string) (ent.Value, bool) {
|
||||
return m.MonthlyLimitUsd()
|
||||
case group.FieldDefaultValidityDays:
|
||||
return m.DefaultValidityDays()
|
||||
case group.FieldImagePrice1k:
|
||||
return m.ImagePrice1k()
|
||||
case group.FieldImagePrice2k:
|
||||
return m.ImagePrice2k()
|
||||
case group.FieldImagePrice4k:
|
||||
return m.ImagePrice4k()
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
@@ -4652,6 +4883,12 @@ func (m *GroupMutation) OldField(ctx context.Context, name string) (ent.Value, e
|
||||
return m.OldMonthlyLimitUsd(ctx)
|
||||
case group.FieldDefaultValidityDays:
|
||||
return m.OldDefaultValidityDays(ctx)
|
||||
case group.FieldImagePrice1k:
|
||||
return m.OldImagePrice1k(ctx)
|
||||
case group.FieldImagePrice2k:
|
||||
return m.OldImagePrice2k(ctx)
|
||||
case group.FieldImagePrice4k:
|
||||
return m.OldImagePrice4k(ctx)
|
||||
}
|
||||
return nil, fmt.Errorf("unknown Group field %s", name)
|
||||
}
|
||||
@@ -4759,6 +4996,27 @@ func (m *GroupMutation) SetField(name string, value ent.Value) error {
|
||||
}
|
||||
m.SetDefaultValidityDays(v)
|
||||
return nil
|
||||
case group.FieldImagePrice1k:
|
||||
v, ok := value.(float64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetImagePrice1k(v)
|
||||
return nil
|
||||
case group.FieldImagePrice2k:
|
||||
v, ok := value.(float64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetImagePrice2k(v)
|
||||
return nil
|
||||
case group.FieldImagePrice4k:
|
||||
v, ok := value.(float64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetImagePrice4k(v)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Group field %s", name)
|
||||
}
|
||||
@@ -4782,6 +5040,15 @@ func (m *GroupMutation) AddedFields() []string {
|
||||
if m.adddefault_validity_days != nil {
|
||||
fields = append(fields, group.FieldDefaultValidityDays)
|
||||
}
|
||||
if m.addimage_price_1k != nil {
|
||||
fields = append(fields, group.FieldImagePrice1k)
|
||||
}
|
||||
if m.addimage_price_2k != nil {
|
||||
fields = append(fields, group.FieldImagePrice2k)
|
||||
}
|
||||
if m.addimage_price_4k != nil {
|
||||
fields = append(fields, group.FieldImagePrice4k)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
@@ -4800,6 +5067,12 @@ func (m *GroupMutation) AddedField(name string) (ent.Value, bool) {
|
||||
return m.AddedMonthlyLimitUsd()
|
||||
case group.FieldDefaultValidityDays:
|
||||
return m.AddedDefaultValidityDays()
|
||||
case group.FieldImagePrice1k:
|
||||
return m.AddedImagePrice1k()
|
||||
case group.FieldImagePrice2k:
|
||||
return m.AddedImagePrice2k()
|
||||
case group.FieldImagePrice4k:
|
||||
return m.AddedImagePrice4k()
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
@@ -4844,6 +5117,27 @@ func (m *GroupMutation) AddField(name string, value ent.Value) error {
|
||||
}
|
||||
m.AddDefaultValidityDays(v)
|
||||
return nil
|
||||
case group.FieldImagePrice1k:
|
||||
v, ok := value.(float64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.AddImagePrice1k(v)
|
||||
return nil
|
||||
case group.FieldImagePrice2k:
|
||||
v, ok := value.(float64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.AddImagePrice2k(v)
|
||||
return nil
|
||||
case group.FieldImagePrice4k:
|
||||
v, ok := value.(float64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.AddImagePrice4k(v)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Group numeric field %s", name)
|
||||
}
|
||||
@@ -4867,6 +5161,15 @@ func (m *GroupMutation) ClearedFields() []string {
|
||||
if m.FieldCleared(group.FieldMonthlyLimitUsd) {
|
||||
fields = append(fields, group.FieldMonthlyLimitUsd)
|
||||
}
|
||||
if m.FieldCleared(group.FieldImagePrice1k) {
|
||||
fields = append(fields, group.FieldImagePrice1k)
|
||||
}
|
||||
if m.FieldCleared(group.FieldImagePrice2k) {
|
||||
fields = append(fields, group.FieldImagePrice2k)
|
||||
}
|
||||
if m.FieldCleared(group.FieldImagePrice4k) {
|
||||
fields = append(fields, group.FieldImagePrice4k)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
@@ -4896,6 +5199,15 @@ func (m *GroupMutation) ClearField(name string) error {
|
||||
case group.FieldMonthlyLimitUsd:
|
||||
m.ClearMonthlyLimitUsd()
|
||||
return nil
|
||||
case group.FieldImagePrice1k:
|
||||
m.ClearImagePrice1k()
|
||||
return nil
|
||||
case group.FieldImagePrice2k:
|
||||
m.ClearImagePrice2k()
|
||||
return nil
|
||||
case group.FieldImagePrice4k:
|
||||
m.ClearImagePrice4k()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Group nullable field %s", name)
|
||||
}
|
||||
@@ -4946,6 +5258,15 @@ func (m *GroupMutation) ResetField(name string) error {
|
||||
case group.FieldDefaultValidityDays:
|
||||
m.ResetDefaultValidityDays()
|
||||
return nil
|
||||
case group.FieldImagePrice1k:
|
||||
m.ResetImagePrice1k()
|
||||
return nil
|
||||
case group.FieldImagePrice2k:
|
||||
m.ResetImagePrice2k()
|
||||
return nil
|
||||
case group.FieldImagePrice4k:
|
||||
m.ResetImagePrice4k()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Group field %s", name)
|
||||
}
|
||||
@@ -7713,6 +8034,9 @@ type UsageLogMutation struct {
|
||||
addduration_ms *int
|
||||
first_token_ms *int
|
||||
addfirst_token_ms *int
|
||||
image_count *int
|
||||
addimage_count *int
|
||||
image_size *string
|
||||
created_at *time.Time
|
||||
clearedFields map[string]struct{}
|
||||
user *int64
|
||||
@@ -9066,6 +9390,111 @@ func (m *UsageLogMutation) ResetFirstTokenMs() {
|
||||
delete(m.clearedFields, usagelog.FieldFirstTokenMs)
|
||||
}
|
||||
|
||||
// SetImageCount sets the "image_count" field.
|
||||
func (m *UsageLogMutation) SetImageCount(i int) {
|
||||
m.image_count = &i
|
||||
m.addimage_count = nil
|
||||
}
|
||||
|
||||
// ImageCount returns the value of the "image_count" field in the mutation.
|
||||
func (m *UsageLogMutation) ImageCount() (r int, exists bool) {
|
||||
v := m.image_count
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldImageCount returns the old "image_count" 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) OldImageCount(ctx context.Context) (v int, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldImageCount is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldImageCount requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldImageCount: %w", err)
|
||||
}
|
||||
return oldValue.ImageCount, nil
|
||||
}
|
||||
|
||||
// AddImageCount adds i to the "image_count" field.
|
||||
func (m *UsageLogMutation) AddImageCount(i int) {
|
||||
if m.addimage_count != nil {
|
||||
*m.addimage_count += i
|
||||
} else {
|
||||
m.addimage_count = &i
|
||||
}
|
||||
}
|
||||
|
||||
// AddedImageCount returns the value that was added to the "image_count" field in this mutation.
|
||||
func (m *UsageLogMutation) AddedImageCount() (r int, exists bool) {
|
||||
v := m.addimage_count
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// ResetImageCount resets all changes to the "image_count" field.
|
||||
func (m *UsageLogMutation) ResetImageCount() {
|
||||
m.image_count = nil
|
||||
m.addimage_count = nil
|
||||
}
|
||||
|
||||
// SetImageSize sets the "image_size" field.
|
||||
func (m *UsageLogMutation) SetImageSize(s string) {
|
||||
m.image_size = &s
|
||||
}
|
||||
|
||||
// ImageSize returns the value of the "image_size" field in the mutation.
|
||||
func (m *UsageLogMutation) ImageSize() (r string, exists bool) {
|
||||
v := m.image_size
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldImageSize returns the old "image_size" 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) OldImageSize(ctx context.Context) (v *string, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldImageSize is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldImageSize requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldImageSize: %w", err)
|
||||
}
|
||||
return oldValue.ImageSize, nil
|
||||
}
|
||||
|
||||
// ClearImageSize clears the value of the "image_size" field.
|
||||
func (m *UsageLogMutation) ClearImageSize() {
|
||||
m.image_size = nil
|
||||
m.clearedFields[usagelog.FieldImageSize] = struct{}{}
|
||||
}
|
||||
|
||||
// ImageSizeCleared returns if the "image_size" field was cleared in this mutation.
|
||||
func (m *UsageLogMutation) ImageSizeCleared() bool {
|
||||
_, ok := m.clearedFields[usagelog.FieldImageSize]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetImageSize resets all changes to the "image_size" field.
|
||||
func (m *UsageLogMutation) ResetImageSize() {
|
||||
m.image_size = nil
|
||||
delete(m.clearedFields, usagelog.FieldImageSize)
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (m *UsageLogMutation) SetCreatedAt(t time.Time) {
|
||||
m.created_at = &t
|
||||
@@ -9271,7 +9700,7 @@ func (m *UsageLogMutation) Type() string {
|
||||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *UsageLogMutation) Fields() []string {
|
||||
fields := make([]string, 0, 25)
|
||||
fields := make([]string, 0, 27)
|
||||
if m.user != nil {
|
||||
fields = append(fields, usagelog.FieldUserID)
|
||||
}
|
||||
@@ -9344,6 +9773,12 @@ func (m *UsageLogMutation) Fields() []string {
|
||||
if m.first_token_ms != nil {
|
||||
fields = append(fields, usagelog.FieldFirstTokenMs)
|
||||
}
|
||||
if m.image_count != nil {
|
||||
fields = append(fields, usagelog.FieldImageCount)
|
||||
}
|
||||
if m.image_size != nil {
|
||||
fields = append(fields, usagelog.FieldImageSize)
|
||||
}
|
||||
if m.created_at != nil {
|
||||
fields = append(fields, usagelog.FieldCreatedAt)
|
||||
}
|
||||
@@ -9403,6 +9838,10 @@ func (m *UsageLogMutation) Field(name string) (ent.Value, bool) {
|
||||
return m.DurationMs()
|
||||
case usagelog.FieldFirstTokenMs:
|
||||
return m.FirstTokenMs()
|
||||
case usagelog.FieldImageCount:
|
||||
return m.ImageCount()
|
||||
case usagelog.FieldImageSize:
|
||||
return m.ImageSize()
|
||||
case usagelog.FieldCreatedAt:
|
||||
return m.CreatedAt()
|
||||
}
|
||||
@@ -9462,6 +9901,10 @@ func (m *UsageLogMutation) OldField(ctx context.Context, name string) (ent.Value
|
||||
return m.OldDurationMs(ctx)
|
||||
case usagelog.FieldFirstTokenMs:
|
||||
return m.OldFirstTokenMs(ctx)
|
||||
case usagelog.FieldImageCount:
|
||||
return m.OldImageCount(ctx)
|
||||
case usagelog.FieldImageSize:
|
||||
return m.OldImageSize(ctx)
|
||||
case usagelog.FieldCreatedAt:
|
||||
return m.OldCreatedAt(ctx)
|
||||
}
|
||||
@@ -9641,6 +10084,20 @@ func (m *UsageLogMutation) SetField(name string, value ent.Value) error {
|
||||
}
|
||||
m.SetFirstTokenMs(v)
|
||||
return nil
|
||||
case usagelog.FieldImageCount:
|
||||
v, ok := value.(int)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetImageCount(v)
|
||||
return nil
|
||||
case usagelog.FieldImageSize:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetImageSize(v)
|
||||
return nil
|
||||
case usagelog.FieldCreatedAt:
|
||||
v, ok := value.(time.Time)
|
||||
if !ok {
|
||||
@@ -9704,6 +10161,9 @@ func (m *UsageLogMutation) AddedFields() []string {
|
||||
if m.addfirst_token_ms != nil {
|
||||
fields = append(fields, usagelog.FieldFirstTokenMs)
|
||||
}
|
||||
if m.addimage_count != nil {
|
||||
fields = append(fields, usagelog.FieldImageCount)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
@@ -9744,6 +10204,8 @@ func (m *UsageLogMutation) AddedField(name string) (ent.Value, bool) {
|
||||
return m.AddedDurationMs()
|
||||
case usagelog.FieldFirstTokenMs:
|
||||
return m.AddedFirstTokenMs()
|
||||
case usagelog.FieldImageCount:
|
||||
return m.AddedImageCount()
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
@@ -9865,6 +10327,13 @@ func (m *UsageLogMutation) AddField(name string, value ent.Value) error {
|
||||
}
|
||||
m.AddFirstTokenMs(v)
|
||||
return nil
|
||||
case usagelog.FieldImageCount:
|
||||
v, ok := value.(int)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.AddImageCount(v)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown UsageLog numeric field %s", name)
|
||||
}
|
||||
@@ -9885,6 +10354,9 @@ func (m *UsageLogMutation) ClearedFields() []string {
|
||||
if m.FieldCleared(usagelog.FieldFirstTokenMs) {
|
||||
fields = append(fields, usagelog.FieldFirstTokenMs)
|
||||
}
|
||||
if m.FieldCleared(usagelog.FieldImageSize) {
|
||||
fields = append(fields, usagelog.FieldImageSize)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
@@ -9911,6 +10383,9 @@ func (m *UsageLogMutation) ClearField(name string) error {
|
||||
case usagelog.FieldFirstTokenMs:
|
||||
m.ClearFirstTokenMs()
|
||||
return nil
|
||||
case usagelog.FieldImageSize:
|
||||
m.ClearImageSize()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown UsageLog nullable field %s", name)
|
||||
}
|
||||
@@ -9991,6 +10466,12 @@ func (m *UsageLogMutation) ResetField(name string) error {
|
||||
case usagelog.FieldFirstTokenMs:
|
||||
m.ResetFirstTokenMs()
|
||||
return nil
|
||||
case usagelog.FieldImageCount:
|
||||
m.ResetImageCount()
|
||||
return nil
|
||||
case usagelog.FieldImageSize:
|
||||
m.ResetImageSize()
|
||||
return nil
|
||||
case usagelog.FieldCreatedAt:
|
||||
m.ResetCreatedAt()
|
||||
return nil
|
||||
|
||||
@@ -521,8 +521,16 @@ func init() {
|
||||
usagelogDescStream := usagelogFields[21].Descriptor()
|
||||
// usagelog.DefaultStream holds the default value on creation for the stream field.
|
||||
usagelog.DefaultStream = usagelogDescStream.Default.(bool)
|
||||
// usagelogDescImageCount is the schema descriptor for image_count field.
|
||||
usagelogDescImageCount := usagelogFields[24].Descriptor()
|
||||
// usagelog.DefaultImageCount holds the default value on creation for the image_count field.
|
||||
usagelog.DefaultImageCount = usagelogDescImageCount.Default.(int)
|
||||
// usagelogDescImageSize is the schema descriptor for image_size field.
|
||||
usagelogDescImageSize := usagelogFields[25].Descriptor()
|
||||
// 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)
|
||||
// usagelogDescCreatedAt is the schema descriptor for created_at field.
|
||||
usagelogDescCreatedAt := usagelogFields[24].Descriptor()
|
||||
usagelogDescCreatedAt := usagelogFields[26].Descriptor()
|
||||
// usagelog.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
usagelog.DefaultCreatedAt = usagelogDescCreatedAt.Default.(func() time.Time)
|
||||
userMixin := schema.User{}.Mixin()
|
||||
|
||||
@@ -72,6 +72,20 @@ func (Group) Fields() []ent.Field {
|
||||
SchemaType(map[string]string{dialect.Postgres: "decimal(20,8)"}),
|
||||
field.Int("default_validity_days").
|
||||
Default(30),
|
||||
|
||||
// 图片生成计费配置(antigravity 和 gemini 平台使用)
|
||||
field.Float("image_price_1k").
|
||||
Optional().
|
||||
Nillable().
|
||||
SchemaType(map[string]string{dialect.Postgres: "decimal(20,8)"}),
|
||||
field.Float("image_price_2k").
|
||||
Optional().
|
||||
Nillable().
|
||||
SchemaType(map[string]string{dialect.Postgres: "decimal(20,8)"}),
|
||||
field.Float("image_price_4k").
|
||||
Optional().
|
||||
Nillable().
|
||||
SchemaType(map[string]string{dialect.Postgres: "decimal(20,8)"}),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -97,6 +97,14 @@ func (UsageLog) Fields() []ent.Field {
|
||||
Optional().
|
||||
Nillable(),
|
||||
|
||||
// 图片生成字段(仅 gemini-3-pro-image 等图片模型使用)
|
||||
field.Int("image_count").
|
||||
Default(0),
|
||||
field.String("image_size").
|
||||
MaxLen(10).
|
||||
Optional().
|
||||
Nillable(),
|
||||
|
||||
// 时间戳(只有 created_at,日志不可修改)
|
||||
field.Time("created_at").
|
||||
Default(time.Now).
|
||||
|
||||
@@ -70,6 +70,10 @@ type UsageLog struct {
|
||||
DurationMs *int `json:"duration_ms,omitempty"`
|
||||
// FirstTokenMs holds the value of the "first_token_ms" field.
|
||||
FirstTokenMs *int `json:"first_token_ms,omitempty"`
|
||||
// ImageCount holds the value of the "image_count" field.
|
||||
ImageCount int `json:"image_count,omitempty"`
|
||||
// ImageSize holds the value of the "image_size" field.
|
||||
ImageSize *string `json:"image_size,omitempty"`
|
||||
// CreatedAt holds the value of the "created_at" field.
|
||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
@@ -159,9 +163,9 @@ func (*UsageLog) scanValues(columns []string) ([]any, error) {
|
||||
values[i] = new(sql.NullBool)
|
||||
case usagelog.FieldInputCost, usagelog.FieldOutputCost, usagelog.FieldCacheCreationCost, usagelog.FieldCacheReadCost, usagelog.FieldTotalCost, usagelog.FieldActualCost, usagelog.FieldRateMultiplier:
|
||||
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:
|
||||
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)
|
||||
case usagelog.FieldRequestID, usagelog.FieldModel:
|
||||
case usagelog.FieldRequestID, usagelog.FieldModel, usagelog.FieldImageSize:
|
||||
values[i] = new(sql.NullString)
|
||||
case usagelog.FieldCreatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
@@ -334,6 +338,19 @@ func (_m *UsageLog) assignValues(columns []string, values []any) error {
|
||||
_m.FirstTokenMs = new(int)
|
||||
*_m.FirstTokenMs = int(value.Int64)
|
||||
}
|
||||
case usagelog.FieldImageCount:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field image_count", values[i])
|
||||
} else if value.Valid {
|
||||
_m.ImageCount = int(value.Int64)
|
||||
}
|
||||
case usagelog.FieldImageSize:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field image_size", values[i])
|
||||
} else if value.Valid {
|
||||
_m.ImageSize = new(string)
|
||||
*_m.ImageSize = value.String
|
||||
}
|
||||
case usagelog.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
@@ -481,6 +498,14 @@ func (_m *UsageLog) String() string {
|
||||
builder.WriteString(fmt.Sprintf("%v", *v))
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("image_count=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.ImageCount))
|
||||
builder.WriteString(", ")
|
||||
if v := _m.ImageSize; v != nil {
|
||||
builder.WriteString("image_size=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
|
||||
@@ -62,6 +62,10 @@ const (
|
||||
FieldDurationMs = "duration_ms"
|
||||
// FieldFirstTokenMs holds the string denoting the first_token_ms field in the database.
|
||||
FieldFirstTokenMs = "first_token_ms"
|
||||
// FieldImageCount holds the string denoting the image_count field in the database.
|
||||
FieldImageCount = "image_count"
|
||||
// FieldImageSize holds the string denoting the image_size field in the database.
|
||||
FieldImageSize = "image_size"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// EdgeUser holds the string denoting the user edge name in mutations.
|
||||
@@ -140,6 +144,8 @@ var Columns = []string{
|
||||
FieldStream,
|
||||
FieldDurationMs,
|
||||
FieldFirstTokenMs,
|
||||
FieldImageCount,
|
||||
FieldImageSize,
|
||||
FieldCreatedAt,
|
||||
}
|
||||
|
||||
@@ -188,6 +194,10 @@ var (
|
||||
DefaultBillingType int8
|
||||
// DefaultStream holds the default value on creation for the "stream" field.
|
||||
DefaultStream bool
|
||||
// DefaultImageCount holds the default value on creation for the "image_count" field.
|
||||
DefaultImageCount int
|
||||
// ImageSizeValidator is a validator for the "image_size" field. It is called by the builders before save.
|
||||
ImageSizeValidator func(string) error
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
DefaultCreatedAt func() time.Time
|
||||
)
|
||||
@@ -320,6 +330,16 @@ func ByFirstTokenMs(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldFirstTokenMs, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByImageCount orders the results by the image_count field.
|
||||
func ByImageCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldImageCount, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByImageSize orders the results by the image_size field.
|
||||
func ByImageSize(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldImageSize, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
|
||||
@@ -175,6 +175,16 @@ func FirstTokenMs(v int) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldEQ(FieldFirstTokenMs, v))
|
||||
}
|
||||
|
||||
// ImageCount applies equality check predicate on the "image_count" field. It's identical to ImageCountEQ.
|
||||
func ImageCount(v int) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldEQ(FieldImageCount, v))
|
||||
}
|
||||
|
||||
// ImageSize applies equality check predicate on the "image_size" field. It's identical to ImageSizeEQ.
|
||||
func ImageSize(v string) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldEQ(FieldImageSize, v))
|
||||
}
|
||||
|
||||
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||
func CreatedAt(v time.Time) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldEQ(FieldCreatedAt, v))
|
||||
@@ -1100,6 +1110,121 @@ func FirstTokenMsNotNil() predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldNotNull(FieldFirstTokenMs))
|
||||
}
|
||||
|
||||
// ImageCountEQ applies the EQ predicate on the "image_count" field.
|
||||
func ImageCountEQ(v int) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldEQ(FieldImageCount, v))
|
||||
}
|
||||
|
||||
// ImageCountNEQ applies the NEQ predicate on the "image_count" field.
|
||||
func ImageCountNEQ(v int) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldNEQ(FieldImageCount, v))
|
||||
}
|
||||
|
||||
// ImageCountIn applies the In predicate on the "image_count" field.
|
||||
func ImageCountIn(vs ...int) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldIn(FieldImageCount, vs...))
|
||||
}
|
||||
|
||||
// ImageCountNotIn applies the NotIn predicate on the "image_count" field.
|
||||
func ImageCountNotIn(vs ...int) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldNotIn(FieldImageCount, vs...))
|
||||
}
|
||||
|
||||
// ImageCountGT applies the GT predicate on the "image_count" field.
|
||||
func ImageCountGT(v int) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldGT(FieldImageCount, v))
|
||||
}
|
||||
|
||||
// ImageCountGTE applies the GTE predicate on the "image_count" field.
|
||||
func ImageCountGTE(v int) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldGTE(FieldImageCount, v))
|
||||
}
|
||||
|
||||
// ImageCountLT applies the LT predicate on the "image_count" field.
|
||||
func ImageCountLT(v int) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldLT(FieldImageCount, v))
|
||||
}
|
||||
|
||||
// ImageCountLTE applies the LTE predicate on the "image_count" field.
|
||||
func ImageCountLTE(v int) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldLTE(FieldImageCount, v))
|
||||
}
|
||||
|
||||
// ImageSizeEQ applies the EQ predicate on the "image_size" field.
|
||||
func ImageSizeEQ(v string) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldEQ(FieldImageSize, v))
|
||||
}
|
||||
|
||||
// ImageSizeNEQ applies the NEQ predicate on the "image_size" field.
|
||||
func ImageSizeNEQ(v string) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldNEQ(FieldImageSize, v))
|
||||
}
|
||||
|
||||
// ImageSizeIn applies the In predicate on the "image_size" field.
|
||||
func ImageSizeIn(vs ...string) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldIn(FieldImageSize, vs...))
|
||||
}
|
||||
|
||||
// ImageSizeNotIn applies the NotIn predicate on the "image_size" field.
|
||||
func ImageSizeNotIn(vs ...string) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldNotIn(FieldImageSize, vs...))
|
||||
}
|
||||
|
||||
// ImageSizeGT applies the GT predicate on the "image_size" field.
|
||||
func ImageSizeGT(v string) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldGT(FieldImageSize, v))
|
||||
}
|
||||
|
||||
// ImageSizeGTE applies the GTE predicate on the "image_size" field.
|
||||
func ImageSizeGTE(v string) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldGTE(FieldImageSize, v))
|
||||
}
|
||||
|
||||
// ImageSizeLT applies the LT predicate on the "image_size" field.
|
||||
func ImageSizeLT(v string) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldLT(FieldImageSize, v))
|
||||
}
|
||||
|
||||
// ImageSizeLTE applies the LTE predicate on the "image_size" field.
|
||||
func ImageSizeLTE(v string) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldLTE(FieldImageSize, v))
|
||||
}
|
||||
|
||||
// ImageSizeContains applies the Contains predicate on the "image_size" field.
|
||||
func ImageSizeContains(v string) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldContains(FieldImageSize, v))
|
||||
}
|
||||
|
||||
// ImageSizeHasPrefix applies the HasPrefix predicate on the "image_size" field.
|
||||
func ImageSizeHasPrefix(v string) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldHasPrefix(FieldImageSize, v))
|
||||
}
|
||||
|
||||
// ImageSizeHasSuffix applies the HasSuffix predicate on the "image_size" field.
|
||||
func ImageSizeHasSuffix(v string) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldHasSuffix(FieldImageSize, v))
|
||||
}
|
||||
|
||||
// ImageSizeIsNil applies the IsNil predicate on the "image_size" field.
|
||||
func ImageSizeIsNil() predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldIsNull(FieldImageSize))
|
||||
}
|
||||
|
||||
// ImageSizeNotNil applies the NotNil predicate on the "image_size" field.
|
||||
func ImageSizeNotNil() predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldNotNull(FieldImageSize))
|
||||
}
|
||||
|
||||
// ImageSizeEqualFold applies the EqualFold predicate on the "image_size" field.
|
||||
func ImageSizeEqualFold(v string) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldEqualFold(FieldImageSize, v))
|
||||
}
|
||||
|
||||
// ImageSizeContainsFold applies the ContainsFold predicate on the "image_size" field.
|
||||
func ImageSizeContainsFold(v string) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldContainsFold(FieldImageSize, v))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v time.Time) predicate.UsageLog {
|
||||
return predicate.UsageLog(sql.FieldEQ(FieldCreatedAt, v))
|
||||
|
||||
@@ -323,6 +323,34 @@ func (_c *UsageLogCreate) SetNillableFirstTokenMs(v *int) *UsageLogCreate {
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetImageCount sets the "image_count" field.
|
||||
func (_c *UsageLogCreate) SetImageCount(v int) *UsageLogCreate {
|
||||
_c.mutation.SetImageCount(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableImageCount sets the "image_count" field if the given value is not nil.
|
||||
func (_c *UsageLogCreate) SetNillableImageCount(v *int) *UsageLogCreate {
|
||||
if v != nil {
|
||||
_c.SetImageCount(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetImageSize sets the "image_size" field.
|
||||
func (_c *UsageLogCreate) SetImageSize(v string) *UsageLogCreate {
|
||||
_c.mutation.SetImageSize(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableImageSize sets the "image_size" field if the given value is not nil.
|
||||
func (_c *UsageLogCreate) SetNillableImageSize(v *string) *UsageLogCreate {
|
||||
if v != nil {
|
||||
_c.SetImageSize(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_c *UsageLogCreate) SetCreatedAt(v time.Time) *UsageLogCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
@@ -457,6 +485,10 @@ func (_c *UsageLogCreate) defaults() {
|
||||
v := usagelog.DefaultStream
|
||||
_c.mutation.SetStream(v)
|
||||
}
|
||||
if _, ok := _c.mutation.ImageCount(); !ok {
|
||||
v := usagelog.DefaultImageCount
|
||||
_c.mutation.SetImageCount(v)
|
||||
}
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
v := usagelog.DefaultCreatedAt()
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
@@ -535,6 +567,14 @@ func (_c *UsageLogCreate) check() error {
|
||||
if _, ok := _c.mutation.Stream(); !ok {
|
||||
return &ValidationError{Name: "stream", err: errors.New(`ent: missing required field "UsageLog.stream"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.ImageCount(); !ok {
|
||||
return &ValidationError{Name: "image_count", err: errors.New(`ent: missing required field "UsageLog.image_count"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.ImageSize(); ok {
|
||||
if err := usagelog.ImageSizeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "image_size", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_size": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "UsageLog.created_at"`)}
|
||||
}
|
||||
@@ -650,6 +690,14 @@ func (_c *UsageLogCreate) createSpec() (*UsageLog, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(usagelog.FieldFirstTokenMs, field.TypeInt, value)
|
||||
_node.FirstTokenMs = &value
|
||||
}
|
||||
if value, ok := _c.mutation.ImageCount(); ok {
|
||||
_spec.SetField(usagelog.FieldImageCount, field.TypeInt, value)
|
||||
_node.ImageCount = value
|
||||
}
|
||||
if value, ok := _c.mutation.ImageSize(); ok {
|
||||
_spec.SetField(usagelog.FieldImageSize, field.TypeString, value)
|
||||
_node.ImageSize = &value
|
||||
}
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(usagelog.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
@@ -1199,6 +1247,42 @@ func (u *UsageLogUpsert) ClearFirstTokenMs() *UsageLogUpsert {
|
||||
return u
|
||||
}
|
||||
|
||||
// SetImageCount sets the "image_count" field.
|
||||
func (u *UsageLogUpsert) SetImageCount(v int) *UsageLogUpsert {
|
||||
u.Set(usagelog.FieldImageCount, v)
|
||||
return u
|
||||
}
|
||||
|
||||
// UpdateImageCount sets the "image_count" field to the value that was provided on create.
|
||||
func (u *UsageLogUpsert) UpdateImageCount() *UsageLogUpsert {
|
||||
u.SetExcluded(usagelog.FieldImageCount)
|
||||
return u
|
||||
}
|
||||
|
||||
// AddImageCount adds v to the "image_count" field.
|
||||
func (u *UsageLogUpsert) AddImageCount(v int) *UsageLogUpsert {
|
||||
u.Add(usagelog.FieldImageCount, v)
|
||||
return u
|
||||
}
|
||||
|
||||
// SetImageSize sets the "image_size" field.
|
||||
func (u *UsageLogUpsert) SetImageSize(v string) *UsageLogUpsert {
|
||||
u.Set(usagelog.FieldImageSize, v)
|
||||
return u
|
||||
}
|
||||
|
||||
// UpdateImageSize sets the "image_size" field to the value that was provided on create.
|
||||
func (u *UsageLogUpsert) UpdateImageSize() *UsageLogUpsert {
|
||||
u.SetExcluded(usagelog.FieldImageSize)
|
||||
return u
|
||||
}
|
||||
|
||||
// ClearImageSize clears the value of the "image_size" field.
|
||||
func (u *UsageLogUpsert) ClearImageSize() *UsageLogUpsert {
|
||||
u.SetNull(usagelog.FieldImageSize)
|
||||
return u
|
||||
}
|
||||
|
||||
// UpdateNewValues updates the mutable fields using the new values that were set on create.
|
||||
// Using this option is equivalent to using:
|
||||
//
|
||||
@@ -1720,6 +1804,48 @@ func (u *UsageLogUpsertOne) ClearFirstTokenMs() *UsageLogUpsertOne {
|
||||
})
|
||||
}
|
||||
|
||||
// SetImageCount sets the "image_count" field.
|
||||
func (u *UsageLogUpsertOne) SetImageCount(v int) *UsageLogUpsertOne {
|
||||
return u.Update(func(s *UsageLogUpsert) {
|
||||
s.SetImageCount(v)
|
||||
})
|
||||
}
|
||||
|
||||
// AddImageCount adds v to the "image_count" field.
|
||||
func (u *UsageLogUpsertOne) AddImageCount(v int) *UsageLogUpsertOne {
|
||||
return u.Update(func(s *UsageLogUpsert) {
|
||||
s.AddImageCount(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateImageCount sets the "image_count" field to the value that was provided on create.
|
||||
func (u *UsageLogUpsertOne) UpdateImageCount() *UsageLogUpsertOne {
|
||||
return u.Update(func(s *UsageLogUpsert) {
|
||||
s.UpdateImageCount()
|
||||
})
|
||||
}
|
||||
|
||||
// SetImageSize sets the "image_size" field.
|
||||
func (u *UsageLogUpsertOne) SetImageSize(v string) *UsageLogUpsertOne {
|
||||
return u.Update(func(s *UsageLogUpsert) {
|
||||
s.SetImageSize(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateImageSize sets the "image_size" field to the value that was provided on create.
|
||||
func (u *UsageLogUpsertOne) UpdateImageSize() *UsageLogUpsertOne {
|
||||
return u.Update(func(s *UsageLogUpsert) {
|
||||
s.UpdateImageSize()
|
||||
})
|
||||
}
|
||||
|
||||
// ClearImageSize clears the value of the "image_size" field.
|
||||
func (u *UsageLogUpsertOne) ClearImageSize() *UsageLogUpsertOne {
|
||||
return u.Update(func(s *UsageLogUpsert) {
|
||||
s.ClearImageSize()
|
||||
})
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (u *UsageLogUpsertOne) Exec(ctx context.Context) error {
|
||||
if len(u.create.conflict) == 0 {
|
||||
@@ -2407,6 +2533,48 @@ func (u *UsageLogUpsertBulk) ClearFirstTokenMs() *UsageLogUpsertBulk {
|
||||
})
|
||||
}
|
||||
|
||||
// SetImageCount sets the "image_count" field.
|
||||
func (u *UsageLogUpsertBulk) SetImageCount(v int) *UsageLogUpsertBulk {
|
||||
return u.Update(func(s *UsageLogUpsert) {
|
||||
s.SetImageCount(v)
|
||||
})
|
||||
}
|
||||
|
||||
// AddImageCount adds v to the "image_count" field.
|
||||
func (u *UsageLogUpsertBulk) AddImageCount(v int) *UsageLogUpsertBulk {
|
||||
return u.Update(func(s *UsageLogUpsert) {
|
||||
s.AddImageCount(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateImageCount sets the "image_count" field to the value that was provided on create.
|
||||
func (u *UsageLogUpsertBulk) UpdateImageCount() *UsageLogUpsertBulk {
|
||||
return u.Update(func(s *UsageLogUpsert) {
|
||||
s.UpdateImageCount()
|
||||
})
|
||||
}
|
||||
|
||||
// SetImageSize sets the "image_size" field.
|
||||
func (u *UsageLogUpsertBulk) SetImageSize(v string) *UsageLogUpsertBulk {
|
||||
return u.Update(func(s *UsageLogUpsert) {
|
||||
s.SetImageSize(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateImageSize sets the "image_size" field to the value that was provided on create.
|
||||
func (u *UsageLogUpsertBulk) UpdateImageSize() *UsageLogUpsertBulk {
|
||||
return u.Update(func(s *UsageLogUpsert) {
|
||||
s.UpdateImageSize()
|
||||
})
|
||||
}
|
||||
|
||||
// ClearImageSize clears the value of the "image_size" field.
|
||||
func (u *UsageLogUpsertBulk) ClearImageSize() *UsageLogUpsertBulk {
|
||||
return u.Update(func(s *UsageLogUpsert) {
|
||||
s.ClearImageSize()
|
||||
})
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (u *UsageLogUpsertBulk) Exec(ctx context.Context) error {
|
||||
if u.create.err != nil {
|
||||
|
||||
@@ -504,6 +504,47 @@ func (_u *UsageLogUpdate) ClearFirstTokenMs() *UsageLogUpdate {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetImageCount sets the "image_count" field.
|
||||
func (_u *UsageLogUpdate) SetImageCount(v int) *UsageLogUpdate {
|
||||
_u.mutation.ResetImageCount()
|
||||
_u.mutation.SetImageCount(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableImageCount sets the "image_count" field if the given value is not nil.
|
||||
func (_u *UsageLogUpdate) SetNillableImageCount(v *int) *UsageLogUpdate {
|
||||
if v != nil {
|
||||
_u.SetImageCount(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddImageCount adds value to the "image_count" field.
|
||||
func (_u *UsageLogUpdate) AddImageCount(v int) *UsageLogUpdate {
|
||||
_u.mutation.AddImageCount(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetImageSize sets the "image_size" field.
|
||||
func (_u *UsageLogUpdate) SetImageSize(v string) *UsageLogUpdate {
|
||||
_u.mutation.SetImageSize(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableImageSize sets the "image_size" field if the given value is not nil.
|
||||
func (_u *UsageLogUpdate) SetNillableImageSize(v *string) *UsageLogUpdate {
|
||||
if v != nil {
|
||||
_u.SetImageSize(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearImageSize clears the value of the "image_size" field.
|
||||
func (_u *UsageLogUpdate) ClearImageSize() *UsageLogUpdate {
|
||||
_u.mutation.ClearImageSize()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUser sets the "user" edge to the User entity.
|
||||
func (_u *UsageLogUpdate) SetUser(v *User) *UsageLogUpdate {
|
||||
return _u.SetUserID(v.ID)
|
||||
@@ -603,6 +644,11 @@ func (_u *UsageLogUpdate) check() error {
|
||||
return &ValidationError{Name: "model", err: fmt.Errorf(`ent: validator failed for field "UsageLog.model": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.ImageSize(); ok {
|
||||
if err := usagelog.ImageSizeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "image_size", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_size": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 {
|
||||
return errors.New(`ent: clearing a required unique edge "UsageLog.user"`)
|
||||
}
|
||||
@@ -738,6 +784,18 @@ func (_u *UsageLogUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if _u.mutation.FirstTokenMsCleared() {
|
||||
_spec.ClearField(usagelog.FieldFirstTokenMs, field.TypeInt)
|
||||
}
|
||||
if value, ok := _u.mutation.ImageCount(); ok {
|
||||
_spec.SetField(usagelog.FieldImageCount, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedImageCount(); ok {
|
||||
_spec.AddField(usagelog.FieldImageCount, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.ImageSize(); ok {
|
||||
_spec.SetField(usagelog.FieldImageSize, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.ImageSizeCleared() {
|
||||
_spec.ClearField(usagelog.FieldImageSize, field.TypeString)
|
||||
}
|
||||
if _u.mutation.UserCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
@@ -1375,6 +1433,47 @@ func (_u *UsageLogUpdateOne) ClearFirstTokenMs() *UsageLogUpdateOne {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetImageCount sets the "image_count" field.
|
||||
func (_u *UsageLogUpdateOne) SetImageCount(v int) *UsageLogUpdateOne {
|
||||
_u.mutation.ResetImageCount()
|
||||
_u.mutation.SetImageCount(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableImageCount sets the "image_count" field if the given value is not nil.
|
||||
func (_u *UsageLogUpdateOne) SetNillableImageCount(v *int) *UsageLogUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetImageCount(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddImageCount adds value to the "image_count" field.
|
||||
func (_u *UsageLogUpdateOne) AddImageCount(v int) *UsageLogUpdateOne {
|
||||
_u.mutation.AddImageCount(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetImageSize sets the "image_size" field.
|
||||
func (_u *UsageLogUpdateOne) SetImageSize(v string) *UsageLogUpdateOne {
|
||||
_u.mutation.SetImageSize(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableImageSize sets the "image_size" field if the given value is not nil.
|
||||
func (_u *UsageLogUpdateOne) SetNillableImageSize(v *string) *UsageLogUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetImageSize(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearImageSize clears the value of the "image_size" field.
|
||||
func (_u *UsageLogUpdateOne) ClearImageSize() *UsageLogUpdateOne {
|
||||
_u.mutation.ClearImageSize()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUser sets the "user" edge to the User entity.
|
||||
func (_u *UsageLogUpdateOne) SetUser(v *User) *UsageLogUpdateOne {
|
||||
return _u.SetUserID(v.ID)
|
||||
@@ -1487,6 +1586,11 @@ func (_u *UsageLogUpdateOne) check() error {
|
||||
return &ValidationError{Name: "model", err: fmt.Errorf(`ent: validator failed for field "UsageLog.model": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.ImageSize(); ok {
|
||||
if err := usagelog.ImageSizeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "image_size", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_size": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 {
|
||||
return errors.New(`ent: clearing a required unique edge "UsageLog.user"`)
|
||||
}
|
||||
@@ -1639,6 +1743,18 @@ func (_u *UsageLogUpdateOne) sqlSave(ctx context.Context) (_node *UsageLog, err
|
||||
if _u.mutation.FirstTokenMsCleared() {
|
||||
_spec.ClearField(usagelog.FieldFirstTokenMs, field.TypeInt)
|
||||
}
|
||||
if value, ok := _u.mutation.ImageCount(); ok {
|
||||
_spec.SetField(usagelog.FieldImageCount, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedImageCount(); ok {
|
||||
_spec.AddField(usagelog.FieldImageCount, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.ImageSize(); ok {
|
||||
_spec.SetField(usagelog.FieldImageSize, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.ImageSizeCleared() {
|
||||
_spec.ClearField(usagelog.FieldImageSize, field.TypeString)
|
||||
}
|
||||
if _u.mutation.UserCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
|
||||
Reference in New Issue
Block a user