feat: 图片生成计费功能
- 新增 Group 图片价格配置(image_price_1k/2k/4k) - BillingService 新增 CalculateImageCost 方法 - AntigravityGatewayService 支持识别图片生成模型并按次计费 - UsageLog 新增 image_count 和 image_size 字段 - 前端分组管理支持配置图片价格(antigravity 和 gemini 平台) - 图片计费复用通用计费能力(余额检查、扣费、倍率、订阅限额)
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user