fix: 修复代理卡密列表数据不显示问题

- Card模型添加AgentID字段
- 生成卡密时设置AgentID
- handleGetCards返回正确格式的数据(包含app_name, card_type_name, code等)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-10 02:04:45 +08:00
parent 8148b1abdb
commit 0cc3e85714
2 changed files with 47 additions and 1 deletions
+2
View File
@@ -286,6 +286,7 @@ type Card struct {
CardTypeID uint `gorm:"index;not null" json:"card_type_id"`
CardKey string `gorm:"uniqueIndex;size:100" json:"card_key"`
CreatorID uint `gorm:"index" json:"creator_id"`
AgentID *uint `gorm:"index" json:"agent_id"`
AppUserID *uint `gorm:"index" json:"app_user_id"`
Status string `gorm:"size:20;default:unused;index" json:"status"`
UsedAt *time.Time `json:"used_at"`
@@ -297,6 +298,7 @@ type Card struct {
Application *Application `gorm:"foreignKey:ApplicationID" json:"application,omitempty"`
CardType CardType `gorm:"foreignKey:CardTypeID" json:"card_type,omitempty"`
Creator User `gorm:"foreignKey:CreatorID" json:"creator,omitempty"`
Agent *User `gorm:"foreignKey:AgentID" json:"agent,omitempty"`
AppUser *AppUser `gorm:"foreignKey:AppUserID" json:"app_user,omitempty"`
}