feat: 实现注册优惠码功能
- 支持创建/编辑/删除优惠码,设置赠送金额和使用限制 - 注册页面实时验证优惠码并显示赠送金额 - 支持 URL 参数自动填充 (?promo=CODE) - 添加优惠码验证接口速率限制 - 使用数据库行锁防止并发超限 - 新增后台优惠码管理页面,支持复制注册链接
This commit is contained in:
125
backend/ent/promocodeusage/promocodeusage.go
Normal file
125
backend/ent/promocodeusage/promocodeusage.go
Normal file
@@ -0,0 +1,125 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package promocodeusage
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the promocodeusage type in the database.
|
||||
Label = "promo_code_usage"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldPromoCodeID holds the string denoting the promo_code_id field in the database.
|
||||
FieldPromoCodeID = "promo_code_id"
|
||||
// FieldUserID holds the string denoting the user_id field in the database.
|
||||
FieldUserID = "user_id"
|
||||
// FieldBonusAmount holds the string denoting the bonus_amount field in the database.
|
||||
FieldBonusAmount = "bonus_amount"
|
||||
// FieldUsedAt holds the string denoting the used_at field in the database.
|
||||
FieldUsedAt = "used_at"
|
||||
// EdgePromoCode holds the string denoting the promo_code edge name in mutations.
|
||||
EdgePromoCode = "promo_code"
|
||||
// EdgeUser holds the string denoting the user edge name in mutations.
|
||||
EdgeUser = "user"
|
||||
// Table holds the table name of the promocodeusage in the database.
|
||||
Table = "promo_code_usages"
|
||||
// PromoCodeTable is the table that holds the promo_code relation/edge.
|
||||
PromoCodeTable = "promo_code_usages"
|
||||
// PromoCodeInverseTable is the table name for the PromoCode entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "promocode" package.
|
||||
PromoCodeInverseTable = "promo_codes"
|
||||
// PromoCodeColumn is the table column denoting the promo_code relation/edge.
|
||||
PromoCodeColumn = "promo_code_id"
|
||||
// UserTable is the table that holds the user relation/edge.
|
||||
UserTable = "promo_code_usages"
|
||||
// UserInverseTable is the table name for the User entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "user" package.
|
||||
UserInverseTable = "users"
|
||||
// UserColumn is the table column denoting the user relation/edge.
|
||||
UserColumn = "user_id"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for promocodeusage fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldPromoCodeID,
|
||||
FieldUserID,
|
||||
FieldBonusAmount,
|
||||
FieldUsedAt,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
if column == Columns[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// DefaultUsedAt holds the default value on creation for the "used_at" field.
|
||||
DefaultUsedAt func() time.Time
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the PromoCodeUsage queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPromoCodeID orders the results by the promo_code_id field.
|
||||
func ByPromoCodeID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPromoCodeID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUserID orders the results by the user_id field.
|
||||
func ByUserID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUserID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByBonusAmount orders the results by the bonus_amount field.
|
||||
func ByBonusAmount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldBonusAmount, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUsedAt orders the results by the used_at field.
|
||||
func ByUsedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUsedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPromoCodeField orders the results by promo_code field.
|
||||
func ByPromoCodeField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newPromoCodeStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
}
|
||||
|
||||
// ByUserField orders the results by user field.
|
||||
func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
}
|
||||
func newPromoCodeStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(PromoCodeInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, PromoCodeTable, PromoCodeColumn),
|
||||
)
|
||||
}
|
||||
func newUserStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(UserInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn),
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user