From 9ed6c4661d05162df8b08143a944a900545fe95b Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Wed, 12 Jun 2024 10:28:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E9=83=A8=E5=88=86=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E7=A0=81=E6=9B=B4=E6=96=B0=EF=BC=8C=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E6=8B=A6=E6=88=AA=E9=94=99=E8=AF=AF=E7=8A=B6=E6=80=81=E7=A0=81?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/video.go | 20 ++++++++++---------- main.go | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/handler/video.go b/handler/video.go index 3fe327d..ac51210 100644 --- a/handler/video.go +++ b/handler/video.go @@ -92,12 +92,12 @@ func UpdateVideo(c *gin.Context) { if err := c.ShouldBind(&video_req); err == nil { res := service.UpdateVideo(video_req.VideoPath, video_req.VideoName, video_req.CameraID, video_req.ID, int(user_id.(float64)), video_req.Human, video_req.IsDelete, video_req.CreateTime, video_req.EndTime, video_req.FileSize) if !res { - c.JSON(http.StatusOK, gin.H{"error": "update video failed", "code": 1, "message": "failed"}) + c.JSON(http.StatusOK, gin.H{"error": "update video failed", "code": 17, "message": "failed"}) return } - c.JSON(http.StatusOK, gin.H{"code": 0, "message": "success"}) + c.JSON(http.StatusOK, gin.H{"code": 0, "message": "success", "data": "update success"}) } else { - c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": 1, "message": "failed"}) + c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": 9, "message": "failed"}) } } @@ -139,12 +139,12 @@ func CreateVideo(c *gin.Context) { fmt.Println(video_req) id := service.CreateVideo(video_req.VideoPath, video_req.VideoName, video_req.CameraID, int(user_id.(float64)), video_req.Human, video_req.IsDelete, video_req.CreateTime, video_req.EndTime, video_req.DeleteTime, video_req.FileSize) if id == 0 { - c.JSON(http.StatusOK, gin.H{"error": "create video failed", "code": 1, "message": "failed"}) + c.JSON(http.StatusOK, gin.H{"error": "create video failed", "code": 14, "message": "failed"}) return } c.JSON(http.StatusOK, gin.H{"id": id, "code": 0, "message": "success"}) } else { - c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": 1, "message": "failed"}) + c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": 9, "message": "failed"}) } } @@ -155,7 +155,7 @@ func GetVideoList(c *gin.Context) { videos := service.GetVideoList(int(id.(float64)), gvl_req.StartTime, gvl_req.EndTime) c.JSON(http.StatusOK, gin.H{"data": videos, "code": 0, "message": "success"}) } else { - c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": 1, "message": "failed"}) + c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": 9, "message": "failed"}) } } @@ -165,7 +165,7 @@ func DelayVideo(c *gin.Context) { cnt := 0 if err := c.ShouldBind(&delay_req); err == nil { if delay_req.Day > 30 || delay_req.Day < 1 { - c.JSON(http.StatusOK, gin.H{"code": 1, "data": "延迟天数过大或过小", "message": "failed"}) + c.JSON(http.StatusOK, gin.H{"code": 11, "data": "延迟天数过大或过小", "message": "failed"}) return } if delay_req.Option == "all" { @@ -175,12 +175,12 @@ func DelayVideo(c *gin.Context) { cnt = service.DelayVideo(delay_req.ID, int(id.(float64)), delay_req.Day) } if cnt == 0 { - c.JSON(http.StatusOK, gin.H{"code": 1, "data": "延迟失败影响数据", "message": "failed,cnt:" + strconv.Itoa(cnt)}) + c.JSON(http.StatusOK, gin.H{"code": 17, "data": "延迟失败影响数据", "message": "failed,cnt:" + strconv.Itoa(cnt)}) } else { c.JSON(http.StatusOK, gin.H{"code": 0, "data": "延迟成功,影响记录:" + strconv.Itoa(cnt), "message": "success cnt:" + strconv.Itoa(cnt)}) } } else { - c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": 1, "message": "failed"}) + c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": 9, "message": "failed"}) } } @@ -191,6 +191,6 @@ func DeleteVideo(c *gin.Context) { service.DeleteVideo(video_req.ID, int(id.(float64))) c.JSON(http.StatusOK, gin.H{"code": 0, "message": "success"}) } else { - c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": 1, "message": "failed"}) + c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": 9, "message": "failed"}) } } diff --git a/main.go b/main.go index f73b960..87504a9 100644 --- a/main.go +++ b/main.go @@ -76,7 +76,7 @@ func JWTAuthMiddleware() gin.HandlerFunc { c.JSON(200, gin.H{ "message": "NOT_LOGIN", "error": "server token is empty", - "code": "4", + "code": "3", }) return }