dblog

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

日志模块

Index

Constants

View Source
const (
	CREATE    int64 = 1
	QUERY     int64 = 2
	UPDATE    int64 = 3
	DOWNLOAD  int64 = 4
	IMPORT    int64 = 5
	OTHER     int64 = 6
	DELETE    int64 = 7
	LOGIN     int64 = 8
	LOGIN_OUT int64 = 9
	UPLOAD    int64 = 10
	EXPORT    int64 = 11
)
View Source
const (
	ERROR   int64 = -1
	SUCCESS int64 = 0
)

Variables

View Source
var NotSaveLogMethod = []string{
	"/account/myinfo",
	"/account/list",
	"/account/listbyidentity",
	"/account/identity/query",
	"/account/UnauthorizedMethodList",
	"/account/getAccountInfoByUsername",
	"/get/account/under/department",
	"/group/list",
	"/account/department/list",
	"/account/department/treelist",
	"/account/department/children",
	"/account/department/one/level/children/",
	"/account/identity/detail",
	"/account/identity/list",
	"/account/identity/list_by_jurisdiction_code",
	"/account/jurisdiction/detail",
	"/account/jurisdiction/list",
	"/account/jurisdiction/treelist",
	"/system/log/create",
	"/system/log/list",
	"/account/query",
	"/nav/tree",
}

Functions

func BatchInsert

func BatchInsert(osArgs ...OperateType) error

func GetUuid

func GetUuid() string

func InitDbLogApi

func InitDbLogApi()

func PathIfNotExistsCreate

func PathIfNotExistsCreate(path string) (bool, error)

func UnixToLoaclTime

func UnixToLoaclTime(t int64) string

func Write

func Write(serviceName, serviceIp, moduleName, protocol, requestParam, responseParam, requestIp, method, createBy string, status int64, detail string) error

写入日志信息

Types

type DownloadLogFileReq

type DownloadLogFileReq struct {
	StartTime int64 `json:"start_time"`
	EndTime   int64 `json:"end_time"`
}
func UpdateWrite(uuid, responseParam string) error {
	go func() {
		log := Log{
			ResponseParam: responseParam,
		}
		basedboperat.Update(&log,nil,"uuid = ?",uuid)
	}()
	return nil
}

type Log

type Log struct {
	ID            int64  `json:"id"`                                                        //id
	ServiceName   string `json:"service_name" xorm:"varchar(125)" gorm:"type:varchar(256)"` //服务名
	ServiceIp     string `json:"service_ip" xorm:"varchar(125)" gorm:"type:varchar(256)"`   //服务ip
	ModuleName    string `json:"module_name" xorm:"varchar(125)" gorm:"type:varchar(256)"`  //模块名
	Protocol      string `json:"protocol" xorm:"varchar(125)" gorm:"type:varchar(256)"`     //协议
	RequestParam  string `json:"request_param"`                                             //入参
	ResponseParam string `json:"response_param"`                                            //出参
	RequestIp     string `json:"request_ip" xorm:"varchar(125)" gorm:"type:varchar(256)"`   //请求
	Method        string `json:"method" xorm:"varchar(256)" gorm:"type:varchar(256)"`       //请求路径
	CreatedAt     int64  `json:"created_at" xorm:"created"`                                 //创建时间
	UpdatedAt     int64  `json:"updated_at" xorm:"updated"`                                 //更新时间
	CreatedBy     string `json:"created_by" xorm:"varchar(125)" gorm:"type:varchar(256)"`   //创建人
	Status        int64  `json:"status"`
	Detail        string `json:"detail" xorm:"longtext"`
	OperateType   int64  `json:"operate_type" xorm:"-"`
	MethodName    string `json:"method_name" xorm:"-"`
}

func (*Log) AfterQuery

func (l *Log) AfterQuery()

func (*Log) Save

func (l *Log) Save() error

将日志保存到数据库

func (Log) TableName

func (Log) TableName() string

type OperateType

type OperateType struct {
	Id          int64
	Type        int64  `json:"type"`
	Method      string `json:"method"`
	ServiceName string `json:"serviceName"`
	ModuleName  string `json:"moduleName"`
	MethodName  string `json:"method_name"`
}

func NewCrudOperateType

func NewCrudOperateType(method string, serverName string, methodName string, CRUD_FLAG ...string) (os []OperateType)

func NewOperateType

func NewOperateType(o int64, method string, serverName string, methodName string) OperateType

func (OperateType) TableName

func (OperateType) TableName() string

Jump to

Keyboard shortcuts

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