作者 yangfu

feat: file replace log

... ... @@ -61,6 +61,12 @@ func (fileService *FileService) CreateFile(ctx *domain.Context, createFileComman
oldFile.FileInfo = fileInfo
oldFile.UpdatedAt = time.Now()
newFile = oldFile
if err = factory.FastLog(transactionContext, domain.CommonLog, oldFile.FileId, &domainService.FileReplaceLog{
LogEntry: domain.NewLogEntry(oldFile.FileInfo.Name, domain.SourceFile.ToString(), domain.FileUpload, ctx),
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
file, err := fileRepository.Save(newFile)
... ...
... ... @@ -24,6 +24,7 @@ var (
DeleteTable OperationType = "DeleteTable" // 表删除
FileUpload OperationType = "FileUpload" // 文件上传
FileVerify OperationType = "FileVerify" // 文件校验
FileReplace OperationType = "FileReplace" // 文件替换
ExcelTableEdit OperationType = "ExcelTableEdit" // 文档表格编辑
... ... @@ -58,6 +59,7 @@ var OperationTypeMap = map[string]string{
DeleteTable.ToString(): "表删除",
FileUpload.ToString(): "文件上传",
FileVerify.ToString(): "文件校验",
FileReplace.ToString(): "文件覆盖",
ExcelTableEdit.ToString(): "文档表格编辑",
CreateSchema.ToString(): "新增方案",
... ...
... ... @@ -82,6 +82,15 @@ func (ptr *FlushDataTableService) flushSourceFile(ctx *domain.Context, table *do
if err != nil {
return err
}
if len(files) > 0 {
for _, existFile := range files {
if err = FastLog(ptr.transactionContext, domain.CommonLog, file.FileId, &FileReplaceLog{
LogEntry: domain.NewLogEntry(existFile.FileInfo.Name, domain.VerifiedFile.ToString(), domain.FileUpload, ctx),
}); err != nil {
return err
}
}
}
deleteFileService, _ := NewDeleteFileService(ptr.transactionContext)
if err = deleteFileService.DeleteFiles(ctx, files...); err != nil {
return err
... ...
... ... @@ -127,6 +127,15 @@ func (l *FileVerifyLog) Content() string {
return msg
}
// FileReplaceLog 1.1文件已被覆盖
type FileReplaceLog struct {
domain.LogEntry
}
func (l *FileReplaceLog) Content() string {
return fmt.Sprintf("该文件已被覆盖")
}
// GenerateMainTableLog 3.主表生成日志
type GenerateMainTableLog struct {
domain.LogEntry
... ...