首次提交
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
// AdminRole 管理员角色
|
||||
type AdminRole string
|
||||
|
||||
const (
|
||||
RoleSuperAdmin AdminRole = "super_admin"
|
||||
RoleAdmin AdminRole = "admin"
|
||||
)
|
||||
|
||||
// AdminStatus 管理员状态
|
||||
type AdminStatus string
|
||||
|
||||
const (
|
||||
AdminStatusActive AdminStatus = "active"
|
||||
AdminStatusDisabled AdminStatus = "disabled"
|
||||
)
|
||||
|
||||
// Admin 管理员模型
|
||||
type Admin struct {
|
||||
ID string `gorm:"primaryKey;type:varchar(32)" json:"id"`
|
||||
Username string `gorm:"uniqueIndex;type:varchar(50);not null" json:"username"`
|
||||
PasswordHash string `gorm:"column:password_hash;type:varchar(255);not null" json:"-"`
|
||||
Nickname *string `gorm:"type:varchar(50)" json:"nickname,omitempty"`
|
||||
Role AdminRole `gorm:"default:admin;type:varchar(20)" json:"role"`
|
||||
Status AdminStatus `gorm:"default:active;type:varchar(20)" json:"status"`
|
||||
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (Admin) TableName() string { return "admins" }
|
||||
Reference in New Issue
Block a user