Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
piexlmax committed Dec 31, 2021
1 parent 7a6939e commit 722ad31
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
15 changes: 11 additions & 4 deletions server/api/v1/example/exa_breakpoint_continue.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package example

import (
"fmt"
"github.com/flipped-aurora/gin-vue-admin/server/model/example"
"io/ioutil"
"mime/multipart"
"strconv"
Expand Down Expand Up @@ -123,11 +124,17 @@ func (b *FileUploadAndDownloadApi) BreakpointContinueFinish(c *gin.Context) {
// @Success 200 {string} string "{"success":true,"data":{},"msg":"缓存切片删除成功"}"
// @Router /fileUploadAndDownload/removeChunk [post]
func (u *FileUploadAndDownloadApi) RemoveChunk(c *gin.Context) {
fileMd5 := c.Query("fileMd5")
err := utils.RemoveChunk(fileMd5)
var file example.ExaFile
c.ShouldBindJSON(&file)
err := utils.RemoveChunk(file.FileMd5)
if err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err = fileUploadAndDownloadService.DeleteFileChunk(file.FileMd5, file.FileName, file.FilePath)
if err != nil {
global.GVA_LOG.Error("缓存切片删除失败!", zap.Error(err))
response.FailWithMessage( "缓存切片删除失败", c)
global.GVA_LOG.Error(err.Error(), zap.Error(err))
response.FailWithMessage(err.Error(), c)
} else {
response.OkWithMessage("缓存切片删除成功", c)
}
Expand Down
2 changes: 1 addition & 1 deletion server/service/example/exa_breakpoint_continue.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (e *FileUploadAndDownloadService) CreateFileChunk(id uint, fileChunkPath st
func (e *FileUploadAndDownloadService) DeleteFileChunk(fileMd5 string, fileName string, filePath string) error {
var chunks []example.ExaFileChunk
var file example.ExaFile
err := global.GVA_DB.Where("file_md5 = ? AND file_name = ?", fileMd5, fileName).First(&file).Update("IsFinish", true).Update("file_path", filePath).Error
err := global.GVA_DB.Where("file_md5 = ? ", fileMd5).First(&file).Update("IsFinish", true).Update("file_path", filePath).Error
if err != nil {
return err
}
Expand Down
4 changes: 3 additions & 1 deletion web/src/view/example/breakpoint/breakpoint.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,11 @@ const upLoadFileSlice = async(item) => {
if (res.code === 0) {
// 合成文件过后 删除缓存切片
const params = {
fileName: file.value.name,
fileMd5: fileMd5.value,
filePath: res.data.filePath,
}
ElMessage.success(上传成功)
ElMessage.success("上传成功")
await removeChunk(params)
}
}
Expand Down

0 comments on commit 722ad31

Please sign in to comment.