package domain

import "time"

// Log 日志
type Log struct {
	// 日志ID
	LogId int `json:"logId"`
	// 日志类型 1.校验步骤  2.常规日志
	LogType string `json:"logType"`
	// 源数据ID
	SourceId int `json:"sourceId"`
	// 日志内容
	Entry *LogEntry `json:"entry"`
	// 对象名称 数据表名 / 文件名
	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"`
	// 创建时间
	CreatedAt time.Time `json:"createdAt"`
	// 扩展
	Context *Context `json:"context"`
	// 日志时间
	LogTime string `json:"log_time"`
}

type LogRepository interface {
	Save(log *Log) (*Log, error)
	Remove(log *Log) (*Log, error)
	FindOne(queryOptions map[string]interface{}) (*Log, error)
	Find(queryOptions map[string]interface{}) (int64, []*Log, error)
}

func (log *Log) Identify() interface{} {
	if log.LogId == 0 {
		return nil
	}
	return log.LogId
}

func (log *Log) Update(data map[string]interface{}) error {
	return nil
}