schema

package
v8.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckIsRootUser

func CheckIsRootUser(ctx context.Context, userID uint64) bool

CheckIsRootUser 检查是否是root用户

Types

type ErrorItem

type ErrorItem struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type ErrorResult

type ErrorResult struct {
	Error ErrorItem `json:"error"`
}

type IDResult

type IDResult struct {
	ID uint64 `json:"id,string"`
}

func NewIDResult

func NewIDResult(id uint64) *IDResult

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 LoginParam struct {
	UserName    string `json:"user_name" binding:"required"`    // 用户名
	Password    string `json:"password" binding:"required"`     // 密码(md5加密)
	CaptchaID   string `json:"captcha_id" binding:"required"`   // 验证码ID
	CaptchaCode string `json:"captcha_code" binding:"required"` // 验证码
}

type LoginTokenInfo

type LoginTokenInfo struct {
	AccessToken string `json:"access_token"` // 访问令牌
	TokenType   string `json:"token_type"`   // 令牌类型
	ExpiresAt   int64  `json:"expires_at"`   // 过期时间戳
}
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 菜单对象

func (a *Menu) String() string
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 struct {
	OrderFields []*OrderField // 排序字段
}

MenuActionQueryOptions 查询可选参数项

type MenuActionQueryParam struct {
	PaginationParam
	MenuID uint64   // 菜单ID
	IDs    []uint64 // 唯一标识列表
}

MenuActionQueryParam 查询条件

type MenuActionQueryResult struct {
	Data       MenuActions
	PageResult *PaginationResult
}

MenuActionQueryResult 查询结果

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 struct {
	OrderFields []*OrderField // 排序字段
}

MenuActionResourceQueryOptions 查询可选参数项

type MenuActionResourceQueryParam struct {
	PaginationParam
	MenuID  uint64   // 菜单ID
	MenuIDs []uint64 // 菜单ID列表
}

MenuActionResourceQueryParam 查询条件

type MenuActionResourceQueryResult struct {
	Data       MenuActionResources
	PageResult *PaginationResult
}

MenuActionResourceQueryResult 查询结果

type MenuActionResources []*MenuActionResource

MenuActionResources 菜单动作关联资源管理列表

func (a MenuActionResources) ToActionIDMap() map[uint64]MenuActionResources

ToActionIDMap 转换为动作ID映射

ToMap 转换为map

type MenuActions []*MenuAction

MenuActions 菜单动作管理列表

func (a MenuActions) FillResources(mResources map[uint64]MenuActionResources)

FillResources 填充资源数据

func (a MenuActions) ToMap() map[string]*MenuAction

ToMap 转换为map

func (a MenuActions) ToMenuIDMap() map[uint64]MenuActions

ToMenuIDMap 转换为菜单ID映射

type MenuQueryOptions struct {
	OrderFields  []*OrderField
	SelectFields []string
}

MenuQueryOptions 查询可选参数项

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 struct {
	Data       Menus
	PageResult *PaginationResult
}

MenuQueryResult 查询结果

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 MenuTrees []*MenuTree

MenuTrees 菜单树列表

func (a MenuTrees) ToTree() MenuTrees

ToTree 转换为树形结构

type Menus []*Menu

Menus 菜单列表

func (a Menus) FillMenuAction(mActions map[uint64]MenuActions) Menus

FillMenuAction 填充菜单动作列表

func (a Menus) Len() int
func (a Menus) Less(i, j int) bool
func (a Menus) SplitParentIDs() []uint64

SplitParentIDs 拆分父级路径的唯一标识列表

func (a Menus) Swap(i, j int)
func (a Menus) ToMap() map[uint64]*Menu

ToMap 转换为键值映射

func (a Menus) ToTree() MenuTrees

ToTree 转换为菜单树

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 PaginationResult struct {
	Total    int64 `json:"total"`
	Current  int   `json:"current"`
	PageSize int   `json:"pageSize"`
}

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) ToActionIDs

func (a RoleMenus) ToActionIDs() []uint64

ToActionIDs 转换为动作ID列表

func (RoleMenus) ToMap

func (a RoleMenus) ToMap() map[string]*RoleMenu

ToMap 转换为map

func (RoleMenus) ToMenuIDs

func (a RoleMenus) ToMenuIDs() []uint64

ToMenuIDs 转换为菜单ID列表

func (RoleMenus) ToRoleIDMap

func (a RoleMenus) ToRoleIDMap() map[uint64]RoleMenus

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 Roles

type Roles []*Role

Roles 角色对象列表

func (Roles) ToMap

func (a Roles) ToMap() map[uint64]*Role

ToMap 转换为键值存储

func (Roles) ToNames

func (a Roles) ToNames() []string

ToNames 获取角色名称列表

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 UpdatePasswordParam struct {
	OldPassword string `json:"old_password" binding:"required"` // 旧密码(md5加密)
	NewPassword string `json:"new_password" binding:"required"` // 新密码(md5加密)
}

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 用户对象

func GetRootUser

func GetRootUser() *User

GetRootUser 获取root用户

func (*User) CleanSecure

func (a *User) CleanSecure() *User

CleanSecure 清理安全数据

func (*User) String

func (a *User) String() string

type UserLoginInfo

type UserLoginInfo struct {
	UserID   uint64 `json:"user_id,string"` // 用户ID
	UserName string `json:"user_name"`      // 用户名
	RealName string `json:"real_name"`      // 真实姓名
	Roles    Roles  `json:"roles"`          // 角色列表
}

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) ToMap

func (a UserRoles) ToMap() map[uint64]*UserRole

ToMap 转换为map

func (UserRoles) ToRoleIDs

func (a UserRoles) ToRoleIDs() []uint64

ToRoleIDs 转换为角色ID列表

func (UserRoles) ToUserIDMap

func (a UserRoles) ToUserIDMap() map[uint64]UserRoles

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 用户显示项查询结果

type UserShows

type UserShows []*UserShow

UserShows 用户显示项列表

type Users

type Users []*User

Users 用户对象列表

func (Users) ToIDs

func (a Users) ToIDs() []uint64

ToIDs 转换为唯一标识列表

func (Users) ToUserShows

func (a Users) ToUserShows(mUserRoles map[uint64]UserRoles, mRoles map[uint64]*Role) UserShows

ToUserShows 转换为用户显示列表

Jump to

Keyboard shortcuts

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