Compare commits
No commits in common. "f7b1c935f42375e80ba2581f8971068461b6dc67" and "75fdf7c1d8677e3e69bf9d2a62845fbced44237b" have entirely different histories.
f7b1c935f4
...
75fdf7c1d8
16
dao/file.go
16
dao/file.go
|
|
@ -53,22 +53,6 @@ func UpdateFileByID(id, auth_id int, fileStoreName, fileName, fileType, filePath
|
|||
if pd.ID == 0 {
|
||||
return false
|
||||
}
|
||||
if fileStoreName == "" {
|
||||
fileStoreName = pd.FileStoreName
|
||||
}
|
||||
if fileName == "" {
|
||||
fileName = pd.FileName
|
||||
}
|
||||
if fileType == "" {
|
||||
fileType = pd.FileType
|
||||
}
|
||||
if filePath == "" {
|
||||
filePath = pd.FilePath
|
||||
}
|
||||
if fileSize == 0 {
|
||||
fileSize = pd.FileSize
|
||||
}
|
||||
|
||||
result := DB.Debug().Model(&File{}).Where("id = ? and auth_id = ?", id, auth_id).Updates(File{FileStoreName: fileStoreName, FileName: fileName, FileType: fileType, FilePath: filePath, FileSize: fileSize})
|
||||
if result.Error != nil {
|
||||
return false
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import (
|
|||
"videoplayer/dao"
|
||||
"videoplayer/proto"
|
||||
"videoplayer/service"
|
||||
"videoplayer/worker"
|
||||
)
|
||||
|
||||
type SetRedisReq struct {
|
||||
|
|
@ -20,14 +19,6 @@ type SetRedisReq struct {
|
|||
Expire int `json:"expire" form:"expire"`
|
||||
}
|
||||
|
||||
type SetFileReq struct {
|
||||
ID int `json:"id" form:"id"`
|
||||
FileStoreName string `json:"file_store_name" form:"file_store_name"`
|
||||
FileName string `json:"file_name" form:"file_name"`
|
||||
FileSize int `json:"file_size" form:"file_size"`
|
||||
FileType string `json:"file_type" form:"file_type"`
|
||||
}
|
||||
|
||||
func SetUpToolGroup(router *gin.Engine) {
|
||||
toolGroup := router.Group("/tool")
|
||||
toolGroup.POST("/set_redis", SetRedis)
|
||||
|
|
@ -38,40 +29,6 @@ func SetUpToolGroup(router *gin.Engine) {
|
|||
toolGroup.GET("/download", DownloadFile)
|
||||
//文件管理
|
||||
toolGroup.POST("/file_del", DelFile)
|
||||
toolGroup.POST("/file_status", FileStatus)
|
||||
toolGroup.POST("/file_set", SetFile)
|
||||
}
|
||||
|
||||
func SetFile(c *gin.Context) {
|
||||
id, _ := c.Get("id")
|
||||
id1 := int(id.(float64))
|
||||
|
||||
var req SetFileReq
|
||||
if err := c.ShouldBind(&req); err == nil {
|
||||
//先查看是否有权限
|
||||
dao.UpdateFileByID(req.ID, id1, req.FileStoreName, req.FileName, req.FileType, "", req.FileSize)
|
||||
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{"error": "parameter error", "code": proto.ParameterError, "message": "failed"})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func FileStatus(c *gin.Context) {
|
||||
//先查看是否有权限
|
||||
id, _ := c.Get("id")
|
||||
id1 := int(id.(float64))
|
||||
|
||||
file_id, _ := strconv.Atoi(c.PostForm("id"))
|
||||
|
||||
file_ := dao.FindFileByID(file_id, id1)
|
||||
if file_.ID == 0 {
|
||||
c.JSON(http.StatusOK, gin.H{"error": "file not found", "code": proto.FileNotFound, "message": "failed"})
|
||||
return
|
||||
}
|
||||
res := worker.GetRedis(file_.FileStoreName)
|
||||
//查看文件信息
|
||||
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "message": "success", "data": file_, "status": res})
|
||||
}
|
||||
|
||||
func DelFile(c *gin.Context) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue