12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- package user
- import (
- "context"
- "encoding/json"
- "fmt"
- "microGame/app/usercenter/cmd/rpc/pb/usercenter"
- "microGame/pkg/ctxdata"
- "microGame/app/usercenter/cmd/api/internal/svc"
- "microGame/app/usercenter/cmd/api/internal/types"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type DetailLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- // NewDetailLogic get user info
- func NewDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DetailLogic {
- return &DetailLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
- func (l *DetailLogic) Detail(req *types.UserInfoReq) (resp *types.UserInfoResp, err error) {
- userId := ctxdata.GetUidFromCtx(l.ctx)
- detailResp, err := l.svcCtx.UserRpc.GetUserInfo(l.ctx, &usercenter.UserInfoReq{
- UserId: userId,
- })
- if err != nil {
- return nil, err
- }
- //value := l.ctx.Value("jwtUserId")
- //logc.Info(l.ctx, value)
- //str := fmt.Sprintf("%s", userId)
- msg, _ := json.Marshal(detailResp)
- if err := l.svcCtx.KqPusherClient.Push(l.ctx, string(msg)); err != nil {
- logx.Errorf("KqPusherClient Push Error , err :%+v\n", err)
- }
- fmt.Printf("KqPusherClient Push connect req , err :%+v\n", err)
- resp = &types.UserInfoResp{
- Uid: detailResp.Uid,
- Username: detailResp.Username,
- }
- return
- }
|