From e38225a4cb410cf04d111d6d0e8e710a9736b961 Mon Sep 17 00:00:00 2001 From: piexlmax <303176530@qq.com> Date: Sat, 1 Jan 2022 00:44:43 +0800 Subject: [PATCH] fixed: #862 --- .../api/v1/example/exa_breakpoint_continue.go | 13 +++++++++--- .../model/example/exa_breakpoint_continue.go | 6 +++--- .../example/exa_breakpoint_continue.go | 2 +- web/src/api/breakpoint.js | 9 ++++++++ web/src/utils/request.js | 6 +++--- .../view/example/breakpoint/breakpoint.vue | 21 +++++++++++++------ 6 files changed, 41 insertions(+), 16 deletions(-) diff --git a/server/api/v1/example/exa_breakpoint_continue.go b/server/api/v1/example/exa_breakpoint_continue.go index 503f439b5..9dbb2f0e1 100644 --- a/server/api/v1/example/exa_breakpoint_continue.go +++ b/server/api/v1/example/exa_breakpoint_continue.go @@ -2,6 +2,7 @@ package example import ( "fmt" + "github.com/flipped-aurora/gin-vue-admin/server/model/example" "io/ioutil" "mime/multipart" "strconv" @@ -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 { global.GVA_LOG.Error("缓存切片删除失败!", zap.Error(err)) - response.FailWithMessage("缓存切片删除失败", c) + return + } + err = fileUploadAndDownloadService.DeleteFileChunk(file.FileMd5, file.FileName, file.FilePath) + if err != nil { + global.GVA_LOG.Error(err.Error(), zap.Error(err)) + response.FailWithMessage(err.Error(), c) } else { response.OkWithMessage("缓存切片删除成功", c) } diff --git a/server/model/example/exa_breakpoint_continue.go b/server/model/example/exa_breakpoint_continue.go index 3c2924bdb..5d665da84 100644 --- a/server/model/example/exa_breakpoint_continue.go +++ b/server/model/example/exa_breakpoint_continue.go @@ -7,9 +7,9 @@ import ( // file struct, 文件结构体 type ExaFile struct { global.GVA_MODEL - FileName string - FileMd5 string - FilePath string + FileName string `json:"fileName"` + FileMd5 string `json:"fileMd5"` + FilePath string `json:"filePath"` ExaFileChunk []ExaFileChunk ChunkTotal int IsFinish bool diff --git a/server/service/example/exa_breakpoint_continue.go b/server/service/example/exa_breakpoint_continue.go index f4de9eee5..8a8a23a2a 100644 --- a/server/service/example/exa_breakpoint_continue.go +++ b/server/service/example/exa_breakpoint_continue.go @@ -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 } diff --git a/web/src/api/breakpoint.js b/web/src/api/breakpoint.js index 04d754e8a..eb4b8d1c0 100644 --- a/web/src/api/breakpoint.js +++ b/web/src/api/breakpoint.js @@ -16,6 +16,15 @@ export const findFile = (params) => { }) } +export const breakpointContinue = (data) => { + return service({ + url: '/fileUploadAndDownload/breakpointContinue', + method: 'post', + headers: { 'Content-Type': 'multipart/form-data' }, + data + }) +} + export const breakpointContinueFinish = (params) => { return service({ url: '/fileUploadAndDownload/breakpointContinueFinish', diff --git a/web/src/utils/request.js b/web/src/utils/request.js index f386b7284..ac607d9d1 100644 --- a/web/src/utils/request.js +++ b/web/src/utils/request.js @@ -36,11 +36,11 @@ service.interceptors.request.use( } const token = store.getters['user/token'] const user = store.getters['user/userInfo'] - config.data = JSON.stringify(config.data) config.headers = { 'Content-Type': 'application/json', 'x-token': token, - 'x-user-id': user.ID + 'x-user-id': user.ID, + ...config.headers } return config }, @@ -70,7 +70,7 @@ service.interceptors.response.use( } else { ElMessage({ showClose: true, - message: response.data.msg||decodeURI(response.headers.msg), + message: response.data.msg || decodeURI(response.headers.msg), type: 'error' }) if (response.data.data && response.data.data.reload) { diff --git a/web/src/view/example/breakpoint/breakpoint.vue b/web/src/view/example/breakpoint/breakpoint.vue index 89cf2a7dc..a9704678a 100644 --- a/web/src/view/example/breakpoint/breakpoint.vue +++ b/web/src/view/example/breakpoint/breakpoint.vue @@ -33,11 +33,11 @@