mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 15:32:26 +08:00
feat:rpc gs增加gm接口
This commit is contained in:
@@ -5,16 +5,19 @@ import (
|
||||
"strconv"
|
||||
|
||||
"hk4e/common/config"
|
||||
"hk4e/gm/rpc_client"
|
||||
"hk4e/pkg/logger"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type Controller struct {
|
||||
rpc *rpc_client.Client
|
||||
}
|
||||
|
||||
func NewController() (r *Controller) {
|
||||
func NewController(rpc *rpc_client.Client) (r *Controller) {
|
||||
r = new(Controller)
|
||||
r.rpc = rpc
|
||||
go r.registerRouter()
|
||||
return r
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"hk4e/gs/api"
|
||||
"hk4e/pkg/logger"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -17,5 +20,14 @@ func (c *Controller) gmCmd(context *gin.Context) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
rep, err := c.rpc.Cmd(context.Request.Context(), &api.CmdRequest{
|
||||
FuncName: gmCmdReq.FuncName,
|
||||
Param: gmCmdReq.Param,
|
||||
})
|
||||
if err != nil {
|
||||
context.JSON(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
context.JSON(http.StatusOK, rep)
|
||||
logger.LOG.Info("%v", gmCmdReq)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user