完善重连流程

This commit is contained in:
flswld
2023-02-05 08:44:07 +08:00
parent 053990a33c
commit 3f0b57721f
4 changed files with 80 additions and 9 deletions

View File

@@ -139,6 +139,7 @@ func (c *Controller) registerRouter() {
}
engine.Use(c.authorize())
engine.POST("/gate/token/verify", c.gateTokenVerify)
engine.POST("/gate/token/reset", c.gateTokenReset)
port := config.CONF.HttpPort
addr := ":" + strconv.Itoa(int(port))
err := engine.Run(addr)

View File

@@ -67,3 +67,32 @@ func (c *Controller) gateTokenVerify(context *gin.Context) {
PlayerID: uint32(account.PlayerID),
})
}
type TokenResetReq struct {
PlayerId uint32 `json:"playerId"`
}
type TokenResetRsp struct {
Result bool `json:"result"`
}
func (c *Controller) gateTokenReset(context *gin.Context) {
req := new(TokenResetReq)
err := context.ShouldBindJSON(req)
if err != nil {
context.JSON(http.StatusOK, &TokenResetRsp{
Result: false,
})
return
}
_, err = c.dao.UpdateAccountFieldByFieldName("PlayerID", req.PlayerId, "comboTokenUsed", false)
if err != nil {
context.JSON(http.StatusOK, &TokenResetRsp{
Result: false,
})
return
}
context.JSON(http.StatusOK, &TokenResetRsp{
Result: true,
})
}