39 lines
990 B
Go
Raw Normal View History

2025-06-22 00:30:14 +08:00
package user
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/flipped-aurora/gin-vue-admin/server/utils"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
type UserApi struct{}
func (e *UserApi) GetUserById(c *gin.Context) {
var gameUser = &user.GameUser{}
err := c.ShouldBindJSON(&gameUser)
if err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err = utils.Verify(gameUser, utils.IdVerify)
if err != nil {
response.FailWithMessage(err.Error(), c)
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)
}