20 lines
491 B
Go
20 lines
491 B
Go
|
|
package model
|
||
|
|
|
||
|
|
import "time"
|
||
|
|
|
||
|
|
// User 用户模型
|
||
|
|
type User struct {
|
||
|
|
ID uint `json:"id" gorm:"primaryKey"`
|
||
|
|
Username string `json:"username" gorm:"uniqueIndex;not null"`
|
||
|
|
Email string `json:"email" gorm:"uniqueIndex;not null"`
|
||
|
|
Password string `json:"-" gorm:"not null"` // 密码不返回给前端
|
||
|
|
CreatedAt time.Time `json:"created_at"`
|
||
|
|
UpdatedAt time.Time `json:"updated_at"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// TableName 指定表名
|
||
|
|
func (User) TableName() string {
|
||
|
|
return "users"
|
||
|
|
}
|
||
|
|
|