From 2034cfd7844841220a1a9a1d2f0a8026b0f113dc Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Fri, 30 Aug 2024 22:42:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=9F=A5=E7=9C=8B=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/tool.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/handler/tool.go b/handler/tool.go index 8cce9f6..8a10732 100644 --- a/handler/tool.go +++ b/handler/tool.go @@ -10,6 +10,7 @@ import ( "videoplayer/dao" "videoplayer/proto" "videoplayer/service" + "videoplayer/worker" ) type SetRedisReq struct { @@ -29,6 +30,24 @@ func SetUpToolGroup(router *gin.Engine) { toolGroup.GET("/download", DownloadFile) //文件管理 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) {