- 新增 GET/PUT /api/me:登录用户可查看并修改自己的 nickname/gender/birthday,空串清空、缺省保持不变,生日校验格式与未来日期 - users 表新增 gender/birthday 字段(迁移 v6)及 model.Date 日期类型,管理员用户接口同步支持 - 前端新增 /profile 个人中心页面、头像下拉入口与登录守卫,保存后同步会话用户信息 - 静态服务对未命中的无扩展名路径回退 index.html,避免刷新前端路由 404 - 重新生成 Swagger 文档,补充 /api/me 与资料字段相关测试
32 lines
1.1 KiB
Go
32 lines
1.1 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// 性别取值,空字符串表示未设置。
|
|
const (
|
|
GenderMale = "male"
|
|
GenderFemale = "female"
|
|
GenderOther = "other"
|
|
)
|
|
|
|
// User 用户,与用户组为多对多关系。
|
|
type User struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
Username string `gorm:"size:50;uniqueIndex;not null" json:"username"`
|
|
Email string `gorm:"size:255;uniqueIndex;not null" json:"email"`
|
|
PasswordHash string `gorm:"size:255;not null" json:"-"`
|
|
Nickname string `gorm:"size:50" json:"nickname"`
|
|
Avatar string `gorm:"size:255" json:"avatar"`
|
|
Gender string `gorm:"size:10;not null;default:''" json:"gender" example:"male"`
|
|
Birthday Date `gorm:"type:date" json:"birthday" swaggertype:"string" example:"1995-06-15"`
|
|
Status int8 `gorm:"not null;default:1" json:"status"`
|
|
Groups []UserGroup `gorm:"-" json:"groups"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
|
}
|