Compare commits
No commits in common. "45fa575f196df7dc256dffde43dc8257e41309fd" and "a5b40c08724205712c8405b1c7c753d065627450" have entirely different histories.
45fa575f19
...
a5b40c0872
|
|
@ -3,7 +3,6 @@ package handler
|
||||||
import (
|
import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
"videoplayer/dao"
|
"videoplayer/dao"
|
||||||
"videoplayer/proto"
|
"videoplayer/proto"
|
||||||
"videoplayer/service"
|
"videoplayer/service"
|
||||||
|
|
@ -23,7 +22,7 @@ func SetUpToolGroup(router *gin.Engine) {
|
||||||
|
|
||||||
//文件上传、下载
|
//文件上传、下载
|
||||||
toolGroup.POST("/upload", UploadFile)
|
toolGroup.POST("/upload", UploadFile)
|
||||||
toolGroup.GET("/download", DownloadFile)
|
toolGroup.GET("/download/:filename", DownloadFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
func UploadFile(c *gin.Context) {
|
func UploadFile(c *gin.Context) {
|
||||||
|
|
@ -64,18 +63,16 @@ func UploadFile(c *gin.Context) {
|
||||||
c.JSON(http.StatusOK, gin.H{"error": "save file info failed", "code": proto.SaveFileInfoFailed, "message": "failed"})
|
c.JSON(http.StatusOK, gin.H{"error": "save file info failed", "code": proto.SaveFileInfoFailed, "message": "failed"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "message": "success"})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func DownloadFile(c *gin.Context) {
|
func DownloadFile(c *gin.Context) {
|
||||||
//参数
|
//参数
|
||||||
//filename := c.Param("filename")
|
filename := c.Param("filename")
|
||||||
file_id, _ := strconv.Atoi(c.Query("id"))
|
//file_id, _ := strconv.Atoi(c.Query("id"))
|
||||||
id, _ := c.Get("id")
|
id, _ := c.Get("id")
|
||||||
//查询文件信息
|
//查询文件信息
|
||||||
//file := dao.FindFileByNames(file_id, int(id.(float64)))
|
file := dao.FindFileByNames(filename, int(id.(float64)))
|
||||||
file := dao.FindFileByID(file_id, int(id.(float64)))
|
|
||||||
if file.ID == 0 {
|
if file.ID == 0 {
|
||||||
c.JSON(http.StatusOK, gin.H{"error": "file not found", "code": proto.FileNotFound, "message": "failed"})
|
c.JSON(http.StatusOK, gin.H{"error": "file not found", "code": proto.FileNotFound, "message": "failed"})
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue