用户登录和接口鉴权
This commit is contained in:
35
internal/model/user.go
Normal file
35
internal/model/user.go
Normal file
@@ -0,0 +1,35 @@
|
||||
// Package model 提供数据模型定义
|
||||
// 包含用户、猪舍、饲料等相关数据结构
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// User 代表系统用户
|
||||
type User struct {
|
||||
// ID 用户ID
|
||||
ID uint `gorm:"primaryKey;column:id" json:"id"`
|
||||
|
||||
// Username 用户名
|
||||
Username string `gorm:"uniqueIndex;not null;column:username" json:"username"`
|
||||
|
||||
// PasswordHash 密码哈希值
|
||||
PasswordHash string `gorm:"not null;column:password_hash" json:"-"`
|
||||
|
||||
// CreatedAt 创建时间
|
||||
CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
|
||||
|
||||
// UpdatedAt 更新时间
|
||||
UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at"`
|
||||
|
||||
// DeletedAt 删除时间(用于软删除)
|
||||
DeletedAt gorm.DeletedAt `gorm:"index;column:deleted_at" json:"-"`
|
||||
}
|
||||
|
||||
// TableName 指定User模型对应的数据库表名
|
||||
func (User) TableName() string {
|
||||
return "users"
|
||||
}
|
||||
Reference in New Issue
Block a user