feat: 实现前端卡密管理界面
- 卡密列表展示与分页功能 - 单个/批量创建卡密 - 卡密删除与批量删除 - 卡密导出功能 (file-saver) - 启用/禁用状态切换 - 状态判断 (有效/已使用/已失效) - Toast 通知系统 (vue-sonner) - 登录页面错误提示优化 - 后端登录错误消息中文化
This commit is contained in:
43
backend/internal/models/invitation.go
Normal file
43
backend/internal/models/invitation.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"time"
|
||||
)
|
||||
|
||||
// InvitationStatus 邀请状态枚举
|
||||
type InvitationStatus string
|
||||
|
||||
const (
|
||||
StatusPending InvitationStatus = "pending"
|
||||
StatusSent InvitationStatus = "sent"
|
||||
StatusAccepted InvitationStatus = "accepted"
|
||||
StatusFailed InvitationStatus = "failed"
|
||||
StatusExpired InvitationStatus = "expired"
|
||||
)
|
||||
|
||||
// Invitation 邀请记录表
|
||||
type Invitation struct {
|
||||
ID int `json:"id"`
|
||||
CardKeyID sql.NullInt64 `json:"card_key_id"`
|
||||
AccountID int `json:"account_id"`
|
||||
InvitedEmail string `json:"invited_email"`
|
||||
Status InvitationStatus `json:"status"`
|
||||
ErrorMessage sql.NullString `json:"error_message"`
|
||||
ExpiresAt sql.NullTime `json:"expires_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt sql.NullTime `json:"updated_at"`
|
||||
}
|
||||
|
||||
// TableName 返回表名
|
||||
func (Invitation) TableName() string {
|
||||
return "invitations"
|
||||
}
|
||||
|
||||
// IsExpired 检查邀请是否过期
|
||||
func (i *Invitation) IsExpired() bool {
|
||||
if !i.ExpiresAt.Valid {
|
||||
return false
|
||||
}
|
||||
return time.Now().After(i.ExpiresAt.Time)
|
||||
}
|
||||
Reference in New Issue
Block a user