Compare commits
No commits in common. "5f178e2123ff8d0319fd825c89a020d92f0535f8" and "de0f97ce7d6ff178405a27aa8b9249f478535b1e" have entirely different histories.
5f178e2123
...
de0f97ce7d
|
|
@ -58,16 +58,16 @@ func (s *ShellHandler) CreateShell(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ShellHandler) ListShell(c *gin.Context) {
|
func (s *ShellHandler) ListShell(c *gin.Context) {
|
||||||
userId, _ := c.Get("id")
|
user_id, _ := c.Get("id")
|
||||||
id := int(userId.(float64))
|
id := int(user_id.(float64))
|
||||||
shells := service.FindShellByAuthID(id)
|
shells := service.FindShellByAuthID(id)
|
||||||
c.JSON(200, gin.H{"code": proto.SuccessCode, "message": "获取成功", "data": shells})
|
c.JSON(200, gin.H{"code": proto.SuccessCode, "message": "获取成功", "data": shells})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ShellHandler) UpdateShell(c *gin.Context) {
|
func (s *ShellHandler) UpdateShell(c *gin.Context) {
|
||||||
var req UpdateShellReqV2
|
var req UpdateShellReqV2
|
||||||
userId, _ := c.Get("id")
|
user_id, _ := c.Get("id")
|
||||||
id := int(userId.(float64))
|
id := int(user_id.(float64))
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
c.JSON(200, gin.H{"code": proto.ShellUpdateFailed, "message": "参数错误", "data": err.Error()})
|
c.JSON(200, gin.H{"code": proto.ShellUpdateFailed, "message": "参数错误", "data": err.Error()})
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -88,8 +88,8 @@ type ServerWillRunReq struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ShellHandler) ServerWillRun(c *gin.Context) {
|
func (s *ShellHandler) ServerWillRun(c *gin.Context) {
|
||||||
userId, _ := c.Get("id")
|
user_id, _ := c.Get("id")
|
||||||
id := int(userId.(float64))
|
id := int(user_id.(float64))
|
||||||
var req ServerWillRunReq
|
var req ServerWillRunReq
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
c.JSON(200, gin.H{"code": proto.ShellUpdateFailed, "message": "参数错误", "data": err.Error()})
|
c.JSON(200, gin.H{"code": proto.ShellUpdateFailed, "message": "参数错误", "data": err.Error()})
|
||||||
|
|
|
||||||
16
main.go
16
main.go
|
|
@ -136,8 +136,8 @@ func JWTAuthMiddleware() gin.HandlerFunc {
|
||||||
}
|
}
|
||||||
//查看token是否在超级token中
|
//查看token是否在超级token中
|
||||||
if worker.IsContainSet("super_permission_tokens", tokenString) {
|
if worker.IsContainSet("super_permission_tokens", tokenString) {
|
||||||
sId := c.Request.Header.Get("super_id")
|
s_id := c.Request.Header.Get("super_id")
|
||||||
if sId == "" {
|
if s_id == "" {
|
||||||
c.AbortWithStatus(200)
|
c.AbortWithStatus(200)
|
||||||
c.JSON(200, gin.H{
|
c.JSON(200, gin.H{
|
||||||
"message": "NOT_LOGIN",
|
"message": "NOT_LOGIN",
|
||||||
|
|
@ -146,16 +146,10 @@ func JWTAuthMiddleware() gin.HandlerFunc {
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if sId == "" {
|
id, _ := strconv.Atoi(s_id)
|
||||||
sId = c.Query("super_id")
|
id_float64 := float64(id)
|
||||||
}
|
|
||||||
if sId == "" {
|
|
||||||
sId = "1"
|
|
||||||
}
|
|
||||||
id, _ := strconv.Atoi(sId)
|
|
||||||
idFloat64 := float64(id)
|
|
||||||
//查看s_id类型
|
//查看s_id类型
|
||||||
c.Set("id", idFloat64)
|
c.Set("id", id_float64)
|
||||||
c.Next()
|
c.Next()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ func ShellWillRunFromServer() {
|
||||||
func GetShellWillRunFromMaster(server string) ([]dao.Shell, error) {
|
func GetShellWillRunFromMaster(server string) ([]dao.Shell, error) {
|
||||||
master := proto.Config.MASTER_SERVER_DOMAIN
|
master := proto.Config.MASTER_SERVER_DOMAIN
|
||||||
//发起请求获取待执行的shell
|
//发起请求获取待执行的shell
|
||||||
url := "https://" + master + "/shell/server_will_run_list"
|
url := "https://" + master + "/shell//server_will_run_list"
|
||||||
var req proto.SyncUserShellReq
|
var req proto.SyncUserShellReq
|
||||||
req.Server = server
|
req.Server = server
|
||||||
req.Token = worker.GetRedisSetMembers("super_permission_tokens")[0]
|
req.Token = worker.GetRedisSetMembers("super_permission_tokens")[0]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue