Files
wx_service/internal/model/user_membership.go
T
nepiedg 1ad775be63 Enhance database models with comments and table descriptions
- Added comments to various fields in the database models for better clarity and understanding.
- Implemented TableComment methods for several models to provide descriptive information about their purpose.
- Updated the AutoMigrate function to support setting table comments in the database.
- Improved overall documentation within the code to facilitate future maintenance and development.
2026-01-03 02:35:11 +00:00

33 lines
1.2 KiB
Go

package model
import (
"time"
"gorm.io/gorm"
)
// UserMembership 表示会员订阅记录(DDL 见 docs/sql/users.sql)。
type UserMembership struct {
ID uint `gorm:"primarykey" json:"id"`
CreatedAt time.Time `gorm:"comment:创建时间" json:"created_at"`
UpdatedAt time.Time `gorm:"comment:更新时间" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index;comment:删除时间" json:"-"`
MiniProgramID uint `gorm:"index:idx_membership_user,priority:1;index:idx_membership_status,priority:1;comment:小程序ID" json:"mini_program_id"`
UserID uint `gorm:"index:idx_membership_user,priority:2;index:idx_membership_status,priority:2;comment:用户ID" json:"user_id"`
Plan string `gorm:"size:30;comment:会员套餐" json:"plan"`
Status string `gorm:"size:20;index:idx_membership_status,priority:3;comment:状态(active/canceled/expired)" json:"status"`
StartsAt time.Time `gorm:"comment:开始时间" json:"starts_at"`
EndsAt time.Time `gorm:"index:idx_membership_user,priority:3;index:idx_membership_status,priority:4;comment:结束时间" json:"ends_at"`
}
func (UserMembership) TableName() string {
return "user_memberships"
}
func (UserMembership) TableComment() string {
return "用户会员订阅"
}