package logic import ( "context" "encoding/json" "slow_wild_api/apps/internal/constants" "slow_wild_api/apps/internal/svc" "slow_wild_api/apps/internal/types" "git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver" "github.com/spf13/cast" "github.com/zeromicro/go-zero/core/logx" ) type GetUserProfileLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext } // 获取用户信息 func NewGetUserProfileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserProfileLogic { return &GetUserProfileLogic{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx, } } func (l *GetUserProfileLogic) GetUserProfile(req *types.GetUserProfileReq) (resp *types.BaseReturnData, err error) { resp = &types.BaseReturnData{} userId := l.ctx.Value(constants.UserIdKey).(json.Number) rpcResp, err := l.svcCtx.SlowWildPb.GetUserProfile(l.ctx, &slowwildserver.GetUserProfileReq{ UserId: cast.ToInt64(userId), }) if err != nil { return nil, err } resp.Data = rpcResp return }