Files
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

34 lines
1.3 KiB
Go
Executable File

package model
import (
"time"
"gorm.io/gorm"
)
type User struct {
ID uint `gorm:"primarykey;comment:用户ID" 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_mini_open,priority:1;comment:小程序ID" json:"mini_program_id"`
MiniProgram MiniProgram `gorm:"foreignKey:MiniProgramID" json:"mini_program,omitempty"`
OpenID string `gorm:"size:100;index:idx_mini_open,priority:2;comment:微信OpenID" json:"open_id"`
UnionID string `gorm:"size:100;comment:微信UnionID" json:"union_id,omitempty"`
NickName string `gorm:"size:100;comment:昵称" json:"nickname"`
AvatarURL string `gorm:"size:500;comment:头像URL" json:"avatar_url"`
Gender int `gorm:"default:0;comment:性别(0未知/1男/2女)" json:"gender"`
Phone string `gorm:"size:20;comment:手机号" json:"phone,omitempty"`
SessionKey string `gorm:"size:100;comment:会话key(用于Bearer Token)" json:"-"`
}
func (User) TableName() string {
return "users"
}
func (User) TableComment() string {
return "用户"
}