mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-02-02 23:03:57 +08:00
fix(invite): 邀请码增加使用情况和过期时间
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"github.com/chaitin/MonkeyCode/backend/consts"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -17,10 +18,14 @@ const (
|
||||
FieldAdminID = "admin_id"
|
||||
// FieldCode holds the string denoting the code field in the database.
|
||||
FieldCode = "code"
|
||||
// FieldStatus holds the string denoting the status field in the database.
|
||||
FieldStatus = "status"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||
FieldUpdatedAt = "updated_at"
|
||||
// FieldExpiredAt holds the string denoting the expired_at field in the database.
|
||||
FieldExpiredAt = "expired_at"
|
||||
// Table holds the table name of the invitecode in the database.
|
||||
Table = "invite_codes"
|
||||
)
|
||||
@@ -30,8 +35,10 @@ var Columns = []string{
|
||||
FieldID,
|
||||
FieldAdminID,
|
||||
FieldCode,
|
||||
FieldStatus,
|
||||
FieldCreatedAt,
|
||||
FieldUpdatedAt,
|
||||
FieldExpiredAt,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
@@ -45,6 +52,8 @@ func ValidColumn(column string) bool {
|
||||
}
|
||||
|
||||
var (
|
||||
// DefaultStatus holds the default value on creation for the "status" field.
|
||||
DefaultStatus consts.InviteCodeStatus
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
DefaultCreatedAt func() time.Time
|
||||
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
||||
@@ -71,6 +80,11 @@ func ByCode(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCode, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByStatus orders the results by the status field.
|
||||
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldStatus, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
@@ -80,3 +94,8 @@ func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByExpiredAt orders the results by the expired_at field.
|
||||
func ByExpiredAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldExpiredAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user