piexlmax 3 years ago
parent
commit
722ad31be2
  1. 15
      server/api/v1/example/exa_breakpoint_continue.go
  2. 2
      server/service/example/exa_breakpoint_continue.go
  3. 4
      web/src/view/example/breakpoint/breakpoint.vue

15
server/api/v1/example/exa_breakpoint_continue.go

@ -2,6 +2,7 @@ package example
import ( import (
"fmt" "fmt"
"github.com/flipped-aurora/gin-vue-admin/server/model/example"
"io/ioutil" "io/ioutil"
"mime/multipart" "mime/multipart"
"strconv" "strconv"
@ -123,11 +124,17 @@ func (b *FileUploadAndDownloadApi) BreakpointContinueFinish(c *gin.Context) {
// @Success 200 {string} string "{"success":true,"data":{},"msg":"缓存切片删除成功"}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"缓存切片删除成功"}"
// @Router /fileUploadAndDownload/removeChunk [post] // @Router /fileUploadAndDownload/removeChunk [post]
func (u *FileUploadAndDownloadApi) RemoveChunk(c *gin.Context) { 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 { 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 { } else {
response.OkWithMessage("缓存切片删除成功", c) response.OkWithMessage("缓存切片删除成功", c)
} }

2
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 { func (e *FileUploadAndDownloadService) DeleteFileChunk(fileMd5 string, fileName string, filePath string) error {
var chunks []example.ExaFileChunk var chunks []example.ExaFileChunk
var file example.ExaFile 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 { if err != nil {
return err return err
} }

4
web/src/view/example/breakpoint/breakpoint.vue

@ -160,9 +160,11 @@ const upLoadFileSlice = async(item) => {
if (res.code === 0) { if (res.code === 0) {
// //
const params = { const params = {
fileName: file.value.name,
fileMd5: fileMd5.value, fileMd5: fileMd5.value,
filePath: res.data.filePath,
} }
ElMessage.success(上传成功)
ElMessage.success("上传成功")
await removeChunk(params) await removeChunk(params)
} }
} }

Loading…
Cancel
Save