log_entry.go 982 字节
package domain

// LogEntry 日志内容
type LogEntry struct {
	// 对象名称 数据表名 / 文件名
	ObjectName string `json:"objectName"`
	// 对象类型 1.主表 2.分表 3.副表 4.源文件 5.校验文件
	ObjectType string `json:"objectType"`
	// 操作类型 1.主表生成 2.主表拆分 3.数据导入 4.分表生成 5.表复制 6.编辑记录 7.文件上传 8.文件校验
	OperationType string `json:"operationType"`
	// 日志内容
	Content string `json:"content"`
	// 操作人名称
	OperatorName string `json:"operatorName"`

	ctx *Context `json:"-"`
}

func (l LogEntry) Entry() LogEntry {
	return l
}

func (l LogEntry) Context() *Context {
	return l.ctx
}

func NewLogEntry(fileOrTableName string, objectType string, operationType OperationType, ctx *Context) LogEntry {
	return LogEntry{
		ObjectName:    fileOrTableName,
		ObjectType:    objectType,
		OperationType: operationType.ToString(),
		OperatorName:  ctx.OperatorName,
		ctx:           ctx,
	}
}