schemago

package
v0.0.0-...-9b07b7c Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrGeneric is used for testing purposes and for errors handled later in the callstack
	ErrGeneric = errors.New("generic error")

	// ErrBadRequest (400) is returned for bad request (validation)
	ErrBadRequest = echo.NewHTTPError(400)

	// ErrUnauthorized (401) is returned when user is not authorized
	ErrUnauthorized = echo.ErrUnauthorized
)

Functions

This section is empty.

Types

type AuthToken

type AuthToken struct {
	Token        string `json:"token"`
	Expires      string `json:"expires"`
	RefreshToken string `json:"refresh_token"`
}

AuthToken holds authentication token details with refresh token

type Logger

type Logger interface {
	// source, msg, error, params
	Log(echo.Context, string, string, error, map[string]interface{})
}

Logger represents logging interface

type Pagination

type Pagination struct {
	Limit  int `json:"limit,omitempty"`
	Offset int `json:"offset,omitempty"`
}

Pagination holds paginations data

type PaginationReq

type PaginationReq struct {
	Limit int `query:"limit"`
	Page  int `query:"page" validate:"min=0"`
}

PaginationReq holds pagination http fields and tags

func (*PaginationReq) Transform

func (p *PaginationReq) Transform() *Pagination

Transform checks and converts http pagination into database pagination model

func (*PaginationReq) TransformMS

func (p *PaginationReq) TransformMS() *Pagination

type RefreshToken

type RefreshToken struct {
	Token   string `json:"token"`
	Expires string `json:"expires"`
}

RefreshToken holds authentication token details

type ReqCreateRole

type ReqCreateRole struct {
	Roleid string `json:"roleid" gorm:"type:varchar(40)"`
}

ReqCreateRole ReqCreateRole

func (*ReqCreateRole) ToSchemaSUserRole

func (c *ReqCreateRole) ToSchemaSUserRole(userid string) *SUserRole

ToSchemaSUserRole ToSchemaSUserRole

type ReqCreateRoles

type ReqCreateRoles []ReqCreateRole

ReqCreateRoles ReqCreateRoles

type ReqCreateUser

type ReqCreateUser struct {
	Recid    string `json:"recid" validate:"required"`
	Code     string `json:"code" validate:"required"`
	Name     string `json:"name" validate:"required,min=3,alphanum"`
	NickName string `json:"nick_name" `

	Password        string `json:"password" validate:"required,min=4"`
	PasswordConfirm string `json:"password_confirm" validate:"required,min=4"`

	Email   string `json:"email"`
	Mobile  string `json:"mobile"`
	Phone   string `json:"phone"`
	Address string `json:"address"`

	Active bool           `json:"active" validate:"required"`
	Roles  ReqCreateRoles `json:"roles" validate:"required"`
}

ReqCreateUser ReqCreateUser

func (*ReqCreateUser) ToSchemaSUser

func (c *ReqCreateUser) ToSchemaSUser() *SUser

ToSchemaSUser ToSchemaSUser

func (*ReqCreateUser) ToSchemaSUserRoles

func (c *ReqCreateUser) ToSchemaSUserRoles() []*SUserRole

ToSchemaSUserRoles ToSchemaSUserRoles

type ReqMenu

type ReqMenu struct {
	PaginationReq
	Code     string `json:"code" validate:"omitempty"`
	Name     string `json:"name" validate:"omitempty"`
	Router   string `json:"router" validate:"omitempty"`
	Parentid string `json:"parentid" validate:"omitempty"`
	Hidden   int    `json:"hidden" validate:"isdefault=-1,min=-1,max=1,omitempty"`
}

ReqMenu query 时的QueryParams

type ReqRole

type ReqRole struct {
	PaginationReq
	Code string `json:"code" validate:"omitempty"`
	Name string `json:"name" validate:"omitempty"`
}

ReqRole request role

type ReqUpdateUser

type ReqUpdateUser struct {
	Recid    string `json:"recid" validate:"required"`
	Code     string `json:"code" validate:"required"`
	Name     string `json:"name" validate:"required,min=3,alphanum"`
	NickName string `json:"nick_name" `

	Email   string `json:"email"`
	Mobile  string `json:"mobile"`
	Phone   string `json:"phone"`
	Address string `json:"address"`

	Active bool           `json:"active" validate:"required"`
	Roles  ReqCreateRoles `json:"roles" validate:"required"`
}

ReqUpdateUser ReqUpdateUser

func (*ReqUpdateUser) ToSchemaSUser

func (c *ReqUpdateUser) ToSchemaSUser() *SUser

ToSchemaSUser ToSchemaSUser

func (*ReqUpdateUser) ToSchemaSUserRoles

func (c *ReqUpdateUser) ToSchemaSUserRoles() []*SUserRole

ToSchemaSUserRoles ToSchemaSUserRoles

type ReqUser

type ReqUser struct {
	PaginationReq
	Code string `json:"code" validate:"omitempty"`
	Name string `json:"name" validate:"omitempty"`
}

ReqUser request user

type RespMenu

type RespMenu struct {
	Recid     string `json:"recid" validate:"required"`
	Code      string `json:"code" validate:"required"`
	Name      string `json:"name" validate:"required"`
	Seq       string `json:"seq" validate:"required"`
	Icon      string `json:"icon" validate:"required"`
	Router    string `json:"router" validate:"required"`
	Parentid  string `json:"parentid" validate:"omitempty"`
	Hidden    bool   `json:"hidden" validate:"omitempty"`
	Usercode  string `json:"usercode" validate:"required"`
	Resources RespMenuResources
}

RespMenu RespMenu

func (*RespMenu) ToSchemaMenu

func (m *RespMenu) ToSchemaMenu() *SMenu

ToSchemaMenu ToSchemaMenu

func (*RespMenu) ToSchemaMenuResources

func (m *RespMenu) ToSchemaMenuResources() SMenuResources

ToSchemaMenuResources ToSchemaMenuResources

type RespMenuResource

type RespMenuResource struct {
	Code   string `json:"code" validate:"required"`
	Name   string `json:"name" validate:"required"`
	Method string `json:"method" validate:"required"`
	Path   string `json:"path" validate:"required"`
}

RespMenuResource RespMenuResource

func (*RespMenuResource) ToSchemaMenuResource

func (m *RespMenuResource) ToSchemaMenuResource(menuid string) *SMenuResource

ToSchemaMenuResource ToSchemaMenuResource

type RespMenuResources

type RespMenuResources []*RespMenuResource

RespMenuResources RespMenuResources

type RespRole

type RespRole struct {
	ID        uint `gorm:"primary_key"`
	CreatedAt time.Time
	UpdatedAt time.Time
	Recid     string        `json:"recid" gorm:"type:varchar(40);not null;unique"`
	Code      string        `json:"code" gorm:"type:varchar(50);not null;unique"`
	Name      string        `json:"name" gorm:"type:varchar(50);not null;unique"`
	Seq       string        `json:"seq" gorm:"type:varchar(10)"`
	Usercode  string        `json:"usercode" gorm:"type:varchar(40)"`
	Menus     RespRoleMenus `json:"menus"`
}

RespRole 返回

func (*RespRole) ToSchemaRole

func (a *RespRole) ToSchemaRole() *SRole

ToSchemaRole d

func (RespRole) ToSchemaRoleMenus

func (a RespRole) ToSchemaRoleMenus() []SRoleMenu

ToSchemaRoleMenus dToSchemaRoleMenu

type RespRoleMenu

type RespRoleMenu struct {
	Menuid    string `json:"menuid" gorm:"type:varchar(40)"`
	Resources []string
}

RespRoleMenu 返回

func (*RespRoleMenu) ToSchemaRoleMenu

func (a *RespRoleMenu) ToSchemaRoleMenu(roleID string) SRoleMenu

ToSchemaRoleMenu ToSchemaRoleMenu

type RespRoleMenus

type RespRoleMenus []*RespRoleMenu

RespRoleMenus 菜单

type RespUser

type RespUser struct {
	SUser
	SUserRoles
}

RespUser RespUser

type SMenu

type SMenu struct {
	gorm.Model
	Recid    string `json:"recid" gorm:"type:varchar(40);not null;unique"`
	Code     string `json:"code" gorm:"type:varchar(50);not null;unique"`
	Name     string `json:"name" gorm:"type:varchar(50);not null;unique"`
	Seq      string `json:"seq" gorm:"type:varchar(10)"`
	Icon     string `json:"icon" gorm:"type:varchar(20)"`
	Router   string `json:"router" gorm:"type:varchar(50)"`
	Parentid string `json:"parentid" gorm:"type:varchar(40)"`
	Hidden   bool   `json:"hidden"`
	Usercode string `json:"usercode" gorm:"type:varchar(40)"`
}

SMenu 菜单

type SMenuResource

type SMenuResource struct {
	gorm.Model
	Menuid string `json:"menuid" gorm:"type:varchar(40)"`
	Code   string `json:"code" gorm:"type:varchar(50)"`
	Name   string `json:"name" gorm:"type:varchar(50)"`
	Method string `json:"method" gorm:"type:varchar(50)"`
	Path   string `json:"path" gorm:"type:varchar(50)"`
}

SMenuResource 菜单

type SMenuResources

type SMenuResources []*SMenuResource

SMenuResources SMenuResources

func (*SMenuResources) ToRespResource

func (s *SMenuResources) ToRespResource() RespMenuResources

ToRespResource ToRespResource

type SRole

type SRole struct {
	gorm.Model
	Recid    string `json:"recid" gorm:"type:varchar(40);not null;unique"`
	Code     string `json:"code" gorm:"type:varchar(50);not null;unique"`
	Name     string `json:"name" gorm:"type:varchar(50);not null;unique"`
	Seq      string `json:"seq" gorm:"type:varchar(10)"`
	Usercode string `json:"usercode" gorm:"type:varchar(40)"`
}

SRole 角色

func (*SRole) ToRespondRole

func (a *SRole) ToRespondRole() *RespRole

ToRespondRole ToRespondRole

type SRoleMenu

type SRoleMenu struct {
	gorm.Model
	Roleid   string `json:"roleid" gorm:"type:varchar(40)"`
	Menuid   string `json:"menuid" gorm:"type:varchar(40)"`
	Resource string
}

SRoleMenu 角色对应的

func (*SRoleMenu) ToRespondRoleMenu

func (a *SRoleMenu) ToRespondRoleMenu() *RespRoleMenu

ToRespondRoleMenu 转换为角色菜单对象

type SRoleMenus

type SRoleMenus []SRoleMenu

SRoleMenus SRoleMenus

func (SRoleMenus) ToMap

func (a SRoleMenus) ToMap() map[string]SRoleMenu

ToMap 转换为键值映射

func (SRoleMenus) ToRespondRoleMenus

func (a SRoleMenus) ToRespondRoleMenus() []*RespRoleMenu

ToRespondRoleMenus 转换为角色菜单对象列表

type SUser

type SUser struct {
	gorm.Model
	Recid    string `json:"recid" gorm:"type:varchar(40);not null;unique"`
	Code     string `json:"code" gorm:"type:varchar(50);not null;unique"`
	Name     string `json:"name" gorm:"type:varchar(50);not null;unique"`
	NickName string `json:"nick_name" gorm:"type:varchar(50)"`

	Password string `json:"-"`
	Email    string `json:"email"`

	Mobile  string `json:"mobile"`
	Phone   string `json:"phone"`
	Address string `json:"address"`

	Active bool `json:"active"`

	LastLogin          time.Time `json:"last_login" `
	LastPasswordChange time.Time `json:"last_password_change"`

	Token string `json:"-"`
}

SUser 用户

func (*SUser) ChangePassword

func (u *SUser) ChangePassword(hash string)

ChangePassword updates user's password related fields

func (*SUser) UpdateLastLogin

func (u *SUser) UpdateLastLogin(token string)

UpdateLastLogin updates last login field

type SUserRole

type SUserRole struct {
	gorm.Model
	Userid string `json:"userid" gorm:"type:varchar(40)"`
	Roleid string `json:"roleid" gorm:"type:varchar(40)"`
}

SUserRole 用户对应的角色

type SUserRoles

type SUserRoles []SUserRole

SUserRoles SUserRole

Jump to

Keyboard shortcuts

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