V2.5.2beta (#1101)
* fix: zap无法在运行时进行切割日志, config.docker.yaml与config.yaml同步 #1094 * feat: 为定时任务增加秒级控制 * feat: 调整代码结构,err更改为后置 * css 样式调整 Co-authored-by: SliverHorn <503551462@qq.com> Co-authored-by: songzhibin97 <718428482@qq.com>
This commit is contained in:
@@ -14,9 +14,9 @@ type FileUploadAndDownloadService struct{}
|
||||
//@function: FindOrCreateFile
|
||||
//@description: 上传文件时检测当前文件属性,如果没有文件则创建,有则返回文件的当前切片
|
||||
//@param: fileMd5 string, fileName string, chunkTotal int
|
||||
//@return: err error, file model.ExaFile
|
||||
//@return: file model.ExaFile, err error
|
||||
|
||||
func (e *FileUploadAndDownloadService) FindOrCreateFile(fileMd5 string, fileName string, chunkTotal int) (err error, file example.ExaFile) {
|
||||
func (e *FileUploadAndDownloadService) FindOrCreateFile(fileMd5 string, fileName string, chunkTotal int) (file example.ExaFile, err error) {
|
||||
var cfile example.ExaFile
|
||||
cfile.FileMd5 = fileMd5
|
||||
cfile.FileName = fileName
|
||||
@@ -24,12 +24,12 @@ func (e *FileUploadAndDownloadService) FindOrCreateFile(fileMd5 string, fileName
|
||||
|
||||
if errors.Is(global.GVA_DB.Where("file_md5 = ? AND is_finish = ?", fileMd5, true).First(&file).Error, gorm.ErrRecordNotFound) {
|
||||
err = global.GVA_DB.Where("file_md5 = ? AND file_name = ?", fileMd5, fileName).Preload("ExaFileChunk").FirstOrCreate(&file, cfile).Error
|
||||
return err, file
|
||||
return file, err
|
||||
}
|
||||
cfile.IsFinish = true
|
||||
cfile.FilePath = file.FilePath
|
||||
err = global.GVA_DB.Create(&cfile).Error
|
||||
return err, cfile
|
||||
return cfile, err
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
@@ -53,7 +53,7 @@ func (e *FileUploadAndDownloadService) CreateFileChunk(id uint, fileChunkPath st
|
||||
//@param: fileMd5 string, fileName string, filePath string
|
||||
//@return: error
|
||||
|
||||
func (e *FileUploadAndDownloadService) DeleteFileChunk(fileMd5 string, fileName string, filePath string) error {
|
||||
func (e *FileUploadAndDownloadService) DeleteFileChunk(fileMd5 string, filePath string) error {
|
||||
var chunks []example.ExaFileChunk
|
||||
var file example.ExaFile
|
||||
err := global.GVA_DB.Where("file_md5 = ? ", fileMd5).First(&file).Update("IsFinish", true).Update("file_path", filePath).Error
|
||||
|
Reference in New Issue
Block a user