From 96208a21813c05b259fb477e9094c04eb3545784 Mon Sep 17 00:00:00 2001 From: ata <17314593+asdxzaaaaa@user.noreply.gitee.com> Date: Fri, 10 Jul 2026 10:06:04 +0000 Subject: [PATCH] Add internal/model/user.go --- internal/model/user.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 internal/model/user.go diff --git a/internal/model/user.go b/internal/model/user.go new file mode 100644 index 0000000..dac8c13 --- /dev/null +++ b/internal/model/user.go @@ -0,0 +1,21 @@ +package model + +import ( + "time" + + "gorm.io/gorm" +) + +// User 用户模型(管理端与用户端共用一套账号体系) +type User struct { + ID uint `gorm:"primaryKey" json:"id"` + Username string `gorm:"size:50;uniqueIndex;not null" json:"username"` + Password string `gorm:"size:255;not null" json:"-"` // bcrypt 哈希,不返回前端 + Phone string `gorm:"size:20;index" json:"phone"` // 手机号 + Role string `gorm:"size:20;default:user;not null" json:"role"` // admin | user + Avatar string `gorm:"size:255" json:"avatar"` // 头像 URL + Status int `gorm:"default:1;not null" json:"status"` // 1=正常 0=禁用 + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` + DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` +}