- 新增商业化模块:Stripe/Binance Pay 支付、邮箱登录、订单管理 - 新增数据模型:ReportProduct, ReportEntitlement, ReportSnapshot, PaymentEvent, EmailLoginCode - 新增 API:/api/commerce/checkout, /api/commerce/webhooks/*, /api/commerce/orders/* - 新增管理后台:订单列表、统计图表、统一 AdminHeader 组件 - 新增中间件测试:RateLimit, Auth, CORS 共 7 个测试用例 - 新增 AGENTS.md 项目代理指令文件 - 新增 REMINDER.md 商业化功能开发规范 - 修复 JWT 解析:添加 WithValidMethods 限制 HS256 - 修复 GetPayStatus:增加用户权限校验 - 更新 .gitignore 和 README.md
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
type BaziChartRecord struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
ReportID string `gorm:"index;size:64" json:"reportId"`
|
||||
UserID *uint `gorm:"index" json:"userId,omitempty"`
|
||||
Name string `gorm:"size:64" json:"name"`
|
||||
BirthDate string `gorm:"size:16" json:"birthDate"`
|
||||
BirthTime string `gorm:"size:8" json:"birthTime"`
|
||||
Gender string `gorm:"size:16" json:"gender"`
|
||||
City string `gorm:"size:64" json:"city"`
|
||||
Snapshot string `gorm:"type:longtext" json:"-"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
type ReportProduct struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Code string `gorm:"uniqueIndex;size:40" json:"code"`
|
||||
Name string `gorm:"size:100" json:"name"`
|
||||
Description string `gorm:"size:255" json:"description"`
|
||||
StripeAmount int `json:"stripeAmount"`
|
||||
StripeCurrency string `gorm:"size:10" json:"stripeCurrency"`
|
||||
BinanceAmount string `gorm:"size:32" json:"binanceAmount"`
|
||||
BinanceCurrency string `gorm:"size:10" json:"binanceCurrency"`
|
||||
Status int `gorm:"default:1" json:"status"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
type ReportEntitlement struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
UserID uint `gorm:"uniqueIndex:idx_user_report;index" json:"userId"`
|
||||
ReportID string `gorm:"uniqueIndex:idx_user_report;size:64;index" json:"reportId"`
|
||||
OrderID uint `gorm:"uniqueIndex" json:"orderId"`
|
||||
Status string `gorm:"size:20;default:'active'" json:"status"`
|
||||
GrantedAt time.Time `json:"grantedAt"`
|
||||
RevokedAt *time.Time `json:"revokedAt"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
type ReportSnapshot struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
UserID uint `gorm:"index" json:"userId"`
|
||||
ReportID string `gorm:"size:64;index" json:"reportId"`
|
||||
OrderID uint `gorm:"uniqueIndex;index" json:"orderId"`
|
||||
Snapshot string `gorm:"type:longtext" json:"-"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
type PaymentEvent struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Provider string `gorm:"uniqueIndex:idx_provider_event;size:30" json:"provider"`
|
||||
ProviderEventID string `gorm:"uniqueIndex:idx_provider_event;size:128" json:"providerEventId"`
|
||||
EventType string `gorm:"size:80" json:"eventType"`
|
||||
OrderNo string `gorm:"size:32;index" json:"orderNo"`
|
||||
PayloadHash string `gorm:"size:64" json:"payloadHash"`
|
||||
ProcessedAt time.Time `json:"processedAt"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
}
|
||||
|
||||
type EmailLoginCode struct {
|
||||
ID uint `gorm:"primaryKey" json:"-"`
|
||||
Email string `gorm:"size:254;index" json:"-"`
|
||||
CodeHash string `gorm:"size:64" json:"-"`
|
||||
Attempts int `gorm:"default:0" json:"-"`
|
||||
ExpiresAt time.Time `gorm:"index" json:"-"`
|
||||
UsedAt *time.Time `json:"-"`
|
||||
CreatedAt time.Time `gorm:"index" json:"-"`
|
||||
}
|
||||
Reference in New Issue
Block a user