Documentation
¶
Index ¶
- Constants
- type AuthDTO
- type AuthService
- type AuthVO
- type BaseDTO
- type BaseVO
- type EmailAddressDTO
- type EmailAddressID
- type EmailAddressQuery
- type EmailAddressService
- type Pagination
- type PermissionDTO
- type PermissionID
- type PermissionQuery
- type PermissionService
- type PermissionVO
- type PhoneNumberDTO
- type PhoneNumberID
- type PhoneNumberQuery
- type PhoneNumberService
- type RoleDTO
- type RoleID
- type RoleName
- type RoleNameList
- type RoleQuery
- type RoleService
- type RoleVO
- type SessionDTO
- type SessionVO
- type TokenDTO
- type UserDTO
- type UserID
- type UserInfo
- type UserInfoBinding
- type UserName
- type UserQuery
- type UserService
- type UserVO
- type VOGetter
Constants ¶
View Source
const ( ActionLogin = "login" ActionSignUp = "sign-up" ActionResetPassword = "reset-password" ActionChangePassword = "change-password" ActionSendCode = "send-code" )
定义几种常用的授权动作
View Source
const ( MechanismPassword = "password" MechanismEmail = "email" MechanismPhone = "phone" )
定义几种常用的验证机制
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthDTO ¶
type AuthDTO struct {
BaseDTO
Action string `json:"action"`
Mechanism string `json:"mechanism"`
Account string `json:"account"`
Secret lang.Base64 `json:"secret"`
Parameters map[string]string `json:"parameters"` // 其它扩展属性
}
AuthDTO 用于登录认证
type AuthService ¶
AuthService 是针对 AuthDTO 的服务
type BaseDTO ¶
type BaseDTO struct {
UUID lang.UUID `json:"uuid"`
CreatedAt lang.Time `json:"created_at"`
UpdatedAt lang.Time `json:"updated_at"`
DeletedAt lang.Time `json:"deleted_at"`
Owner UserID `json:"owner"`
Creator UserID `json:"creator"`
Updater UserID `json:"updater"`
}
BaseDTO 是基本的 DTO
type BaseVO ¶
type BaseVO struct {
Status int `json:"status"`
Message string `json:"message"`
Error string `json:"error"`
Time time.Time `json:"time"`
Timestamp lang.Time `json:"timestamp"`
Pagination *Pagination `json:"pagination"`
}
BaseVO 是通用的基本 VO 结构
type EmailAddressDTO ¶ added in v1.0.5
type EmailAddressDTO struct {
ID EmailAddressID `json:"id"`
BaseDTO
Address string `json:"address"`
}
EmailAddressDTO ...
type EmailAddressQuery ¶ added in v1.0.5
type EmailAddressQuery struct {
Pagination Pagination
}
EmailAddressQuery 查询参数
type EmailAddressService ¶ added in v1.0.5
type EmailAddressService interface {
Insert(c context.Context, o *EmailAddressDTO) (*EmailAddressDTO, error)
Update(c context.Context, id EmailAddressID, o *EmailAddressDTO) (*EmailAddressDTO, error)
Delete(c context.Context, id EmailAddressID) error
Find(c context.Context, id EmailAddressID) (*EmailAddressDTO, error)
List(c context.Context, q *EmailAddressQuery) ([]*EmailAddressDTO, error)
}
EmailAddressService ...
type Pagination ¶
type Pagination struct {
Page int64 `json:"page"` // 页码, first=1
Size int `json:"size"` // 页大小
Total int64 `json:"total"` // 所有页面的条目总数
}
Pagination 是通用的分页参数
type PermissionDTO ¶
type PermissionDTO struct {
ID PermissionID `json:"id"`
BaseDTO
Method string `json:"method"`
Path string `json:"path"`
AcceptRoles RoleNameList `json:"accept_roles"`
}
PermissionDTO 表示 Permission 的 REST 网络对象
type PermissionService ¶
type PermissionService interface {
Insert(c context.Context, o *PermissionDTO) (*PermissionDTO, error)
Update(c context.Context, id PermissionID, o *PermissionDTO) (*PermissionDTO, error)
Delete(c context.Context, id PermissionID) error
Find(c context.Context, id PermissionID) (*PermissionDTO, error)
List(c context.Context, q *PermissionQuery) ([]*PermissionDTO, error)
}
PermissionService 是针对 PermissionDTO 的服务
type PermissionVO ¶
type PermissionVO struct {
BaseVO
Permissions []*PermissionDTO `json:"permissions"`
}
PermissionVO ...
type PhoneNumberDTO ¶ added in v1.0.5
type PhoneNumberDTO struct {
ID PhoneNumberID `json:"id"`
BaseDTO
SimpleNunber string `json:"simple_number"`
}
PhoneNumberDTO ...
type PhoneNumberQuery ¶ added in v1.0.5
type PhoneNumberQuery struct {
Pagination Pagination
}
PhoneNumberQuery 查询参数
type PhoneNumberService ¶ added in v1.0.5
type PhoneNumberService interface {
Insert(c context.Context, o *PhoneNumberDTO) (*PhoneNumberDTO, error)
Update(c context.Context, id PhoneNumberID, o *PhoneNumberDTO) (*PhoneNumberDTO, error)
Delete(c context.Context, id PhoneNumberID) error
Find(c context.Context, id PhoneNumberID) (*PhoneNumberDTO, error)
List(c context.Context, q *PhoneNumberQuery) ([]*PhoneNumberDTO, error)
}
PhoneNumberService ...
type RoleName ¶
type RoleName string
RoleName 是 Role 的正式名称
type RoleService ¶
type RoleService interface {
Insert(c context.Context, o *RoleDTO) (*RoleDTO, error)
Update(c context.Context, id RoleID, o *RoleDTO) (*RoleDTO, error)
Delete(c context.Context, id RoleID) error
Find(c context.Context, id RoleID) (*RoleDTO, error)
List(c context.Context, q *RoleQuery) ([]*RoleDTO, error)
}
RoleService 是针对 RoleDTO 的服务
type SessionDTO ¶
type SessionDTO struct {
BaseDTO
ExpiredAt lang.Time `json:"expired_at"` // 会话的过期时间
User UserDTO `json:"user"` // 用户信息
Authenticated bool `json:"authenticated"` // 是否已验证
Properties map[string]string `json:"properties"`
}
SessionDTO 表示会话信息
type SessionVO ¶
type SessionVO struct {
BaseVO
Sessions []*SessionDTO `json:"sessions"`
}
SessionVO ...
type TokenDTO ¶ added in v1.0.18
type TokenDTO struct {
BaseDTO
ExpiredAt lang.Time `json:"expired_at"` // 令牌的过期时间
Session *SessionDTO `json:"session"` // 会话信息
Properties map[string]string `json:"properties"`
}
TokenDTO 表示令牌信息
type UserDTO ¶
type UserDTO struct {
ID UserID `json:"id"`
BaseDTO
Name UserName `json:"name"`
NickName string `json:"nickname"`
Avatar string `json:"avatar"`
Phone string `json:"phone"`
Email string `json:"email"`
Roles RoleNameList `json:"roles"`
}
UserDTO 表示 User 的 REST 网络对象
type UserInfoBinding ¶ added in v1.0.17
type UserInfoBinding struct {
// contains filtered or unexported fields
}
UserInfoBinding 负责把用户信息绑定到当前上下文
func NewUserInfoBinding ¶ added in v1.0.17
func NewUserInfoBinding(info *UserInfo) *UserInfoBinding
NewUserInfoBinding 新建并初始化一个 UserInfoBinding
func (*UserInfoBinding) UserInfo ¶ added in v1.0.17
func (inst *UserInfoBinding) UserInfo() *UserInfo
UserInfo 取用户信息
type UserService ¶
type UserService interface {
Insert(c context.Context, o *UserDTO) (*UserDTO, error)
Update(c context.Context, id UserID, o *UserDTO) (*UserDTO, error)
Delete(c context.Context, id UserID) error
Find(c context.Context, id UserID) (*UserDTO, error)
List(c context.Context, q *UserQuery) ([]*UserDTO, error)
}
UserService 是针对 UserDTO 的服务
Click to show internal directories.
Click to hide internal directories.