From 7581a17a29623dac651e59fe71bc900d24e60264 Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Wed, 5 Mar 2025 20:02:06 +0800 Subject: [PATCH 1/9] =?UTF-8?q?header=E5=8A=A0token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 1 - 1 file changed, 1 deletion(-) diff --git a/main.go b/main.go index c699a85..5f00575 100644 --- a/main.go +++ b/main.go @@ -149,7 +149,6 @@ func JWTAuthMiddleware() gin.HandlerFunc { }) return } - log.Printf("req super_id:%s", sId) id, _ := strconv.Atoi(sId) idFloat64 := float64(id) //查看s_id类型 From 793d306238cf6181974f7ab008c00bc4783bfe81 Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Tue, 11 Mar 2025 14:24:38 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E5=91=BD=E4=BB=A4=E6=B7=BB=E5=8A=A0form?= =?UTF-8?q?=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/shell.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/handler/shell.go b/handler/shell.go index 5be9ba6..2f4531a 100644 --- a/handler/shell.go +++ b/handler/shell.go @@ -10,21 +10,21 @@ type ShellHandler struct { } type CreateShellReq struct { - ShellName string `json:"shell_name"` - ShellContent string `json:"shell_content"` - Server string `json:"server"` + ShellName string `json:"shell_name" form:"shell_name" binding:"required"` + ShellContent string `json:"shell_content" form:"shell_content" binding:"required"` + Server string `json:"server" form:"server" binding:"required"` } type UpdateShellReq struct { - ID uint `json:"id"` - ShellName string `json:"shell_name"` - ShellContent string `json:"shell_content"` - Server string `json:"server"` - Status int `json:"status"` - ShellResult string `json:"shell_result"` + ID uint `json:"id" form:"id" binding:"required"` + ShellName string `json:"shell_name" form:"shell_name"` + ShellContent string `json:"shell_content" form:"shell_content"` + Server string `json:"server" form:"server"` + Status int `json:"status" form:"status"` + ShellResult string `json:"shell_result" form:"shell_result"` } type UpdateShellReqV2 struct { - Shells []UpdateShellReq `json:"shells"` + Shells []UpdateShellReq `json:"shells" form:"shells"` } type UpdateShellResp struct { From 1bed10c5e50d1be60b4a4de0c7796a11363fa9a4 Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Tue, 11 Mar 2025 14:29:26 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E5=91=BD=E4=BB=A4=E6=B7=BB=E5=8A=A0form?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=EF=BC=8C=E4=BF=AE=E6=94=B9=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/shell.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/handler/shell.go b/handler/shell.go index 2f4531a..03cae5e 100644 --- a/handler/shell.go +++ b/handler/shell.go @@ -45,7 +45,7 @@ func (s *ShellHandler) CreateShell(c *gin.Context) { user_id, _ := c.Get("id") uid := int(user_id.(float64)) var req CreateShellReq - if err := c.ShouldBindJSON(&req); err != nil { + if err := c.ShouldBind(&req); err != nil { c.JSON(200, gin.H{"code": proto.ShellCreateFailed, "message": "参数错误", "data": err.Error()}) } else { id := service.CreateShell(req.ShellName, req.ShellContent, req.Server, uid) @@ -68,7 +68,7 @@ func (s *ShellHandler) UpdateShell(c *gin.Context) { var req UpdateShellReqV2 userId, _ := c.Get("id") id := int(userId.(float64)) - if err := c.ShouldBindJSON(&req); err != nil { + if err := c.ShouldBind(&req); err != nil { c.JSON(200, gin.H{"code": proto.ShellUpdateFailed, "message": "参数错误", "data": err.Error()}) } else { var resp []UpdateShellResp @@ -91,7 +91,7 @@ func (s *ShellHandler) ServerWillRun(c *gin.Context) { userId, _ := c.Get("id") id := int(userId.(float64)) var req ServerWillRunReq - if err := c.ShouldBindJSON(&req); err != nil { + if err := c.ShouldBind(&req); err != nil { c.JSON(200, gin.H{"code": proto.ShellUpdateFailed, "message": "参数错误", "data": err.Error()}) } else { willRunShells, err2 := service.FindShellWillRunByServer(req.Server, id) From a164def0cd48f1df856286909143c764a0eedd3f Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Tue, 11 Mar 2025 14:32:39 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dao/shell.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dao/shell.go b/dao/shell.go index 39d78ec..8d1c5bd 100644 --- a/dao/shell.go +++ b/dao/shell.go @@ -50,9 +50,9 @@ func FindShellByID(id, uid uint) []Shell { func FindShellByAuthID(auth_id int) []Shell { var shells []Shell if proto.Config.SERVER_SQL_LOG { - DB.Debug().Exec("select * from shells where auth_id = ? order by created_at desc limit 100", auth_id).Scan(&shells) + DB.Debug().Where("auth_id = ?", auth_id).Order("created_at DESC").Limit(100).Find(&shells) } else { - DB.Exec("select * from shells where auth_id = ? order by created_at desc limit 100", auth_id).Scan(&shells) + DB.Where("auth_id = ?", auth_id).Order("created_at DESC").Limit(100).Find(&shells) } return shells } From ad248777719bef01c4c7528ffe8b19334f63b6a8 Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Tue, 11 Mar 2025 15:14:38 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E5=B0=86=E8=8E=B7=E5=8F=96=E5=BE=85?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/shell.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/handler/shell.go b/handler/shell.go index 03cae5e..4d32a2d 100644 --- a/handler/shell.go +++ b/handler/shell.go @@ -2,6 +2,7 @@ package handler import ( "github.com/gin-gonic/gin" + "log" "videoplayer/proto" "videoplayer/service" ) @@ -94,6 +95,7 @@ func (s *ShellHandler) ServerWillRun(c *gin.Context) { if err := c.ShouldBind(&req); err != nil { c.JSON(200, gin.H{"code": proto.ShellUpdateFailed, "message": "参数错误", "data": err.Error()}) } else { + log.Printf("ServerWillRunReq:%s,id:%d", req.Server, id) willRunShells, err2 := service.FindShellWillRunByServer(req.Server, id) if err2 != nil { c.JSON(200, gin.H{"code": proto.ShellUpdateFailed, "message": "获取失败", "data": err2.Error()}) From 40a119cebb178d78a39737f7a9b0280298d9a41c Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Tue, 11 Mar 2025 15:24:47 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dshell=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E8=8E=B7=E5=8F=96token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/shellService.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/shellService.go b/service/shellService.go index 5e417f1..90a30ed 100644 --- a/service/shellService.go +++ b/service/shellService.go @@ -63,7 +63,7 @@ func ShellWillRunFromServer() { //返回执行结果 url := "https://" + proto.Config.MASTER_SERVER_DOMAIN + "/shell/update" var req proto.SyncUserShellResp - req.Token = worker.GetRedisSetMembers("super_permission_tokens?super_id=1")[0] + req.Token = worker.GetRedisSetMembers("super_permission_tokens")[0] req.Shells = resp resp_data, err := worker.SyncDataFromMasterShellReq3(url, req) if err != nil { From bdc32ec806a378a2ad2349f6fd872c6f430576f6 Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Tue, 11 Mar 2025 15:30:32 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/shell.go | 1 + 1 file changed, 1 insertion(+) diff --git a/handler/shell.go b/handler/shell.go index 4d32a2d..34166ad 100644 --- a/handler/shell.go +++ b/handler/shell.go @@ -73,6 +73,7 @@ func (s *ShellHandler) UpdateShell(c *gin.Context) { c.JSON(200, gin.H{"code": proto.ShellUpdateFailed, "message": "参数错误", "data": err.Error()}) } else { var resp []UpdateShellResp + log.Println("UpdateShellReqData:", req.Shells) for _, v := range req.Shells { if service.UpdateShellByID(v.ID, uint(id), v.ShellName, v.ShellContent, v.Server, v.Status, v.ShellResult) { resp = append(resp, UpdateShellResp{ID: v.ID, Status: v.Status}) From 7672b3a638d7abdc39e0c81a8c60a2f986ee70eb Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Tue, 11 Mar 2025 15:32:44 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/shellService.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/shellService.go b/service/shellService.go index 90a30ed..2a00982 100644 --- a/service/shellService.go +++ b/service/shellService.go @@ -61,7 +61,7 @@ func ShellWillRunFromServer() { return } //返回执行结果 - url := "https://" + proto.Config.MASTER_SERVER_DOMAIN + "/shell/update" + url := "https://" + proto.Config.MASTER_SERVER_DOMAIN + "/shell/update?super_id=1" var req proto.SyncUserShellResp req.Token = worker.GetRedisSetMembers("super_permission_tokens")[0] req.Shells = resp From cc21f69fc0c960076d6df8e7ebdfe43ba5b4f41c Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Tue, 11 Mar 2025 15:35:19 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/shell.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/handler/shell.go b/handler/shell.go index 34166ad..3f39d77 100644 --- a/handler/shell.go +++ b/handler/shell.go @@ -2,7 +2,6 @@ package handler import ( "github.com/gin-gonic/gin" - "log" "videoplayer/proto" "videoplayer/service" ) @@ -73,7 +72,7 @@ func (s *ShellHandler) UpdateShell(c *gin.Context) { c.JSON(200, gin.H{"code": proto.ShellUpdateFailed, "message": "参数错误", "data": err.Error()}) } else { var resp []UpdateShellResp - log.Println("UpdateShellReqData:", req.Shells) + //log.Println("UpdateShellReqData:", req.Shells) for _, v := range req.Shells { if service.UpdateShellByID(v.ID, uint(id), v.ShellName, v.ShellContent, v.Server, v.Status, v.ShellResult) { resp = append(resp, UpdateShellResp{ID: v.ID, Status: v.Status}) @@ -96,7 +95,7 @@ func (s *ShellHandler) ServerWillRun(c *gin.Context) { if err := c.ShouldBind(&req); err != nil { c.JSON(200, gin.H{"code": proto.ShellUpdateFailed, "message": "参数错误", "data": err.Error()}) } else { - log.Printf("ServerWillRunReq:%s,id:%d", req.Server, id) + //log.Printf("ServerWillRunReq:%s,id:%d", req.Server, id) willRunShells, err2 := service.FindShellWillRunByServer(req.Server, id) if err2 != nil { c.JSON(200, gin.H{"code": proto.ShellUpdateFailed, "message": "获取失败", "data": err2.Error()})