...
|
...
|
@@ -54,10 +54,10 @@ func (fileService *FileService) CreateFile(ctx *domain.Context, createFileComman |
|
|
|
|
|
// 文件名相同进行替换
|
|
|
if oldFile, findOldFileErr := fileRepository.FindOne(map[string]interface{}{
|
|
|
"context": ctx,
|
|
|
"fileName": fileInfo.Name,
|
|
|
"context": ctx,
|
|
|
"fileName": fileInfo.Name,
|
|
|
"fileType": domain.SourceFile.ToString(),
|
|
|
}); oldFile != nil && findOldFileErr == nil {
|
|
|
}); oldFile != nil && findOldFileErr == nil {
|
|
|
oldFile.FileInfo = fileInfo
|
|
|
oldFile.UpdatedAt = time.Now()
|
|
|
newFile = oldFile
|
...
|
...
|
@@ -319,6 +319,40 @@ func (fileService *FileService) CancelVerifyingFile(ctx *domain.Context, cmd *co |
|
|
return struct{}{}, nil
|
|
|
}
|
|
|
|
|
|
// CheckFileVerifyStatus 检查文件校验状态
|
|
|
func (fileService *FileService) CheckFileVerifyStatus(ctx *domain.Context, cmd *command.CheckFileVerifyStatusCommand) (interface{}, error) {
|
|
|
if err := cmd.ValidateCommand(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
}
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
fileRepository, file, err := factory.FastPgFile(transactionContext, cmd.FileId)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
var res = struct {
|
|
|
ExistVerifyFile bool `json:"existVerifyFile"`
|
|
|
}{}
|
|
|
_, verifyFiles, findErr := fileRepository.Find(map[string]interface{}{"context": ctx, "fileType": domain.VerifiedFile.ToString(), "sourceFileId": file.SourceFileId})
|
|
|
if findErr == nil && len(verifyFiles) > 0 {
|
|
|
res.ExistVerifyFile = true
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return res, nil
|
|
|
}
|
|
|
|
|
|
func NewFileService(options map[string]interface{}) *FileService {
|
|
|
newFileService := &FileService{}
|
|
|
return newFileService
|
...
|
...
|
|