gva-pms/server/model/system/sys_operation_record.go

65 lines
3.3 KiB
Go

// 自动生成模板SysOperationRecord
package system
import (
"time"
"github.com/flipped-aurora/gin-vue-admin/server/global"
)
// 如果含有time.Time 请自行import time包
type SysOperationRecord struct {
global.GVA_MODEL
Ip string `json:"ip" form:"ip" gorm:"column:ip;comment:请求ip"` // 请求ip
Method string `json:"method" form:"method" gorm:"column:method;comment:请求方法"` // 请求方法
Path string `json:"path" form:"path" gorm:"column:path;comment:请求路径"` // 请求路径
Status int `json:"status" form:"status" gorm:"column:status;comment:请求状态"` // 请求状态
Latency time.Duration `json:"latency" form:"latency" gorm:"column:latency;comment:延迟" swaggertype:"string"` // 延迟
Agent string `json:"agent" form:"agent" gorm:"type:text;column:agent;comment:代理"` // 代理
ErrorMessage string `json:"error_message" form:"error_message" gorm:"column:error_message;comment:错误信息"` // 错误信息
Body string `json:"body" form:"body" gorm:"type:text;column:body;comment:请求Body"` // 请求Body
Resp string `json:"resp" form:"resp" gorm:"type:text;column:resp;comment:响应Body"` // 响应Body
UserID int `json:"user_id" form:"user_id" gorm:"column:user_id;comment:用户id"` // 用户id
User SysUser `json:"user"`
//SysTableName string `json:"sys_table_name" form:"sys_table_name" gorm:"column:sys_table_name;comment:系统表名"`
//FieldRecords []SysFieldRecord `json:"field_records" gorm:"foreignKey:OperationRecordID;references:ID"`
}
//type SysFieldRecord struct {
// global.GVA_MODEL
// OperationRecordID int `json:"operation_record_id"` // 操作记录id
// OperationType string `json:"operation_type"` // 操作类型
// FieldName string `json:"field_name"`
// OldValue string `json:"old_value"`
// NewValue string `json:"new_value"`
//}
// BeforeUpdate 钩子:记录旧值
//func (s *SysOperationRecord) BeforeUpdate(tx *gorm.DB) (err error) {
// var oldModel SysOperationRecord
// // 查询数据库中的旧值
// tx.Model(s).Last(&oldModel)
// return nil
//}
type MonitorConfig struct {
global.GVA_MODEL
BusinessDB string `json:"business_db" gorm:"column:business_db;comment:业务数据库"` // 业务数据库
Database string `json:"database" gorm:"column:database;comment:数据库名"`
Table string `json:"table" gorm:"column:table;comment:表名"`
Columns []string `json:"columns" gorm:"type:text;column:columns;comment:字段列表(json数组)"`
IsEnabled bool `json:"is_enabled" gorm:"column:is_enabled;comment:是否启用"`
}
type ChangeLog struct {
global.GVA_MODEL
Database string `json:"database"` // 数据库名
Table string `json:"table"` // 表名
Column string `json:"column"` // 字段名
OldValue string `json:"old_value"` // 旧值(json)
NewValue string `json:"new_value"` // 新值(json)
RecordID uint `json:"record_id"` // 记录ID
ChangedAt time.Time `json:"changed_at"` // 变更时间
OperType string `json:"oper_type"` // 操作类型(U/P/D)
}