2025-06-22 16:51:01 +08:00
|
|
|
package gameUser
|
2025-06-22 00:30:14 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"game/common/model/user"
|
|
|
|
"game/common/proto/pb"
|
|
|
|
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
|
|
|
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
|
|
|
|
us "github.com/flipped-aurora/gin-vue-admin/server/service/user"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
2025-06-22 16:51:01 +08:00
|
|
|
type GameUserApi struct{}
|
2025-06-22 00:30:14 +08:00
|
|
|
|
2025-06-22 16:51:01 +08:00
|
|
|
func (e *GameUserApi) GetUserById(c *gin.Context) {
|
2025-06-22 00:30:14 +08:00
|
|
|
var gameUser = &user.GameUser{}
|
|
|
|
err := c.ShouldBindJSON(&gameUser)
|
|
|
|
if err != nil {
|
|
|
|
response.FailWithMessage(err.Error(), c)
|
|
|
|
return
|
|
|
|
}
|
2025-06-22 16:51:01 +08:00
|
|
|
if gameUser.ID < 1 {
|
|
|
|
response.FailWithMessage(fmt.Sprintf("玩家id不能为0"), c)
|
2025-06-22 00:30:14 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
var code pb.ErrCode
|
|
|
|
gameUser, code = us.GetUser(gameUser.ID)
|
|
|
|
if code != pb.ErrCode_OK {
|
|
|
|
global.GVA_LOG.Error("查询失败!", zap.Error(fmt.Errorf(code.String())))
|
|
|
|
response.FailWithMessage("查询失败", c)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
response.OkWithData(gin.H{"user": gameUser}, c)
|
|
|
|
}
|