correct all comments of functions in service
This commit is contained in:
@@ -8,20 +8,20 @@ import (
|
||||
// @title FindOrCreateFile
|
||||
// @description Check your file if it does not exist, or return current slice of the file
|
||||
// 上传文件时检测当前文件属性,如果没有文件则创建,有则返回文件的当前切片
|
||||
// @auth (2020/04/05 20:22 )
|
||||
// @param FileMd5 string
|
||||
// @param FileName string
|
||||
// @param ChunkTotal int
|
||||
// @auth (2020/04/05 20:22)
|
||||
// @param fileMd5 string
|
||||
// @param fileName string
|
||||
// @param chunkTotal int
|
||||
// @return err error
|
||||
// @return file ExaFile
|
||||
func FindOrCreateFile(FileMd5 string, FileName string, ChunkTotal int) (err error, file model.ExaFile) {
|
||||
func FindOrCreateFile(fileMd5 string, fileName string, chunkTotal int) (err error, file model.ExaFile) {
|
||||
var cfile model.ExaFile
|
||||
cfile.FileMd5 = FileMd5
|
||||
cfile.FileName = FileName
|
||||
cfile.ChunkTotal = ChunkTotal
|
||||
notHaveSameMd5Finish := global.GVA_DB.Where("file_md5 = ? AND is_finish = ?", FileMd5, true).First(&file).RecordNotFound()
|
||||
cfile.FileMd5 = fileMd5
|
||||
cfile.FileName = fileName
|
||||
cfile.ChunkTotal = chunkTotal
|
||||
notHaveSameMd5Finish := global.GVA_DB.Where("file_md5 = ? AND is_finish = ?", fileMd5, true).First(&file).RecordNotFound()
|
||||
if notHaveSameMd5Finish {
|
||||
err = global.GVA_DB.Where("file_md5 = ? AND file_name = ?", FileMd5, FileName).Preload("ExaFileChunk").FirstOrCreate(&file, cfile).Error
|
||||
err = global.GVA_DB.Where("file_md5 = ? AND file_name = ?", fileMd5, fileName).Preload("ExaFileChunk").FirstOrCreate(&file, cfile).Error
|
||||
return err, file
|
||||
} else {
|
||||
cfile.IsFinish = true
|
||||
@@ -34,38 +34,39 @@ func FindOrCreateFile(FileMd5 string, FileName string, ChunkTotal int) (err err
|
||||
|
||||
// @title CreateFileChunk
|
||||
// @description create a chunk of the file, 创建文件切片记录
|
||||
// @auth (2020/04/05 20:22 )
|
||||
// @param FileChunkPath string
|
||||
// @param FileChunkNumber int
|
||||
// @auth (2020/04/05 20:22)
|
||||
// @param id unit
|
||||
// @param fileChunkPath string
|
||||
// @param fileChunkNumber int
|
||||
// @return error
|
||||
func CreateFileChunk(id uint, FileChunkPath string, FileChunkNumber int) error {
|
||||
func CreateFileChunk(id uint, fileChunkPath string, fileChunkNumber int) error {
|
||||
var chunk model.ExaFileChunk
|
||||
chunk.FileChunkPath = FileChunkPath
|
||||
chunk.FileChunkPath = fileChunkPath
|
||||
chunk.ExaFileId = id
|
||||
chunk.FileChunkNumber = FileChunkNumber
|
||||
chunk.FileChunkNumber = fileChunkNumber
|
||||
err := global.GVA_DB.Create(&chunk).Error
|
||||
return err
|
||||
}
|
||||
|
||||
// @title FileCreateComplete
|
||||
// @description file creation, 文件合成完成
|
||||
// @auth (2020/04/05 20:22 )
|
||||
// @param FileMd5 string
|
||||
// @param FileName string
|
||||
// @param FilePath string
|
||||
// @auth (2020/04/05 20:22)
|
||||
// @param fileMd5 string
|
||||
// @param fileName string
|
||||
// @param filePath string
|
||||
// @return error
|
||||
func FileCreateComplete(FileMd5 string, FileName string, FilePath string) error {
|
||||
func FileCreateComplete(fileMd5 string, fileName string, filePath string) error {
|
||||
var file model.ExaFile
|
||||
upDateFile := make(map[string]interface{})
|
||||
upDateFile["FilePath"] = FilePath
|
||||
upDateFile["FilePath"] = filePath
|
||||
upDateFile["IsFinish"] = true
|
||||
err := global.GVA_DB.Where("file_md5 = ? AND file_name = ?", FileMd5, FileName).First(&file).Updates(upDateFile).Error
|
||||
err := global.GVA_DB.Where("file_md5 = ? AND file_name = ?", fileMd5, fileName).First(&file).Updates(upDateFile).Error
|
||||
return err
|
||||
}
|
||||
|
||||
// @title DeleteFileChunk
|
||||
// @description delete a chuck of the file, 删除文件切片记录
|
||||
// @auth (2020/04/05 20:22 )
|
||||
// @auth (2020/04/05 20:22)
|
||||
// @param FileMd5 string
|
||||
// @param FileName string
|
||||
// @param FilePath string
|
||||
|
Reference in New Issue
Block a user