schema

package
v0.0.0-...-a377ca4 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: MIT Imports: 6 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckIsRootUser

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

CheckIsRootUser 检查是否是root用户

func GetRootUser

func GetRootUser() *userPB.User

GetRootUser 获取root用户

Types

type Demo

type Demo struct {
	ID        string    `json:"id"`                                    // 唯一标识
	Code      string    `json:"code" binding:"required"`               // 编号
	Name      string    `json:"name" binding:"required"`               // 名称
	Memo      string    `json:"memo"`                                  // 备注
	Status    int       `json:"status" binding:"required,max=2,min=1"` // 状态(1:启用 2:停用)
	Creator   string    `json:"creator"`                               // 创建者
	CreatedAt time.Time `json:"created_at"`                            // 创建时间
	UpdatedAt time.Time `json:"updated_at"`                            // 更新时间
}

Demo 示例对象

type DemoQueryOptions

type DemoQueryOptions struct {
	OrderFields []*OrderField // 排序字段
}

DemoQueryOptions 示例对象查询可选参数项

type DemoQueryParam

type DemoQueryParam struct {
	PaginationParam
	Code       string `form:"-"`          // 编号
	QueryValue string `form:"queryValue"` // 查询值
}

DemoQueryParam 查询条件

type DemoQueryResult

type DemoQueryResult struct {
	Data       []*Demo
	PageResult *PaginationResult
}

DemoQueryResult 示例对象查询结果

type ErrorItem

type ErrorItem struct {
	Code    int    `json:"code"`    // 错误码
	Message string `json:"message"` // 错误信息
}

ErrorItem 响应错误项

type ErrorResult

type ErrorResult struct {
	Error ErrorItem `json:"error"` // 错误项
}

ErrorResult 响应错误

type IDResult

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

IDResult 响应唯一标识

func NewIDResult

func NewIDResult(id string) *IDResult

NewIDResult 创建响应唯一标识实例

type ListResult

type ListResult struct {
	List       interface{}       `json:"list"`
	Pagination *PaginationResult `json:"pagination,omitempty"`
}

ListResult 响应列表数据

type LoginCaptcha

type LoginCaptcha struct {
	CaptchaID string `json:"captcha_id"` // 验证码ID
}

LoginCaptcha 登录验证码

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"` // 验证码
}

LoginParam 登录参数

type LoginTokenInfo

type LoginTokenInfo struct {
	AccessToken string `json:"access_token"` // 访问令牌
	TokenType   string `json:"token_type"`   // 令牌类型
	ExpiresAt   int64  `json:"expires_at"`   // 令牌到期时间戳
}

LoginTokenInfo 登录令牌信息

type Menu struct {
	ID         string      `json:"id"`                                         // 唯一标识
	Name       string      `json:"name" binding:"required"`                    // 菜单名称
	Sequence   int         `json:"sequence"`                                   // 排序值
	Icon       string      `json:"icon"`                                       // 菜单图标
	Router     string      `json:"router"`                                     // 访问路由
	ParentID   string      `json:"parent_id"`                                  // 父级ID
	ParentPath string      `json:"parent_path"`                                // 父级路径
	ShowStatus int         `json:"show_status" 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    string      `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        string              `yaml:"-" json:"id"`                          // 唯一标识
	MenuID    string              `yaml:"-" binding:"required" json:"menu_id"`  // 菜单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 string   // 菜单ID
	IDs    []string // 唯一标识列表
}

MenuActionQueryParam 查询条件

type MenuActionQueryResult struct {
	Data       MenuActions
	PageResult *PaginationResult
}

MenuActionQueryResult 查询结果

type MenuActionResource struct {
	ID       string `yaml:"-" json:"id"`                             // 唯一标识
	ActionID string `yaml:"-" json:"action_id"`                      // 菜单动作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  string   // 菜单ID
	MenuIDs []string // 菜单ID列表
}

MenuActionResourceQueryParam 查询条件

type MenuActionResourceQueryResult struct {
	Data       MenuActionResources
	PageResult *PaginationResult
}

MenuActionResourceQueryResult 查询结果

type MenuActionResources []*MenuActionResource

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

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

ToActionIDMap 转换为动作ID映射

ToMap 转换为map

type MenuActions []*MenuAction

MenuActions 菜单动作管理列表

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

FillResources 填充资源数据

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

ToMap 转换为map

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

ToMenuIDMap 转换为菜单ID映射

type MenuQueryOptions struct {
	OrderFields []*OrderField // 排序字段
}

MenuQueryOptions 查询可选参数项

type MenuQueryParam struct {
	PaginationParam
	IDs              []string `form:"-"`          // 唯一标识列表
	Name             string   `form:"-"`          // 菜单名称
	PrefixParentPath string   `form:"-"`          // 父级路径(前缀模糊查询)
	QueryValue       string   `form:"queryValue"` // 模糊查询
	ParentID         *string  `form:"parentID"`   // 父级内码
	ShowStatus       int      `form:"showStatus"` // 显示状态(1:显示 2:隐藏)
	Status           int      `form:"status"`     // 状态(1:启用 2:禁用)
}

MenuQueryParam 查询条件

type MenuQueryResult struct {
	Data       Menus
	PageResult *PaginationResult
}

MenuQueryResult 查询结果

type MenuTree struct {
	ID         string      `yaml:"-" json:"id"`                                  // 唯一标识
	Name       string      `yaml:"name" json:"name"`                             // 菜单名称
	Icon       string      `yaml:"icon" json:"icon"`                             // 菜单图标
	Router     string      `yaml:"router,omitempty" json:"router"`               // 访问路由
	ParentID   string      `yaml:"-" json:"parent_id"`                           // 父级ID
	ParentPath string      `yaml:"-" json:"parent_path"`                         // 父级路径
	Sequence   int         `yaml:"sequence" json:"sequence"`                     // 排序值
	ShowStatus int         `yaml:"-" json:"show_status"`                         // 显示状态(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[string]MenuActions) Menus

FillMenuAction 填充菜单动作列表

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

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

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

ToMap 转换为键值映射

func (a Menus) ToTree() MenuTrees

ToTree 转换为菜单树

type OrderDirection

type OrderDirection int

OrderDirection 排序方向

const (
	// OrderByASC 升序排序
	OrderByASC OrderDirection = 1
	// OrderByDESC 降序排序
	OrderByDESC OrderDirection = 2
)

type OrderField

type OrderField struct {
	Key       string         // 字段名(字段名约束为小写蛇形)
	Direction OrderDirection // 排序方向
}

OrderField 排序字段

func NewOrderField

func NewOrderField(key string, d OrderDirection) *OrderField

NewOrderField 创建排序字段

func NewOrderFieldWithKeys

func NewOrderFieldWithKeys(keys []string, directions ...map[int]OrderDirection) []*OrderField

NewOrderFieldWithKeys 创建排序字段(默认升序排序),可指定不同key的排序规则 keys 需要排序的key directions 排序规则,按照key的索引指定,索引默认从0开始

func NewOrderFields

func NewOrderFields(orderFields ...*OrderField) []*OrderField

NewOrderFields 创建排序字段列表

type PaginationParam

type PaginationParam struct {
	Pagination bool `form:"-"`                                     // 是否使用分页查询
	OnlyCount  bool `form:"-"`                                     // 是否仅查询count
	Current    uint `form:"current,default=1"`                     // 当前页
	PageSize   uint `form:"pageSize,default=10" binding:"max=100"` // 页大小
}

PaginationParam 分页查询条件

func (PaginationParam) GetCurrent

func (a PaginationParam) GetCurrent() uint

GetCurrent 获取当前页

func (PaginationParam) GetPageSize

func (a PaginationParam) GetPageSize() uint

GetPageSize 获取页大小

type PaginationResult

type PaginationResult struct {
	Total    int  `json:"total"`
	Current  uint `json:"current"`
	PageSize uint `json:"pageSize"`
}

PaginationResult 分页查询结果

type Role

type Role struct {
	ID        string    `json:"id"`                                    // 唯一标识
	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   string    `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       string `json:"id"`                           // 唯一标识
	RoleID   string `json:"role_id" binding:"required"`   // 角色ID
	MenuID   string `json:"menu_id" binding:"required"`   // 菜单ID
	ActionID string `json:"action_id" binding:"required"` // 动作ID
}

RoleMenu 角色菜单对象

type RoleMenuQueryOptions

type RoleMenuQueryOptions struct {
	OrderFields []*OrderField // 排序字段
}

RoleMenuQueryOptions 查询可选参数项

type RoleMenuQueryParam

type RoleMenuQueryParam struct {
	PaginationParam
	RoleID  string   // 角色ID
	RoleIDs []string // 角色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() []string

ToActionIDs 转换为动作ID列表

func (RoleMenus) ToMap

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

ToMap 转换为map

func (RoleMenus) ToMenuIDs

func (a RoleMenus) ToMenuIDs() []string

ToMenuIDs 转换为菜单ID列表

func (RoleMenus) ToRoleIDMap

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

ToRoleIDMap 转换为角色ID映射

type RoleQueryOptions

type RoleQueryOptions struct {
	OrderFields []*OrderField // 排序字段
}

RoleQueryOptions 查询可选参数项

type RoleQueryParam

type RoleQueryParam struct {
	PaginationParam
	IDs        []string `form:"-"`          // 唯一标识列表
	Name       string   `form:"-"`          // 角色名称
	QueryValue string   `form:"queryValue"` // 模糊查询
	UserID     string   `form:"-"`          // 用户ID
	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[string]*Role

ToMap 转换为键值存储

func (Roles) ToNames

func (a Roles) ToNames() []string

ToNames 获取角色名称列表

type StatusResult

type StatusResult struct {
	Status StatusText `json:"status"` // 状态(OK)
}

StatusResult 响应状态

type StatusText

type StatusText string

StatusText 定义状态文本

const (
	OKStatus    StatusText = "OK"
	ErrorStatus StatusText = "ERROR"
	FailStatus  StatusText = "FAIL"
)

定义HTTP状态文本常量

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加密)
}

UpdatePasswordParam 更新密码请求参数

type User

type User struct {
	ID        string    `json:"id"`                                    // 唯一标识
	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   string    `json:"creator"`                               // 创建者
	CreatedAt time.Time `json:"created_at"`                            // 创建时间
	UserRoles UserRoles `json:"user_roles" binding:"required,gt=0"`    // 角色授权
}

User 用户对象

func (*User) CleanSecure

func (a *User) CleanSecure() *User

CleanSecure 清理安全数据

func (*User) String

func (a *User) String() string

type UserLoginInfo

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

UserLoginInfo 用户登录信息

type UserQueryOptions

type UserQueryOptions struct {
	OrderFields []*OrderField // 排序字段
}

UserQueryOptions 查询可选参数项

type UserQueryParam

type UserQueryParam struct {
	PaginationParam
	UserName   string   `form:"userName"`   // 用户名
	QueryValue string   `form:"queryValue"` // 模糊查询
	Status     int      `form:"status"`     // 用户状态(1:启用 2:停用)
	RoleIDs    []string `form:"-"`          // 角色ID列表
}

UserQueryParam 查询条件

type UserQueryResult

type UserQueryResult struct {
	Data       Users
	PageResult *PaginationResult
}

UserQueryResult 查询结果

func (UserQueryResult) ToShowResult

func (a UserQueryResult) ToShowResult(mUserRoles map[string]UserRoles, mRoles map[string]*Role) *UserShowQueryResult

ToShowResult 转换为显示结果

type UserRole

type UserRole struct {
	ID     string `json:"id"`      // 唯一标识
	UserID string `json:"user_id"` // 用户ID
	RoleID string `json:"role_id"` // 角色ID
}

UserRole 用户角色

type UserRoleQueryOptions

type UserRoleQueryOptions struct {
	OrderFields []*OrderField // 排序字段
}

UserRoleQueryOptions 查询可选参数项

type UserRoleQueryParam

type UserRoleQueryParam struct {
	PaginationParam
	UserID  string   // 用户ID
	UserIDs []string // 用户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[string]*UserRole

ToMap 转换为map

func (UserRoles) ToRoleIDs

func (a UserRoles) ToRoleIDs() []string

ToRoleIDs 转换为角色ID列表

func (UserRoles) ToUserIDMap

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

ToUserIDMap 转换为用户ID映射

type UserShow

type UserShow struct {
	ID        string    `json:"id"`         // 唯一标识
	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() []string

ToIDs 转换为唯一标识列表

func (Users) ToUserShows

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

ToUserShows 转换为用户显示列表

Jump to

Keyboard shortcuts

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