Files
xinghuoapi/backend/ent/promocodeusage/where.go
long d2fc14fb97 feat: 实现注册优惠码功能
- 支持创建/编辑/删除优惠码,设置赠送金额和使用限制
  - 注册页面实时验证优惠码并显示赠送金额
  - 支持 URL 参数自动填充 (?promo=CODE)
  - 添加优惠码验证接口速率限制
  - 使用数据库行锁防止并发超限
  - 新增后台优惠码管理页面,支持复制注册链接
2026-01-10 13:14:35 +08:00

258 lines
9.0 KiB
Go

// Code generated by ent, DO NOT EDIT.
package promocodeusage
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// ID filters vertices based on their ID field.
func ID(id int64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldLTE(FieldID, id))
}
// PromoCodeID applies equality check predicate on the "promo_code_id" field. It's identical to PromoCodeIDEQ.
func PromoCodeID(v int64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldEQ(FieldPromoCodeID, v))
}
// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ.
func UserID(v int64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldEQ(FieldUserID, v))
}
// BonusAmount applies equality check predicate on the "bonus_amount" field. It's identical to BonusAmountEQ.
func BonusAmount(v float64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldEQ(FieldBonusAmount, v))
}
// UsedAt applies equality check predicate on the "used_at" field. It's identical to UsedAtEQ.
func UsedAt(v time.Time) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldEQ(FieldUsedAt, v))
}
// PromoCodeIDEQ applies the EQ predicate on the "promo_code_id" field.
func PromoCodeIDEQ(v int64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldEQ(FieldPromoCodeID, v))
}
// PromoCodeIDNEQ applies the NEQ predicate on the "promo_code_id" field.
func PromoCodeIDNEQ(v int64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldNEQ(FieldPromoCodeID, v))
}
// PromoCodeIDIn applies the In predicate on the "promo_code_id" field.
func PromoCodeIDIn(vs ...int64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldIn(FieldPromoCodeID, vs...))
}
// PromoCodeIDNotIn applies the NotIn predicate on the "promo_code_id" field.
func PromoCodeIDNotIn(vs ...int64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldNotIn(FieldPromoCodeID, vs...))
}
// UserIDEQ applies the EQ predicate on the "user_id" field.
func UserIDEQ(v int64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldEQ(FieldUserID, v))
}
// UserIDNEQ applies the NEQ predicate on the "user_id" field.
func UserIDNEQ(v int64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldNEQ(FieldUserID, v))
}
// UserIDIn applies the In predicate on the "user_id" field.
func UserIDIn(vs ...int64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldIn(FieldUserID, vs...))
}
// UserIDNotIn applies the NotIn predicate on the "user_id" field.
func UserIDNotIn(vs ...int64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldNotIn(FieldUserID, vs...))
}
// BonusAmountEQ applies the EQ predicate on the "bonus_amount" field.
func BonusAmountEQ(v float64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldEQ(FieldBonusAmount, v))
}
// BonusAmountNEQ applies the NEQ predicate on the "bonus_amount" field.
func BonusAmountNEQ(v float64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldNEQ(FieldBonusAmount, v))
}
// BonusAmountIn applies the In predicate on the "bonus_amount" field.
func BonusAmountIn(vs ...float64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldIn(FieldBonusAmount, vs...))
}
// BonusAmountNotIn applies the NotIn predicate on the "bonus_amount" field.
func BonusAmountNotIn(vs ...float64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldNotIn(FieldBonusAmount, vs...))
}
// BonusAmountGT applies the GT predicate on the "bonus_amount" field.
func BonusAmountGT(v float64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldGT(FieldBonusAmount, v))
}
// BonusAmountGTE applies the GTE predicate on the "bonus_amount" field.
func BonusAmountGTE(v float64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldGTE(FieldBonusAmount, v))
}
// BonusAmountLT applies the LT predicate on the "bonus_amount" field.
func BonusAmountLT(v float64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldLT(FieldBonusAmount, v))
}
// BonusAmountLTE applies the LTE predicate on the "bonus_amount" field.
func BonusAmountLTE(v float64) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldLTE(FieldBonusAmount, v))
}
// UsedAtEQ applies the EQ predicate on the "used_at" field.
func UsedAtEQ(v time.Time) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldEQ(FieldUsedAt, v))
}
// UsedAtNEQ applies the NEQ predicate on the "used_at" field.
func UsedAtNEQ(v time.Time) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldNEQ(FieldUsedAt, v))
}
// UsedAtIn applies the In predicate on the "used_at" field.
func UsedAtIn(vs ...time.Time) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldIn(FieldUsedAt, vs...))
}
// UsedAtNotIn applies the NotIn predicate on the "used_at" field.
func UsedAtNotIn(vs ...time.Time) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldNotIn(FieldUsedAt, vs...))
}
// UsedAtGT applies the GT predicate on the "used_at" field.
func UsedAtGT(v time.Time) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldGT(FieldUsedAt, v))
}
// UsedAtGTE applies the GTE predicate on the "used_at" field.
func UsedAtGTE(v time.Time) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldGTE(FieldUsedAt, v))
}
// UsedAtLT applies the LT predicate on the "used_at" field.
func UsedAtLT(v time.Time) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldLT(FieldUsedAt, v))
}
// UsedAtLTE applies the LTE predicate on the "used_at" field.
func UsedAtLTE(v time.Time) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.FieldLTE(FieldUsedAt, v))
}
// HasPromoCode applies the HasEdge predicate on the "promo_code" edge.
func HasPromoCode() predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, PromoCodeTable, PromoCodeColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasPromoCodeWith applies the HasEdge predicate on the "promo_code" edge with a given conditions (other predicates).
func HasPromoCodeWith(preds ...predicate.PromoCode) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(func(s *sql.Selector) {
step := newPromoCodeStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// HasUser applies the HasEdge predicate on the "user" edge.
func HasUser() predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates).
func HasUserWith(preds ...predicate.User) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(func(s *sql.Selector) {
step := newUserStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.PromoCodeUsage) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.PromoCodeUsage) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.PromoCodeUsage) predicate.PromoCodeUsage {
return predicate.PromoCodeUsage(sql.NotPredicates(p))
}