Merge branch 'refs/heads/feat-file' into master-pg

This commit is contained in:
junleea 2024-08-30 22:42:27 +08:00
commit 08f1d5cd5b
1 changed files with 19 additions and 0 deletions

View File

@ -10,6 +10,7 @@ import (
"videoplayer/dao" "videoplayer/dao"
"videoplayer/proto" "videoplayer/proto"
"videoplayer/service" "videoplayer/service"
"videoplayer/worker"
) )
type SetRedisReq struct { type SetRedisReq struct {
@ -29,6 +30,24 @@ func SetUpToolGroup(router *gin.Engine) {
toolGroup.GET("/download", DownloadFile) toolGroup.GET("/download", DownloadFile)
//文件管理 //文件管理
toolGroup.POST("/file_del", DelFile) toolGroup.POST("/file_del", DelFile)
toolGroup.POST("/file_status", FileStatus)
}
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) { func DelFile(c *gin.Context) {