Documentation
¶
Index ¶
- Constants
- Variables
- type Captcha
- type LoginForm
- type LoginToken
- type Menu
- type MenuForm
- type MenuQueryOptions
- type MenuQueryParam
- type MenuQueryResult
- type MenuResource
- type MenuResourceForm
- type MenuResourceQueryOptions
- type MenuResourceQueryParam
- type MenuResourceQueryResult
- type MenuResources
- type Menus
- type Role
- type RoleForm
- type RoleMenu
- type RoleMenuForm
- type RoleMenuQueryOptions
- type RoleMenuQueryParam
- type RoleMenuQueryResult
- type RoleMenus
- type RoleQueryOptions
- type RoleQueryParam
- type RoleQueryResult
- type Roles
- type UpdateCurrentUser
- type UpdateLoginPassword
- type User
- type UserForm
- type UserQueryOptions
- type UserQueryParam
- type UserQueryResult
- type UserRole
- type UserRoleForm
- type UserRoleQueryOptions
- type UserRoleQueryParam
- type UserRoleQueryResult
- type UserRoles
- type Users
Constants ¶
const ( MenuStatusDisabled = "disabled" MenuStatusEnabled = "enabled" )
const ( RoleStatusEnabled = "enabled" // Enabled RoleStatusDisabled = "disabled" // Disabled RoleResultTypeSelect = "select" // Select )
const ( UserStatusActivated = "activated" UserStatusFreezed = "freezed" )
Variables ¶
var ( MenusOrderParams = []util.OrderByParam{ {Field: "sequence", Direction: util.DESC}, {Field: "created_at", Direction: util.DESC}, } )
Functions ¶
This section is empty.
Types ¶
type LoginForm ¶
type LoginForm struct {
Username string `json:"username" binding:"required"` // Login name
Password string `json:"password" binding:"required"` // Login password (md5 hash)
CaptchaID string `json:"captcha_id" binding:"required"` // Captcha verify id
CaptchaCode string `json:"captcha_code" binding:"required"` // Captcha verify code
}
type LoginToken ¶
type Menu ¶
type Menu struct {
ID string `json:"id" gorm:"size:20;primarykey;"` // Unique ID
Code string `json:"code" gorm:"size:32;index;"` // Code of menu (unique for each level)
Name string `json:"name" gorm:"size:128;index"` // Display name of menu
Description string `json:"description" gorm:"size:1024"` // Details about menu
Sequence int `json:"sequence" gorm:"index;"` // Sequence for sorting (Order by desc)
Type string `json:"type" gorm:"size:20;index"` // Type of menu (page, button)
Path string `json:"path" gorm:"size:255;"` // Access path of menu
Properties string `json:"properties" gorm:"type:text;"` // Properties of menu (JSON)
Status string `json:"status" gorm:"size:20;index"` // Status of menu (enabled, disabled)
ParentID string `json:"parent_id" gorm:"size:20;index;"` // Parent ID (From Menu.ID)
ParentPath string `json:"parent_path" gorm:"size:255;index;"` // Parent path (split by .)
Children *Menus `json:"children" gorm:"-"` // Child menus
CreatedAt time.Time `json:"created_at" gorm:"index;"` // Create time
UpdatedAt time.Time `json:"updated_at" gorm:"index;"` // Update time
Resources MenuResources `json:"resources" gorm:"-"` // Resources of menu
}
Menu management for RBAC
type MenuForm ¶
type MenuForm struct {
Code string `json:"code" binding:"required,max=32"` // Code of menu (unique for each level)
Name string `json:"name" binding:"required,max=128"` // Display name of menu
Description string `json:"description"` // Details about menu
Sequence int `json:"sequence"` // Sequence for sorting (Order by desc)
Type string `json:"type" binding:"required,oneof=page button"` // Type of menu (page, button)
Path string `json:"path"` // Access path of menu
Properties string `json:"properties"` // Properties of menu (JSON)
Status string `json:"status" binding:"required,oneof=disabled enabled"` // Status of menu (enabled, disabled)
ParentID string `json:"parent_id"` // Parent ID (From Menu.ID)
Resources MenuResources `json:"resources"` // Resources of menu
}
Defining the data structure for creating a `Menu` struct.
type MenuQueryOptions ¶
type MenuQueryOptions struct {
util.QueryOptions
}
Defining the query options for the `Menu` struct.
type MenuQueryParam ¶
type MenuQueryParam struct {
util.PaginationParam
CodePath string `form:"code"` // Code path (like xxx.xxx.xxx)
LikeName string `form:"name"` // Display name of menu
IncludeResources bool `form:"includeResources"` // Include resources
InIDs []string `form:"-"` // Include menu IDs
Status string `form:"-"` // Status of menu (disabled, enabled)
ParentID string `form:"-"` // Parent ID (From Menu.ID)
ParentPathPrefix string `form:"-"` // Parent path (split by .)
UserID string `form:"-"` // User ID
RoleID string `form:"-"` // Role ID
}
Defining the query parameters for the `Menu` struct.
type MenuQueryResult ¶
type MenuQueryResult struct {
Data Menus
PageResult *util.PaginationResult
}
Defining the query result for the `Menu` struct.
type MenuResource ¶
type MenuResource struct {
ID string `json:"id" gorm:"size:20;primarykey"` // Unique ID
MenuID string `json:"menu_id" gorm:"size:20;index"` // From Menu.ID
Method string `json:"method" gorm:"size:20;"` // HTTP method
Path string `json:"path" gorm:"size:255;"` // API request path (e.g. /api/v1/users/:id)
CreatedAt time.Time `json:"created_at" gorm:"index;"` // Create time
UpdatedAt time.Time `json:"updated_at" gorm:"index;"` // Update time
}
Menu resource management for RBAC
func (*MenuResource) TableName ¶
func (a *MenuResource) TableName() string
type MenuResourceForm ¶
type MenuResourceForm struct {
}
Defining the data structure for creating a `MenuResource` struct.
func (*MenuResourceForm) FillTo ¶
func (a *MenuResourceForm) FillTo(menuResource *MenuResource) error
func (*MenuResourceForm) Validate ¶
func (a *MenuResourceForm) Validate() error
A validation function for the `MenuResourceForm` struct.
type MenuResourceQueryOptions ¶
type MenuResourceQueryOptions struct {
util.QueryOptions
}
Defining the query options for the `MenuResource` struct.
type MenuResourceQueryParam ¶
type MenuResourceQueryParam struct {
util.PaginationParam
MenuID string `form:"-"` // From Menu.ID
MenuIDs []string `form:"-"` // From Menu.ID
}
Defining the query parameters for the `MenuResource` struct.
type MenuResourceQueryResult ¶
type MenuResourceQueryResult struct {
Data MenuResources
PageResult *util.PaginationResult
}
Defining the query result for the `MenuResource` struct.
type MenuResources ¶
type MenuResources []*MenuResource
Defining the slice of `MenuResource` struct.
type Role ¶
type Role struct {
ID string `json:"id" gorm:"size:20;primarykey;"` // Unique ID
Code string `json:"code" gorm:"size:32;index;"` // Code of role (unique)
Name string `json:"name" gorm:"size:128;index"` // Display name of role
Description string `json:"description" gorm:"size:1024"` // Details about role
Sequence int `json:"sequence" gorm:"index"` // Sequence for sorting
Status string `json:"status" gorm:"size:20;index"` // Status of role (disabled, enabled)
CreatedAt time.Time `json:"created_at" gorm:"index;"` // Create time
UpdatedAt time.Time `json:"updated_at" gorm:"index;"` // Update time
Menus RoleMenus `json:"menus" gorm:"-"` // Role menu list
}
Role management for RBAC
type RoleForm ¶
type RoleForm struct {
Code string `json:"code" binding:"required,max=32"` // Code of role (unique)
Name string `json:"name" binding:"required,max=128"` // Display name of role
Description string `json:"description"` // Details about role
Sequence int `json:"sequence"` // Sequence for sorting
Status string `json:"status" binding:"required,oneof=disabled enabled"` // Status of role (enabled, disabled)
Menus RoleMenus `json:"menus"` // Role menu list
}
Defining the data structure for creating a `Role` struct.
type RoleMenu ¶
type RoleMenu struct {
ID string `json:"id" gorm:"size:20;primarykey"` // Unique ID
RoleID string `json:"role_id" gorm:"size:20;index"` // From Role.ID
MenuID string `json:"menu_id" gorm:"size:20;index"` // From Menu.ID
CreatedAt time.Time `json:"created_at" gorm:"index;"` // Create time
UpdatedAt time.Time `json:"updated_at" gorm:"index;"` // Update time
}
Role permissions for RBAC
type RoleMenuForm ¶
type RoleMenuForm struct {
}
Defining the data structure for creating a `RoleMenu` struct.
func (*RoleMenuForm) FillTo ¶
func (a *RoleMenuForm) FillTo(roleMenu *RoleMenu) error
func (*RoleMenuForm) Validate ¶
func (a *RoleMenuForm) Validate() error
A validation function for the `RoleMenuForm` struct.
type RoleMenuQueryOptions ¶
type RoleMenuQueryOptions struct {
util.QueryOptions
}
Defining the query options for the `RoleMenu` struct.
type RoleMenuQueryParam ¶
type RoleMenuQueryParam struct {
util.PaginationParam
RoleID string `form:"-"` // From Role.ID
}
Defining the query parameters for the `RoleMenu` struct.
type RoleMenuQueryResult ¶
type RoleMenuQueryResult struct {
Data RoleMenus
PageResult *util.PaginationResult
}
Defining the query result for the `RoleMenu` struct.
type RoleQueryOptions ¶
type RoleQueryOptions struct {
util.QueryOptions
}
Defining the query options for the `Role` struct.
type RoleQueryParam ¶
type RoleQueryParam struct {
util.PaginationParam
LikeName string `form:"name"` // Display name of role
Status string `form:"status" binding:"oneof=disabled enabled ''"` // Status of role (disabled, enabled)
ResultType string `form:"resultType"` // Result type (options: select)
InIDs []string `form:"-"` // ID list
GtUpdatedAt *time.Time `form:"-"` // Update time is greater than
}
Defining the query parameters for the `Role` struct.
type RoleQueryResult ¶
type RoleQueryResult struct {
Data Roles
PageResult *util.PaginationResult
}
Defining the query result for the `Role` struct.
type UpdateCurrentUser ¶
type UpdateCurrentUser struct {
Name string `json:"name" binding:"required,max=64"` // Name of user
Phone string `json:"phone" binding:"max=32"` // Phone number of user
Email string `json:"email" binding:"max=128"` // Email of user
Remark string `json:"remark" binding:"max=1024"` // Remark of user
}
type UpdateLoginPassword ¶
type User ¶
type User struct {
ID string `json:"id" gorm:"size:20;primarykey;"` // Unique ID
Username string `json:"username" gorm:"size:64;index"` // Username for login
Name string `json:"name" gorm:"size:64;index"` // Name of user
Password string `json:"-" gorm:"size:64;"` // Password for login (encrypted)
Phone string `json:"phone" gorm:"size:32;"` // Phone number of user
Email string `json:"email" gorm:"size:128;"` // Email of user
Remark string `json:"remark" gorm:"size:1024;"` // Remark of user
Status string `json:"status" gorm:"size:20;index"` // Status of user (activated, freezed)
CreatedAt time.Time `json:"created_at" gorm:"index;"` // Create time
UpdatedAt time.Time `json:"updated_at" gorm:"index;"` // Update time
Roles UserRoles `json:"roles" gorm:"-"` // Roles of user
}
User management for RBAC
type UserForm ¶
type UserForm struct {
Username string `json:"username" binding:"required,max=64"` // Username for login
Name string `json:"name" binding:"required,max=64"` // Name of user
Password string `json:"password" binding:"max=64"` // Password for login (md5 hash)
Phone string `json:"phone" binding:"max=32"` // Phone number of user
Email string `json:"email" binding:"max=128"` // Email of user
Remark string `json:"remark" binding:"max=1024"` // Remark of user
Status string `json:"status" binding:"required,oneof=activated freezed"` // Status of user (activated, freezed)
Roles UserRoles `json:"roles" binding:"required"` // Roles of user
}
Defining the data structure for creating a `User` struct.
type UserQueryOptions ¶
type UserQueryOptions struct {
util.QueryOptions
}
Defining the query options for the `User` struct.
type UserQueryParam ¶
type UserQueryParam struct {
util.PaginationParam
LikeUsername string `form:"username"` // Username for login
LikeName string `form:"name"` // Name of user
Status string `form:"status" binding:"oneof=activated freezed ''"` // Status of user (activated, freezed)
}
Defining the query parameters for the `User` struct.
type UserQueryResult ¶
type UserQueryResult struct {
Data Users
PageResult *util.PaginationResult
}
Defining the query result for the `User` struct.
type UserRole ¶
type UserRole struct {
ID string `json:"id" gorm:"size:20;primarykey"` // Unique ID
UserID string `json:"user_id" gorm:"size:20;index"` // From User.ID
RoleID string `json:"role_id" gorm:"size:20;index"` // From Role.ID
CreatedAt time.Time `json:"created_at" gorm:"index;"` // Create time
UpdatedAt time.Time `json:"updated_at" gorm:"index;"` // Update time
RoleName string `json:"role_name" gorm:"<-:false;-:migration;"` // From Role.Name
}
User roles for RBAC
type UserRoleForm ¶
type UserRoleForm struct {
}
Defining the data structure for creating a `UserRole` struct.
func (*UserRoleForm) FillTo ¶
func (a *UserRoleForm) FillTo(userRole *UserRole) error
func (*UserRoleForm) Validate ¶
func (a *UserRoleForm) Validate() error
A validation function for the `UserRoleForm` struct.
type UserRoleQueryOptions ¶
type UserRoleQueryOptions struct {
util.QueryOptions
JoinRole bool // Join role table
}
Defining the query options for the `UserRole` struct.
type UserRoleQueryParam ¶
type UserRoleQueryParam struct {
util.PaginationParam
InUserIDs []string `form:"-"` // From User.ID
UserID string `form:"-"` // From User.ID
RoleID string `form:"-"` // From Role.ID
}
Defining the query parameters for the `UserRole` struct.
type UserRoleQueryResult ¶
type UserRoleQueryResult struct {
Data UserRoles
PageResult *util.PaginationResult
}
Defining the query result for the `UserRole` struct.
type UserRoles ¶
type UserRoles []*UserRole
Defining the slice of `UserRole` struct.