mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 15:52:27 +08:00
34 lines
634 B
Go
34 lines
634 B
Go
package controller
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"hk4e/gs/api"
|
|
"hk4e/pkg/logger"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type GmCmdReq struct {
|
|
FuncName string `json:"func_name"`
|
|
Param []string `json:"param"`
|
|
}
|
|
|
|
func (c *Controller) gmCmd(context *gin.Context) {
|
|
gmCmdReq := new(GmCmdReq)
|
|
err := context.ShouldBindJSON(gmCmdReq)
|
|
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)
|
|
}
|