diff --git a/server/api/v1/example/exa_breakpoint_continue.go b/server/api/v1/example/exa_breakpoint_continue.go index e10db174f95d20ad92705662a0139d632ad6465f..9dbb2f0e132bba7a90817df3e54636969df359a6 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,18 +124,18 @@ 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") - fileName := c.Query("fileName") - filePath := c.Query("filePath") - 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)) return } - err = fileUploadAndDownloadService.DeleteFileChunk(fileMd5, fileName, filePath) + err = fileUploadAndDownloadService.DeleteFileChunk(file.FileMd5, file.FileName, file.FilePath) if err != nil { - global.GVA_LOG.Error("缓存切片删除失败!", zap.Error(err)) - response.FailWithDetailed(exampleRes.FilePathResponse{FilePath: filePath}, "缓存切片删除失败", c) + global.GVA_LOG.Error(err.Error(), zap.Error(err)) + response.FailWithMessage(err.Error(), c) } else { - response.OkWithDetailed(exampleRes.FilePathResponse{FilePath: filePath}, "缓存切片删除成功", c) + response.OkWithMessage("缓存切片删除成功", c) } } diff --git a/server/model/example/exa_breakpoint_continue.go b/server/model/example/exa_breakpoint_continue.go index 3c2924bdbb955337678af7846b4c0af329f0d046..5d665da84b6c3c67321b67f1b73172fc55340ef0 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 f4de9eee5e5a8305950b26129a60e7086d822e05..8a8a23a2a477a0dd32909c98b40f3c2958452129 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/server/source/system/api.go b/server/source/system/api.go index 603f9a1beee33b9cdef1aa2a8c89493233c0642a..25667cfd4e34c6c0b24a9ad4dd2ab74a1ea9739c 100644 --- a/server/source/system/api.go +++ b/server/source/system/api.go @@ -60,8 +60,9 @@ func (a *api) Initialize() error { {ApiGroup: "菜单", Method: "POST", Path: "/menu/addMenuAuthority", Description: "增加menu和角色关联关系"}, {ApiGroup: "分片上传", Method: "POST", Path: "/fileUploadAndDownload/findFile", Description: "寻找目标文件(秒传)"}, - {ApiGroup: "分片上传", Method: "POST", Path: "/fileUploadAndDownload/breakpointContinueFinish", Description: "断点续传"}, - {ApiGroup: "分片上传", Method: "POST", Path: "/fileUploadAndDownload/removeChunk", Description: "上传完成"}, + {ApiGroup: "分片上传", Method: "POST", Path: "/fileUploadAndDownload/breakpointContinue", Description: "断点续传"}, + {ApiGroup: "分片上传", Method: "POST", Path: "/fileUploadAndDownload/breakpointContinueFinish", Description: "断点续传完成"}, + {ApiGroup: "分片上传", Method: "POST", Path: "/fileUploadAndDownload/removeChunk", Description: "上传完成移除文件"}, {ApiGroup: "文件上传与下载", Method: "POST", Path: "/fileUploadAndDownload/upload", Description: "文件上传示例"}, {ApiGroup: "文件上传与下载", Method: "POST", Path: "/fileUploadAndDownload/deleteFile", Description: "删除文件"}, diff --git a/server/source/system/casbin.go b/server/source/system/casbin.go index b8edaae723e165495578bf82cac2160e6c3db629..dfeba6a69782fe1af998bcd2be14652b20230252 100644 --- a/server/source/system/casbin.go +++ b/server/source/system/casbin.go @@ -56,6 +56,7 @@ func (c *casbin) Initialize() error { {PType: "p", V0: "888", V1: "/fileUploadAndDownload/findFile", V2: "GET"}, {PType: "p", V0: "888", V1: "/fileUploadAndDownload/breakpointContinueFinish", V2: "POST"}, + {PType: "p", V0: "888", V1: "/fileUploadAndDownload/breakpointContinue", V2: "POST"}, {PType: "p", V0: "888", V1: "/fileUploadAndDownload/removeChunk", V2: "POST"}, {PType: "p", V0: "888", V1: "/fileUploadAndDownload/upload", V2: "POST"}, diff --git a/web/src/api/breakpoint.js b/web/src/api/breakpoint.js index 04d754e8a0936632b5a44fd3139d3f4f5581ad97..eb4b8d1c03feacdc99de0b427106adea1bd3b85f 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/components/chooseImg/index.vue b/web/src/components/chooseImg/index.vue index cf44a7574e0220a4552341077b0ac323a5a53741..cfc50ad37c31937c79523d718baf72dd9ff48673 100644 --- a/web/src/components/chooseImg/index.vue +++ b/web/src/components/chooseImg/index.vue @@ -19,7 +19,7 @@