修复老版本客户端dispatch问题

This commit is contained in:
flswld committed 2023-07-16 19:39:39 +08:00
1 parent 6b41772ebe
commit acb6a55781
12 files changed
+443 -404

No files matched your search

+26 -26
View File
@@ -9,14 +9,14 @@ import (
"github.com/gin-gonic/gin"
)
func (c *Controller) serverStopState(context *gin.Context) {
stopServerInfo, err := c.discoveryClient.GetStopServerInfo(context.Request.Context(), &api.GetStopServerInfoReq{ClientIpAddr: ""})
func (c *Controller) serverStopState(ctx *gin.Context) {
stopServerInfo, err := c.discoveryClient.GetStopServerInfo(ctx.Request.Context(), &api.GetStopServerInfoReq{ClientIpAddr: ""})
if err != nil {
logger.Error("get stop server info error: %v", err)
context.JSON(http.StatusOK, &CommonRsp{Code: -1, Msg: "", Data: err})
ctx.JSON(http.StatusOK, &CommonRsp{Code: -1, Msg: "", Data: err})
return
}
context.JSON(http.StatusOK, &CommonRsp{Code: 0, Msg: "", Data: stopServerInfo})
ctx.JSON(http.StatusOK, &CommonRsp{Code: 0, Msg: "", Data: stopServerInfo})
}
type ServerStopChangeReq struct {
@@ -25,78 +25,78 @@ type ServerStopChangeReq struct {
EndTime uint32 `json:"end_time"`
}
func (c *Controller) serverStopChange(context *gin.Context) {
func (c *Controller) serverStopChange(ctx *gin.Context) {
req := new(ServerStopChangeReq)
err := context.ShouldBindJSON(req)
err := ctx.ShouldBindJSON(req)
if err != nil {
context.JSON(http.StatusOK, &CommonRsp{Code: -1, Msg: "", Data: err})
ctx.JSON(http.StatusOK, &CommonRsp{Code: -1, Msg: "", Data: err})
return
}
_, err = c.discoveryClient.SetStopServerInfo(context.Request.Context(), &api.StopServerInfo{
_, err = c.discoveryClient.SetStopServerInfo(ctx.Request.Context(), &api.StopServerInfo{
StopServer: req.StopServer,
StartTime: req.StartTime,
EndTime: req.EndTime,
})
if err != nil {
logger.Error("set stop server info error: %v", err)
context.JSON(http.StatusOK, &CommonRsp{Code: -1, Msg: "", Data: err})
ctx.JSON(http.StatusOK, &CommonRsp{Code: -1, Msg: "", Data: err})
return
}
context.JSON(http.StatusOK, &CommonRsp{Code: 0, Msg: "", Data: nil})
ctx.JSON(http.StatusOK, &CommonRsp{Code: 0, Msg: "", Data: nil})
}
func (c *Controller) serverWhiteList(context *gin.Context) {
whiteList, err := c.discoveryClient.GetWhiteList(context.Request.Context(), &api.NullMsg{})
func (c *Controller) serverWhiteList(ctx *gin.Context) {
whiteList, err := c.discoveryClient.GetWhiteList(ctx.Request.Context(), &api.NullMsg{})
if err != nil {
logger.Error("get white list error: %v", err)
context.JSON(http.StatusOK, &CommonRsp{Code: -1, Msg: "", Data: err})
ctx.JSON(http.StatusOK, &CommonRsp{Code: -1, Msg: "", Data: err})
return
}
context.JSON(http.StatusOK, &CommonRsp{Code: 0, Msg: "", Data: whiteList.IpAddrList})
ctx.JSON(http.StatusOK, &CommonRsp{Code: 0, Msg: "", Data: whiteList.IpAddrList})
}
type ServerWhiteAdd struct {
IpAddr string `json:"ip_addr"`
}
func (c *Controller) serverWhiteAdd(context *gin.Context) {
func (c *Controller) serverWhiteAdd(ctx *gin.Context) {
req := new(ServerWhiteAdd)
err := context.ShouldBindJSON(req)
err := ctx.ShouldBindJSON(req)
if err != nil {
context.JSON(http.StatusOK, &CommonRsp{Code: -1, Msg: "", Data: err})
ctx.JSON(http.StatusOK, &CommonRsp{Code: -1, Msg: "", Data: err})
return
}
_, err = c.discoveryClient.SetWhiteList(context.Request.Context(), &api.SetWhiteListReq{
_, err = c.discoveryClient.SetWhiteList(ctx.Request.Context(), &api.SetWhiteListReq{
IsAdd: true,
IpAddr: req.IpAddr,
})
if err != nil {
logger.Error("set white list error: %v", err)
context.JSON(http.StatusOK, &CommonRsp{Code: -1, Msg: "", Data: err})
ctx.JSON(http.StatusOK, &CommonRsp{Code: -1, Msg: "", Data: err})
return
}
context.JSON(http.StatusOK, &CommonRsp{Code: 0, Msg: "", Data: nil})
ctx.JSON(http.StatusOK, &CommonRsp{Code: 0, Msg: "", Data: nil})
}
type ServerWhiteDel struct {
IpAddr string `json:"ip_addr"`
}
func (c *Controller) serverWhiteDel(context *gin.Context) {
func (c *Controller) serverWhiteDel(ctx *gin.Context) {
req := new(ServerWhiteDel)
err := context.ShouldBindJSON(req)
err := ctx.ShouldBindJSON(req)
if err != nil {
context.JSON(http.StatusOK, &CommonRsp{Code: -1, Msg: "", Data: err})
ctx.JSON(http.StatusOK, &CommonRsp{Code: -1, Msg: "", Data: err})
return
}
_, err = c.discoveryClient.SetWhiteList(context.Request.Context(), &api.SetWhiteListReq{
_, err = c.discoveryClient.SetWhiteList(ctx.Request.Context(), &api.SetWhiteListReq{
IsAdd: false,
IpAddr: req.IpAddr,
})
if err != nil {
logger.Error("set white list error: %v", err)
context.JSON(http.StatusOK, &CommonRsp{Code: -1, Msg: "", Data: err})
ctx.JSON(http.StatusOK, &CommonRsp{Code: -1, Msg: "", Data: err})
return
}
context.JSON(http.StatusOK, &CommonRsp{Code: 0, Msg: "", Data: nil})
ctx.JSON(http.StatusOK, &CommonRsp{Code: 0, Msg: "", Data: nil})
}