entitys

package
v0.0.0-...-a4d5418 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeOK        = 0
	CodeErr       = 50
	CodeNoAuth    = 51 //您没有执行该操作的权限
	CodeTOKENERR  = 52 //token错误
	CodeValidFail = 53 //格式验证错误
)
View Source
const (
	RequestTypeFromData = iota + 1
	RequestTypeApplicationJson
)

api接受协议类型

View Source
const (
	Enable  = 1 //有效
	Disable = 2 //无效
)
View Source
const (
	IsSuper = 1 //超级用户标识
)

Variables

View Source
var CodeMsg = map[uint32]string{
	CodeErr:      "错误",
	CodeNoAuth:   "您没有执行该操作的权限",
	CodeTOKENERR: "token错误",
}
View Source
var (
	JwtSecretKey string //jwt验证密码
)

Functions

func NewWebErr

func NewWebErr(code uint32, originalMsg ...string) error

构造webErr

Types

type CustomClaims

type CustomClaims struct {
	UserId uint32
	jwt.StandardClaims
}

jwt认证

type EnableRole

type EnableRole struct {
	RoleId int //角色id
	Status int //角色状态:1=启用,2=禁用
}

禁用、启动角色

type JsonResult

type JsonResult struct {
	Code uint32
	Msg  string
	Data interface{}
}

json数据输出

type Login

type Login struct {
	UserName string `field:"账号"` //账号
	Password string `field:"密码"` //密码
}

登录结构体

type Pager

type Pager struct {
	Page      int         //当前页
	PageSize  int         //页大小 ,页大小 小于 0 返回所有数据
	Total     int64       //总量
	SliceData interface{} //切片源数据
}

func (*Pager) DoPage

func (this *Pager) DoPage() error

切片分页 pageSize=-1 返回全部数据

func (*Pager) Offset

func (this *Pager) Offset() int

偏移量

func (*Pager) SetSliceData

func (this *Pager) SetSliceData(data interface{}) *Pager

func (*Pager) Size

func (this *Pager) Size() int

页大小

func (*Pager) ToSlice

func (this *Pager) ToSlice(arr interface{}) ([]interface{}, error)

slice interface 变数组

type Perm

type Perm struct {
	Id         uint32
	Name       string
	PermUrl    string
	PermTreeId uint32 //用于树形结构展示
	Sort       uint32 //排序字段
}

权限表

type PermTree

type PermTree struct {
	Id          uint32
	Name        string
	SubPermTree []PermTree
}

权限数结构

type QueryRoleParam

type QueryRoleParam struct {
	RoleId int //角色Id
	TypeId int //用户类型
}

查询角色参数

type Role

type Role struct {
	Id         uint32
	Name       string    //角色名称
	Desc       string    //角色描述
	Enable     bool      //角色状态:1=启用,2=禁用
	CreateTime time.Time //创建时间
	UpdateTime time.Time //更新时间
	Perms      []Perm    `orm:"-"` //角色的权限信息
}

角色表

type RolePerm

type RolePerm struct {
	Id     uint32
	RoleId uint32
	PermId uint32
}

角色-权限中间表

type RoleSearchParams

type RoleSearchParams struct {
	Pager
	Name string
}

角色搜索参数

type RoleUser

type RoleUser struct {
	Id     uint32
	RoleId uint32
	UserId uint32
}

角色-用户中间表

type SaveRole

type SaveRole struct {
	RoleId  int    //角色id:修改时传入
	Name    string //角色名称
	TypeId  int    //角色类型
	Status  int    //状态:1=启用,2=禁用
	PermIds []int  //勾选了权限项的id
}

添加角色、编辑角色

type SearchUser

type SearchUser struct {
	Pager
	Params string //搜索列表
}

用户列表搜索参数

type User

type User struct {
	Id         uint32
	UserName   string    `field:"账号"`                       //用户名
	Password   string    `field:"密码"json:"-"`               //密码
	Salt       string    `json:"-"`                         //密码加密盐
	Name       string    `field:"名称"  `                     //姓名
	Mobile     string    `field:"手机号"  valid:"Mobile"`      //手机号码
	Email      string    `field:"邮箱"  valid:"Email"`        //邮箱
	Memo       string    `field:"备注"  valid:"MaxSize(20);"` //备注
	Enable     uint      //用户状态:1=启用,2=禁用
	IsSuper    uint      //超级用户标识:1=超级用户,其他=非超级用户
	CreateTime time.Time //创建时间
	UpdateTime time.Time //更新时间
}

用户表

type WebErr

type WebErr struct {
	Code        uint32 //错误码
	Msg         string //展示错误消息
	OriginalMsg string //原始的错误消息
}

func (WebErr) Error

func (this WebErr) Error() string

func (WebErr) Log

func (this WebErr) Log() string

Jump to

Keyboard shortcuts

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