middleware

package
v0.0.0-...-6e4d488 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Casbin

func Casbin() iris.Handler

Casbin Casbin 权鉴中间件

func Check

func Check(r *http.Request, userId string) (bool, error)

Check checks the username, request's method and path and returns true if permission grandted otherwise false.

func CreateOplog

func CreateOplog(ol Oplog) error

CreateOplog

func CrsAuth

func CrsAuth() context.Handler

CrsAuth 跨域中间件

func InitCheck

func InitCheck() iris.Handler

InitCheck 初始化检测中间件

func IsMobileReg

func IsMobileReg() iris.Handler

查询手机号是否被注册

func IsReg

func IsReg(mobile string) (string, error)

func JwtHandler

func JwtHandler() iris.Handler

*

  • 验证 jwt
  • @method JwtHandler

func MobileScope

func MobileScope(mobile string) func(db *gorm.DB) *gorm.DB

- mobile 手机

func OperationRecord

func OperationRecord() iris.Handler

OperationRecord 操作日志中间件

Types

type BaseUser

type BaseUser struct {
	Uuid     string `gorm:"type:varchar(36);" json:"uuid"`
	Sex      string `gorm:"default:'0';not null; type:tinyint(1)" json:"sex"`
	Age      string `gorm:"default:'0';not null; type:tinyint(2)" json:"age"`
	Region   string `gorm:"not null; type:varchar(15)" json:"region"`
	Mobile   string `gorm:"not null; type:varchar(20)" json:"mobile" validate:"required"`
	Nickname string `gorm:"not null; type:varchar(60)" json:"nickname"`
	Name     string `gorm:"index;not null; type:varchar(60)" json:"name"`
	Username string `gorm:"uniqueIndex;not null;type:varchar(60)" json:"username"`
	Identity string `gorm:"not null; type:varchar(30)" json:"identity"`
	Intro    string `gorm:"not null; type:varchar(512)" json:"intro"`
	Avatar   string `gorm:"type:varchar(1024)" json:"avatar"`
}

type Oplog

type Oplog struct {
	gorm.Model
	Ip           string        `json:"ip" form:"ip" gorm:"column:ip;comment:请求ip"`
	Method       string        `json:"method" form:"method" gorm:"column:method;comment:请求方法" validate:"required"`
	Path         string        `json:"path" form:"path" gorm:"column:path;comment:请求路径" validate:"required"`
	Status       int           `json:"status" form:"status" gorm:"column:status;comment:请求状态" validate:"required"`
	Latency      time.Duration `json:"latency" form:"latency" gorm:"column:latency;comment:延迟"`
	Agent        string        `json:"agent" form:"agent" gorm:"column:agent;comment:代理"`
	ErrorMessage string        `json:"error_message" form:"error_message" gorm:"column:error_message;comment:错误信息"`
	Body         string        `json:"body" form:"body" gorm:"type:longtext;column:body;comment:请求Body"`
	Resp         string        `json:"resp" form:"resp" gorm:"type:longtext;column:resp;comment:响应Body"`
	UserID       uint          `json:"user_id" form:"user_id" gorm:"column:user_id;comment:用户id"`
}

Oplog 中间件 model

type Request

type Request struct {
	Mobile string `json:"mobile"`
	Code   string `json:"code"`
}

type Response

type Response struct {
	g.Model
	BaseUser
	Roles []string `gorm:"-" json:"roles"`
}

func FindByUserName

func FindByUserName(scopes ...func(db *gorm.DB) *gorm.DB) (*Response, error)

FindByName

func (*Response) First

func (res *Response) First(db *gorm.DB, scopes ...func(db *gorm.DB) *gorm.DB) error

type User

type User struct {
	gorm.Model
	BaseUser
	Password string `gorm:"type:varchar(250)" json:"password" validate:"required"`
	RoleIds  []uint `gorm:"-" json:"role_ids"`
}

Jump to

Keyboard shortcuts

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