models

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Enabled  = 1
	Disabled = 2
)
View Source
const (
	MenuDirectory = 1
	MenuPage      = 2
	MenuAction    = 3
	MenuLink      = 4
)
View Source
const (
	ScopeAll         = "all"
	ScopeSelf        = "self"
	ScopeDepartment  = "department"
	ScopeDepartments = "departments"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	Base
	Scope      string `` /* 139-byte string literal not displayed */
	Name       string `json:"name" gorm:"not null;size:255;comment:附件名称" binding:"required,max=255"`
	FileID     uint   `json:"file_id" gorm:"not null;default:0;uniqueIndex:idx_admin_attachment_file;comment:文件ID"`
	CategoryID uint   `json:"category_id" gorm:"not null;default:0;index;comment:附件分类ID:0为未分类"`
	CreatedBy  uint   `json:"created_by" gorm:"not null;default:0;index;comment:上传管理员ID"`
	File       File   `json:"file" gorm:"foreignKey:FileID"`
}

func (Attachment) TableName

func (Attachment) TableName() string

type Base

type Base struct {
	ID        uint                  `json:"id" gorm:"not null;primaryKey"`
	CreatedAt int64                 `json:"created_at" gorm:"not null;autoCreateTime:milli"`
	UpdatedAt int64                 `json:"updated_at" gorm:"not null;autoUpdateTime:milli"`
	DeletedAt soft_delete.DeletedAt `json:"-" gorm:"not null;softDelete:milli;index;default:0"`
}

Base 复用主键、UTC 时间和软删除字段.

type Category

type Category struct {
	Base
	Name     string `json:"name" gorm:"not null;size:100;comment:附件分类名称" binding:"required,max=100"`
	ParentID uint   `json:"parent_id" gorm:"not null;default:0;comment:上级分类ID:0为顶级;index"`
	Sort     int    `json:"sort" gorm:"not null;default:0;comment:排序:升序"`
}

func (Category) TableName

func (Category) TableName() string

type Department

type Department struct {
	Base
	Name     string `json:"name" gorm:"not null;size:100;comment:部门名称" binding:"required,max=100"`
	ParentID uint   `json:"parent_id" gorm:"not null;default:0;index;comment:上级部门ID:0为顶级"`
	Leader   string `json:"leader" gorm:"not null;size:100;comment:负责人"`
	Phone    string `json:"phone" gorm:"not null;size:40;comment:联系电话"`
	Email    string `json:"email" gorm:"not null;size:180;comment:联系邮箱"`
	Sort     int    `json:"sort" gorm:"not null;default:0;comment:排序:升序"`
	Status   int    `json:"status" gorm:"not null;type:smallint;default:1;comment:状态:1正常 2停用"`
	Remark   string `json:"remark" gorm:"not null;comment:备注;size:500"`
}

func (Department) TableName

func (Department) TableName() string

type File

type File struct {
	Location  storage.Config `json:"-" gorm:"not null;serializer:json;type:text;comment:上传时的存储位置(JSON):驱动和路径参数,不含密钥"`
	ID        uint           `json:"id" gorm:"not null;primaryKey"`
	MD5       string         `json:"md5" gorm:"not null;size:32;index:idx_admin_file_lookup;comment:文件MD5摘要"`
	SHA256    string         `json:"sha256" gorm:"not null;size:64;uniqueIndex;comment:文件SHA-256摘要"`
	Size      int64          `json:"size" gorm:"not null;default:0;index:idx_admin_file_lookup;comment:文件大小(字节)"`
	Path      string         `json:"-" gorm:"not null;size:500;comment:存储路径"`
	MIME      string         `json:"mime" gorm:"not null;size:150;comment:文件媒体类型"`
	CreatedAt int64          `json:"created_at" gorm:"not null;autoCreateTime:milli"`
}

func (File) TableName

func (File) TableName() string

type Log

type Log struct {
	Location     string `json:"location" gorm:"not null;default:'';size:255;comment:IP地理位置"`
	CountryCode  string `json:"country_code" gorm:"not null;default:'';size:2;comment:IP所在国家代码"`
	RequestData  string `json:"request_data" gorm:"not null;type:text;comment:请求参数:敏感字段脱敏"`
	ResponseData string `json:"response_data" gorm:"not null;type:text;comment:响应摘要:敏感字段脱敏"`

	Sender    string `json:"sender" gorm:"not null;default:'';size:180;comment:邮件发件地址:非邮件日志为空"`
	Recipient string `json:"recipient" gorm:"not null;default:'';size:180;comment:邮件收件地址:非邮件日志为空"`
	ID        uint   `json:"id" gorm:"not null;primaryKey"`
	Kind      string `` /* 127-byte string literal not displayed */
	UserID    uint   `json:"user_id" gorm:"not null;default:0;index;comment:管理员ID"`
	Username  string `json:"username" gorm:"not null;size:80;comment:管理员账号"`
	Method    string `json:"method" gorm:"not null;size:10;comment:HTTP请求方法"`
	Path      string `json:"path" gorm:"not null;size:500;comment:请求路径"`
	IP        string `json:"ip" gorm:"not null;size:80;comment:客户端IP"`
	Status    int    `json:"status" gorm:"not null;default:0;comment:HTTP响应状态码"`
	Duration  int64  `json:"duration" gorm:"not null;default:0;comment:请求耗时(毫秒)"`
	Message   string `json:"message" gorm:"not null;type:text;comment:日志内容"`
	CreatedAt int64  `json:"created_at" gorm:"not null;autoCreateTime:milli;index:idx_admin_logs_kind_time"`
}

func (Log) TableName

func (Log) TableName() string
type Menu struct {
	Base
	Type      int    `json:"type" gorm:"not null;default:0;comment:类型:1目录 2菜单 3按钮 4外链" binding:"required,oneof=1 2 3 4"`
	Path      string `json:"path" gorm:"not null;size:500;comment:前端路由路径"`
	Component string `json:"component" gorm:"not null;size:500;comment:前端组件路径"`
	Status    int    `json:"status" gorm:"not null;type:smallint;default:1;comment:状态:1正常 2停用" binding:"required,oneof=1 2"`
	Hidden    bool   `json:"hidden" gorm:"not null;default:false;comment:隐藏菜单:0否 1是"`
	KeepAlive bool   `json:"keep_alive" gorm:"not null;default:false;comment:缓存页面:0否 1是"`
	FixedTab  bool   `json:"fixed_tab" gorm:"not null;default:false;comment:固定页签:0否 1是"`
	FullPage  bool   `json:"full_page" gorm:"not null;default:false;comment:独立全屏:0否 1是"`
	Key       string `` /* 129-byte string literal not displayed */
	ParentKey string `json:"parent_key" gorm:"not null;size:150;index;comment:上级菜单Key:空为顶级"`
	Title     string `json:"title" gorm:"not null;size:100;comment:菜单或权限名称" binding:"required,max=100"`
	URL       string `json:"url" gorm:"not null;size:1500;comment:菜单目标地址:站内路径或HTTP(S)地址" binding:"max=1500"`
	Icon      string `json:"icon" gorm:"not null;size:100;comment:菜单图标"`
	Mode      string `json:"mode" gorm:"not null;size:20;comment:打开方式:iframe后台内嵌 new_tab新窗口"`
	SystemKey string `json:"system_key" gorm:"not null;size:100;comment:受控外部系统Key"`
	Sort      int    `json:"sort" gorm:"not null;default:0;comment:排序:升序"`
}

Menu 保存自定义目录、外链菜单和操作权限, 内置菜单由代码定义.

func (Menu) TableName() string

type Migration

type Migration struct {
	Name      string `json:"name" gorm:"not null;size:150;primaryKey;comment:已执行的迁移版本"`
	CreatedAt int64  `json:"created_at" gorm:"not null;autoCreateTime:milli"`
}

func (Migration) TableName

func (Migration) TableName() string

type Post

type Post struct {
	Base
	Name   string `json:"name" gorm:"not null;size:100;comment:岗位名称" binding:"required,max=100"`
	Code   string `json:"code" gorm:"not null;size:100;uniqueIndex;comment:岗位唯一编码" binding:"required,max=100"`
	Sort   int    `json:"sort" gorm:"not null;default:0;comment:排序:升序"`
	Status int    `json:"status" gorm:"not null;type:smallint;default:1;comment:状态:1正常 2停用"`
	Remark string `json:"remark" gorm:"not null;comment:备注;size:500"`
}

func (Post) TableName

func (Post) TableName() string

type Role

type Role struct {
	Base
	Name          string `json:"name" gorm:"not null;size:100;comment:角色名称" binding:"required,max=100"`
	Code          string `json:"code" gorm:"not null;size:100;uniqueIndex;comment:角色唯一编码" binding:"required,max=100"`
	Level         int    `json:"level" gorm:"not null;default:100;comment:权限级别:数值越小权限越高"`
	Status        int    `json:"status" gorm:"not null;type:smallint;default:1;comment:状态:1正常 2停用"`
	Sort          int    `json:"sort" gorm:"not null;default:0;comment:排序:升序"`
	Remark        string `json:"remark" gorm:"not null;comment:备注;size:500"`
	DataScope     string `` /* 140-byte string literal not displayed */
	DepartmentIDs []uint `json:"department_ids" gorm:"not null;serializer:json;default:'[]';comment:指定部门ID列表(JSON)"`
}

func (Role) TableName

func (Role) TableName() string

type RolePermission

type RolePermission struct {
	RoleID uint   `json:"role_id" gorm:"not null;primaryKey;comment:角色ID"`
	Key    string `json:"key" gorm:"not null;size:150;primaryKey;comment:授权权限Key"`
}

func (RolePermission) TableName

func (RolePermission) TableName() string

type Session

type Session struct {
	ID               string `json:"id" gorm:"not null;size:64;primaryKey"`
	UserID           uint   `json:"user_id" gorm:"not null;default:0;index;comment:管理员ID"`
	AccessHash       string `json:"-" gorm:"not null;size:64;uniqueIndex;comment:访问凭证摘要"`
	RefreshHash      string `json:"-" gorm:"not null;size:64;uniqueIndex;comment:刷新凭证摘要"`
	ExpiresAt        int64  `json:"expires_at" gorm:"not null;default:0;index;comment:访问凭证到期时间(Unix毫秒)"`
	RefreshExpiresAt int64  `json:"-" gorm:"not null;default:0;index;comment:刷新凭证到期时间(Unix毫秒)"`
	CreatedAt        int64  `json:"created_at" gorm:"not null;autoCreateTime:milli"`
	IP               string `json:"ip" gorm:"not null;size:80;comment:登录IP"`
	UserAgent        string `json:"user_agent" gorm:"not null;size:500;comment:客户端信息"`
}

Session 仅保存凭证摘要, 每次请求重新读取账号和角色状态.

func (Session) TableName

func (Session) TableName() string

type Setting

type Setting struct {
	ID        uint   `json:"id" gorm:"primaryKey"`
	Key       string `json:"key" gorm:"not null;size:100;uniqueIndex;comment:配置唯一标识"`
	Name      string `json:"name" gorm:"not null;size:100;comment:配置名称"`
	Value     string `json:"value" gorm:"not null;type:json;comment:配置内容JSON:保密字段保存密文"`
	Revision  int64  `json:"revision" gorm:"not null;default:1;comment:配置版本:防止并发写入旧缓存"`
	CreatedAt int64  `json:"created_at" gorm:"not null;autoCreateTime:milli"`
	UpdatedAt int64  `json:"updated_at" gorm:"not null;autoUpdateTime:milli"`
	UpdatedBy uint   `json:"updated_by" gorm:"not null;default:0;comment:最后修改管理员ID"`
}

func (Setting) TableName

func (Setting) TableName() string

type User

type User struct {
	Base
	Username     string `json:"username" gorm:"not null;size:80;uniqueIndex;comment:登录账号" binding:"required,max=80"`
	Password     string `json:"-" gorm:"not null;size:100;comment:密码哈希"`
	Realname     string `json:"realname" gorm:"not null;size:100;comment:姓名"`
	Email        string `json:"email" gorm:"not null;size:180;comment:邮箱"`
	Phone        string `json:"phone" gorm:"not null;size:40;comment:手机号"`
	Avatar       string `json:"avatar" gorm:"not null;size:500;comment:头像地址"`
	Gender       string `json:"gender" gorm:"not null;size:1;default:0;comment:性别:0未知 1男 2女"`
	DepartmentID uint   `json:"dept_id" gorm:"not null;default:0;index;comment:所属部门ID"`
	Status       int    `json:"status" gorm:"not null;type:smallint;default:1;comment:状态:1正常 2停用"`
	Super        bool   `json:"is_super" gorm:"not null;default:false;comment:超级管理员:0否 1是"`
	Remark       string `json:"remark" gorm:"not null;comment:备注;size:500"`
	LoginTime    int64  `json:"login_time" gorm:"not null;default:0;comment:最后登录时间(Unix毫秒)"`
	Roles        []Role `json:"role_list" gorm:"many2many:admin_user_roles"`
	Posts        []Post `json:"post_list" gorm:"many2many:admin_user_posts"`
}

func (User) TableName

func (User) TableName() string

type UserPost

type UserPost struct {
	UserID uint `gorm:"not null;primaryKey;comment:管理员ID"`
	PostID uint `gorm:"not null;primaryKey;index;comment:岗位ID"`
}

UserPost 用户与岗位关联.

func (UserPost) TableName

func (UserPost) TableName() string

type UserRole

type UserRole struct {
	UserID uint `gorm:"not null;primaryKey;comment:管理员ID"`
	RoleID uint `gorm:"not null;primaryKey;index;comment:角色ID"`
}

UserRole 用户与角色关联.

func (UserRole) TableName

func (UserRole) TableName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL