operation

package
v1.1.1-alpha12 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2021 License: Apache-2.0 Imports: 12 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CONFIG = Operation{
	Except: Route{
		Uri:    "api/v1/upload;api/v1/upload",
		Method: "post;put",
	},
	Include: Route{
		Uri:    "api/v1/menus",
		Method: "get",
	},
}

Functions

func CreateOplog

func CreateOplog(ol *Oplog) error

CreateOplog

func GetMigration

func GetMigration() *gormigrate.Migration

Types

type Operation

type Operation struct {
	Except  Route `mapstructure:"except" json:"except" yaml:"except"`
	Include Route `mapstructure:"include" json:"include" yaml:"include"`
}

Operation 操作日志配置 Except 排除生成操作日志的路由,多条使用 ; 号分割 Include 包括生成操作日志的路由,多条使用 ; 号分割

func (Operation) GetExcept

func (op Operation) GetExcept() ([]string, []string)

GetExcept 返回需要排除路由数组数据

func (Operation) GetInclude

func (op Operation) GetInclude() ([]string, []string)

GetInclude 返回需要包含路由数组数据

func (Operation) IsExcept

func (op Operation) IsExcept(uri, method string) bool

IsExcept 判断当前路由是否需要属于排除数据中

func (Operation) IsInclude

func (op Operation) IsInclude(uri, method string) bool

IsInclude 判断当前路由是否需要属于包含数据中

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"`
	TenancyId    uint          `json:"tenancyId" form:"tenancyId" gorm:"column:tenancy_id;comment:商户id"`
}

Oplog 中间件 model

type Route

type Route struct {
	Uri    string `mapstructure:"uri" json:"uri" yaml:"uri"`
	Method string `mapstructure:"method" json:"method" yaml:"method"`
}

Jump to

Keyboard shortcuts

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