Documentation ¶
Index ¶
- func CheckIsRootUser(ctx context.Context, userID uint64) bool
- type ErrorItem
- type ErrorResult
- type IDResult
- type ListResult
- type LoginCaptcha
- type LoginParam
- type LoginTokenInfo
- type Menu
- type MenuAction
- type MenuActionQueryOptions
- type MenuActionQueryParam
- type MenuActionQueryResult
- type MenuActionResource
- type MenuActionResourceQueryOptions
- type MenuActionResourceQueryParam
- type MenuActionResourceQueryResult
- type MenuActionResources
- type MenuActions
- type MenuQueryOptions
- type MenuQueryParam
- type MenuQueryResult
- type MenuTree
- type MenuTrees
- type Menus
- type OrderDirection
- type OrderField
- type PaginationParam
- type PaginationResult
- type Role
- type RoleMenu
- type RoleMenuQueryOptions
- type RoleMenuQueryParam
- type RoleMenuQueryResult
- type RoleMenus
- type RoleQueryOptions
- type RoleQueryParam
- type RoleQueryResult
- type Roles
- type StatusResult
- type StatusText
- type UpdatePasswordParam
- type User
- type UserLoginInfo
- type UserQueryOptions
- type UserQueryParam
- type UserQueryResult
- type UserRole
- type UserRoleQueryOptions
- type UserRoleQueryParam
- type UserRoleQueryResult
- type UserRoles
- type UserShow
- type UserShowQueryResult
- type UserShows
- type Users
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ErrorResult ¶
type ErrorResult struct {
Error ErrorItem `json:"error"`
}
type ListResult ¶
type ListResult struct { List interface{} `json:"list"` Pagination *PaginationResult `json:"pagination,omitempty"` }
type LoginCaptcha ¶
type LoginCaptcha struct {
CaptchaID string `json:"captcha_id"` // 验证码ID
}
type LoginParam ¶
type LoginTokenInfo ¶
type Menu ¶
type Menu struct { ID uint64 `json:"id,string"` // 唯一标识 Name string `json:"name" binding:"required"` // 菜单名称 Sequence int `json:"sequence"` // 排序值 Icon string `json:"icon"` // 菜单图标 Router string `json:"router"` // 访问路由 ParentID uint64 `json:"parent_id,string"` // 父级ID ParentPath string `json:"parent_path"` // 父级路径 IsShow int `json:"is_show" binding:"required,max=2,min=1"` // 是否显示(1:显示 2:隐藏) Status int `json:"status" binding:"required,max=2,min=1"` // 状态(1:启用 2:禁用) Memo string `json:"memo"` // 备注 Creator uint64 `json:"creator"` // 创建者 CreatedAt time.Time `json:"created_at"` // 创建时间 UpdatedAt time.Time `json:"updated_at"` // 更新时间 Actions MenuActions `json:"actions"` // 动作列表 }
Menu 菜单对象
type MenuAction ¶
type MenuAction struct { ID uint64 `yaml:"-" json:"id,string"` // 唯一标识 MenuID uint64 `yaml:"-" binding:"required" json:"menu_id,string"` // 菜单ID Code string `yaml:"code" binding:"required" json:"code"` // 动作编号 Name string `yaml:"name" binding:"required" json:"name"` // 动作名称 Resources MenuActionResources `yaml:"resources,omitempty" json:"resources"` // 资源列表 }
MenuAction 菜单动作对象
type MenuActionQueryOptions ¶
type MenuActionQueryOptions struct {
OrderFields []*OrderField // 排序字段
}
MenuActionQueryOptions 查询可选参数项
type MenuActionQueryParam ¶
type MenuActionQueryParam struct { PaginationParam MenuID uint64 // 菜单ID IDs []uint64 // 唯一标识列表 }
MenuActionQueryParam 查询条件
type MenuActionQueryResult ¶
type MenuActionQueryResult struct { Data MenuActions PageResult *PaginationResult }
MenuActionQueryResult 查询结果
type MenuActionResource ¶
type MenuActionResource struct { ID uint64 `yaml:"-" json:"id,string"` // 唯一标识 ActionID uint64 `yaml:"-" json:"action_id,string"` // 菜单动作ID Method string `yaml:"method" binding:"required" json:"method"` // 资源请求方式(支持正则) Path string `yaml:"path" binding:"required" json:"path"` // 资源请求路径(支持/:id匹配) }
MenuActionResource 菜单动作关联资源对象
type MenuActionResourceQueryOptions ¶
type MenuActionResourceQueryOptions struct {
OrderFields []*OrderField // 排序字段
}
MenuActionResourceQueryOptions 查询可选参数项
type MenuActionResourceQueryParam ¶
type MenuActionResourceQueryParam struct { PaginationParam MenuID uint64 // 菜单ID MenuIDs []uint64 // 菜单ID列表 }
MenuActionResourceQueryParam 查询条件
type MenuActionResourceQueryResult ¶
type MenuActionResourceQueryResult struct { Data MenuActionResources PageResult *PaginationResult }
MenuActionResourceQueryResult 查询结果
type MenuActionResources ¶
type MenuActionResources []*MenuActionResource
MenuActionResources 菜单动作关联资源管理列表
func (MenuActionResources) ToActionIDMap ¶
func (a MenuActionResources) ToActionIDMap() map[uint64]MenuActionResources
ToActionIDMap 转换为动作ID映射
func (MenuActionResources) ToMap ¶
func (a MenuActionResources) ToMap() map[string]*MenuActionResource
ToMap 转换为map
type MenuActions ¶
type MenuActions []*MenuAction
MenuActions 菜单动作管理列表
func (MenuActions) FillResources ¶
func (a MenuActions) FillResources(mResources map[uint64]MenuActionResources)
FillResources 填充资源数据
func (MenuActions) ToMenuIDMap ¶
func (a MenuActions) ToMenuIDMap() map[uint64]MenuActions
ToMenuIDMap 转换为菜单ID映射
type MenuQueryOptions ¶
type MenuQueryOptions struct { OrderFields []*OrderField SelectFields []string }
MenuQueryOptions 查询可选参数项
type MenuQueryParam ¶
type MenuQueryParam struct { PaginationParam IDs []uint64 `form:"-"` // 唯一标识列表 Name string `form:"-"` // 菜单名称 PrefixParentPath string `form:"-"` // 父级路径(前缀模糊查询) QueryValue string `form:"queryValue"` // 模糊查询 ParentID *uint64 `form:"parentID"` // 父级内码 IsShow int `form:"isShow"` // 是否显示(1:显示 2:隐藏) Status int `form:"status"` // 状态(1:启用 2:禁用) }
MenuQueryParam 查询条件
type MenuQueryResult ¶
type MenuQueryResult struct { Data Menus PageResult *PaginationResult }
MenuQueryResult 查询结果
type MenuTree ¶
type MenuTree struct { ID uint64 `yaml:"-" json:"id,string"` // 唯一标识 Name string `yaml:"name" json:"name"` // 菜单名称 Icon string `yaml:"icon" json:"icon"` // 菜单图标 Router string `yaml:"router,omitempty" json:"router"` // 访问路由 ParentID uint64 `yaml:"-" json:"parent_id,string"` // 父级ID ParentPath string `yaml:"-" json:"parent_path"` // 父级路径 Sequence int `yaml:"sequence" json:"sequence"` // 排序值 IsShow int `yaml:"-" json:"is_show"` // 是否显示(1:显示 2:隐藏) Status int `yaml:"-" json:"status"` // 状态(1:启用 2:禁用) Actions MenuActions `yaml:"actions,omitempty" json:"actions"` // 动作列表 Children *MenuTrees `yaml:"children,omitempty" json:"children,omitempty"` // 子级树 }
MenuTree 菜单树
type Menus ¶
type Menus []*Menu
Menus 菜单列表
func (Menus) FillMenuAction ¶
func (a Menus) FillMenuAction(mActions map[uint64]MenuActions) Menus
FillMenuAction 填充菜单动作列表
type OrderDirection ¶
type OrderDirection int
const ( OrderByASC OrderDirection = iota + 1 OrderByDESC )
type OrderField ¶
type OrderField struct { Key string Direction OrderDirection }
func NewOrderField ¶
func NewOrderField(key string, d OrderDirection) *OrderField
func NewOrderFieldWithKeys ¶
func NewOrderFieldWithKeys(keys []string, directions ...map[int]OrderDirection) []*OrderField
Create order fields key and define key index direction
func NewOrderFields ¶
func NewOrderFields(orderFields ...*OrderField) []*OrderField
type PaginationParam ¶
type PaginationParam struct { Pagination bool `form:"-"` OnlyCount bool `form:"-"` Current int `form:"current,default=1"` PageSize int `form:"pageSize,default=10" binding:"max=100"` }
func (PaginationParam) GetCurrent ¶
func (a PaginationParam) GetCurrent() int
func (PaginationParam) GetPageSize ¶
func (a PaginationParam) GetPageSize() int
type PaginationResult ¶
type Role ¶
type Role struct { ID uint64 `json:"id,string"` // 唯一标识 Name string `json:"name" binding:"required"` // 角色名称 Sequence int `json:"sequence"` // 排序值 Memo string `json:"memo"` // 备注 Status int `json:"status" binding:"required,max=2,min=1"` // 状态(1:启用 2:禁用) Creator uint64 `json:"creator"` // 创建者 CreatedAt time.Time `json:"created_at"` // 创建时间 UpdatedAt time.Time `json:"updated_at"` // 更新时间 RoleMenus RoleMenus `json:"role_menus" binding:"required,gt=0"` // 角色菜单列表 }
Role 角色对象
type RoleMenu ¶
type RoleMenu struct { ID uint64 `json:"id,string"` // 唯一标识 RoleID uint64 `json:"role_id,string" binding:"required"` // 角色ID MenuID uint64 `json:"menu_id,string" binding:"required"` // 菜单ID ActionID uint64 `json:"action_id,string" binding:"required"` // 动作ID }
RoleMenu 角色菜单对象
type RoleMenuQueryOptions ¶
type RoleMenuQueryOptions struct { OrderFields []*OrderField SelectFields []string }
RoleMenuQueryOptions 查询可选参数项
type RoleMenuQueryParam ¶
type RoleMenuQueryParam struct { PaginationParam RoleID uint64 // 角色ID RoleIDs []uint64 // 角色ID列表 }
RoleMenuQueryParam 查询条件
type RoleMenuQueryResult ¶
type RoleMenuQueryResult struct { Data RoleMenus PageResult *PaginationResult }
RoleMenuQueryResult 查询结果
type RoleMenus ¶
type RoleMenus []*RoleMenu
RoleMenus 角色菜单列表
func (RoleMenus) ToRoleIDMap ¶
ToRoleIDMap 转换为角色ID映射
type RoleQueryOptions ¶
type RoleQueryOptions struct { OrderFields []*OrderField // 排序字段 SelectFields []string // 查询字段 }
RoleQueryOptions 查询可选参数项
type RoleQueryParam ¶
type RoleQueryParam struct { PaginationParam IDs []uint64 `form:"-"` // 唯一标识列表 Name string `form:"-"` // 角色名称 QueryValue string `form:"queryValue"` // 模糊查询 Status int `form:"status"` // 状态(1:启用 2:禁用) }
RoleQueryParam 查询条件
type RoleQueryResult ¶
type RoleQueryResult struct { Data Roles PageResult *PaginationResult }
RoleQueryResult 查询结果
type StatusResult ¶
type StatusResult struct {
Status StatusText `json:"status"`
}
type StatusText ¶
type StatusText string
const ( OKStatus StatusText = "OK" ErrorStatus StatusText = "ERROR" FailStatus StatusText = "FAIL" )
func (StatusText) String ¶
func (t StatusText) String() string
type UpdatePasswordParam ¶
type User ¶
type User struct { ID uint64 `json:"id,string"` // 唯一标识 UserName string `json:"user_name" binding:"required"` // 用户名 RealName string `json:"real_name" binding:"required"` // 真实姓名 Password string `json:"password"` // 密码 Phone string `json:"phone"` // 手机号 Email string `json:"email"` // 邮箱 Status int `json:"status" binding:"required,max=2,min=1"` // 用户状态(1:启用 2:停用) Creator uint64 `json:"creator"` // 创建者 CreatedAt time.Time `json:"created_at"` // 创建时间 UserRoles UserRoles `json:"user_roles" binding:"required,gt=0"` // 角色授权 }
User 用户对象
type UserLoginInfo ¶
type UserQueryOptions ¶
type UserQueryOptions struct { OrderFields []*OrderField SelectFields []string }
UserQueryOptions 查询可选参数项
type UserQueryParam ¶
type UserQueryParam struct { PaginationParam UserName string `form:"userName"` // 用户名 QueryValue string `form:"queryValue"` // 模糊查询 Status int `form:"status"` // 用户状态(1:启用 2:停用) RoleIDs []uint64 `form:"-"` // 角色ID列表 }
UserQueryParam 查询条件
type UserQueryResult ¶
type UserQueryResult struct { Data Users PageResult *PaginationResult }
UserQueryResult 查询结果
func (UserQueryResult) ToShowResult ¶
func (a UserQueryResult) ToShowResult(mUserRoles map[uint64]UserRoles, mRoles map[uint64]*Role) *UserShowQueryResult
ToShowResult 转换为显示结果
type UserRole ¶
type UserRole struct { ID uint64 `json:"id,string"` // 唯一标识 UserID uint64 `json:"user_id,string"` // 用户ID RoleID uint64 `json:"role_id,string"` // 角色ID }
UserRole 用户角色
type UserRoleQueryOptions ¶
type UserRoleQueryOptions struct {
OrderFields []*OrderField // 排序字段
}
UserRoleQueryOptions 查询可选参数项
type UserRoleQueryParam ¶
type UserRoleQueryParam struct { PaginationParam UserID uint64 // 用户ID UserIDs []uint64 // 用户ID列表 }
UserRoleQueryParam 查询条件
type UserRoleQueryResult ¶
type UserRoleQueryResult struct { Data UserRoles PageResult *PaginationResult }
UserRoleQueryResult 查询结果
type UserRoles ¶
type UserRoles []*UserRole
UserRoles 角色菜单列表
func (UserRoles) ToUserIDMap ¶
ToUserIDMap 转换为用户ID映射
type UserShow ¶
type UserShow struct { ID uint64 `json:"id,string"` // 唯一标识 UserName string `json:"user_name"` // 用户名 RealName string `json:"real_name"` // 真实姓名 Phone string `json:"phone"` // 手机号 Email string `json:"email"` // 邮箱 Status int `json:"status"` // 用户状态(1:启用 2:停用) CreatedAt time.Time `json:"created_at"` // 创建时间 Roles []*Role `json:"roles"` // 授权角色列表 }
UserShow 用户显示项
type UserShowQueryResult ¶
type UserShowQueryResult struct { Data UserShows PageResult *PaginationResult }
UserShowQueryResult 用户显示项查询结果