93 lines
3.9 KiB
Go
93 lines
3.9 KiB
Go
package models
|
||
|
||
import (
|
||
"time"
|
||
|
||
"gorm.io/gorm"
|
||
)
|
||
|
||
// InviteCodeApplication 邀请码申请模型
|
||
type InviteCodeApplication struct {
|
||
ID uint `json:"id" gorm:"primaryKey;autoIncrement;comment:主键ID"`
|
||
Email string `json:"email" gorm:"not null;type:varchar(255);index;comment:申请邮箱"`
|
||
Reason string `json:"reason" gorm:"type:text;comment:申请理由"`
|
||
Language string `json:"language" gorm:"type:varchar(10);default:'zh';comment:语言:zh-中文,en-英文"`
|
||
Status string `json:"status" gorm:"not null;type:varchar(20);default:'pending';index;comment:申请状态:pending-待处理,approved-已通过,rejected-已拒绝"`
|
||
InviteCodeID *uint `json:"invite_code_id" gorm:"comment:关联的邀请码ID"`
|
||
InviteCode *InviteCode `json:"invite_code" gorm:"foreignKey:InviteCodeID;constraint:OnDelete:SET NULL;-:migration"`
|
||
RejectReason string `json:"reject_reason" gorm:"type:text;comment:拒绝理由"`
|
||
ApprovedAt *time.Time `json:"approved_at" gorm:"comment:审批时间"`
|
||
ApprovedBy string `json:"approved_by" gorm:"type:varchar(64);comment:审批人"`
|
||
EmailSentAt *time.Time `json:"email_sent_at" gorm:"comment:邮件发送时间"`
|
||
CreatedAt time.Time `json:"created_at" gorm:"not null;comment:创建时间"`
|
||
UpdatedAt time.Time `json:"updated_at" gorm:"not null;comment:更新时间"`
|
||
DeletedAt gorm.DeletedAt `json:"-" gorm:"index;comment:软删除时间"`
|
||
}
|
||
|
||
// TableName 指定数据库表名
|
||
func (InviteCodeApplication) TableName() string {
|
||
return "admin_invite_code_applications"
|
||
}
|
||
|
||
// InviteCodeApplicationListRequest 申请列表请求
|
||
type InviteCodeApplicationListRequest struct {
|
||
Email string `form:"email"`
|
||
Status string `form:"status"` // pending, approved, rejected
|
||
StartTime string `form:"start_time"`
|
||
EndTime string `form:"end_time"`
|
||
Page int `form:"page,default=1"`
|
||
Size int `form:"size,default=20"`
|
||
}
|
||
|
||
// InviteCodeApplicationCreateRequest 创建申请请求(官网提交)
|
||
type InviteCodeApplicationCreateRequest struct {
|
||
Email string `json:"email" binding:"required,email"`
|
||
Reason string `json:"reason"`
|
||
Language string `json:"language"` // zh 或 en,默认 zh
|
||
}
|
||
|
||
// InviteCodeApplicationApproveRequest 审批通过请求
|
||
type InviteCodeApplicationApproveRequest struct {
|
||
ApplicationID uint `json:"application_id" binding:"required"`
|
||
ValidDays int `json:"valid_days"` // 有效期天数,默认7天
|
||
}
|
||
|
||
// InviteCodeApplicationRejectRequest 审批拒绝请求
|
||
type InviteCodeApplicationRejectRequest struct {
|
||
ApplicationID uint `json:"application_id" binding:"required"`
|
||
RejectReason string `json:"reject_reason"`
|
||
}
|
||
|
||
// InviteCodeApplicationBatchApproveRequest 批量审批通过请求
|
||
type InviteCodeApplicationBatchApproveRequest struct {
|
||
ApplicationIDs []uint `json:"application_ids" binding:"required"`
|
||
ValidDays int `json:"valid_days"` // 有效期天数,默认7天
|
||
}
|
||
|
||
// InviteCodeApplicationBatchRejectRequest 批量审批拒绝请求
|
||
type InviteCodeApplicationBatchRejectRequest struct {
|
||
ApplicationIDs []uint `json:"application_ids" binding:"required"`
|
||
RejectReason string `json:"reject_reason"`
|
||
}
|
||
|
||
// InviteCodeApplicationListResponse 申请列表响应
|
||
type InviteCodeApplicationListResponse struct {
|
||
List []InviteCodeApplication `json:"list"`
|
||
Total int64 `json:"total"`
|
||
}
|
||
|
||
// InviteCodeApplicationStatistics 申请统计
|
||
type InviteCodeApplicationStatistics struct {
|
||
TotalPending int `json:"total_pending"` // 待处理数量
|
||
TotalApproved int `json:"total_approved"` // 已通过数量
|
||
TotalRejected int `json:"total_rejected"` // 已拒绝数量
|
||
TodayApplied int `json:"today_applied"` // 今日申请数量
|
||
}
|
||
|
||
// 申请状态常量
|
||
const (
|
||
ApplicationStatusPending = "pending"
|
||
ApplicationStatusApproved = "approved"
|
||
ApplicationStatusRejected = "rejected"
|
||
)
|