package logic import ( quitl "app.yhyue.com/moapp/jybase/common" "app.yhyue.com/moapp/jybase/encrypt" "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/util" "bp.jydev.jianyu360.cn/SocialPlatform/socialPlatform/entity" "bp.jydev.jianyu360.cn/SocialPlatform/socialPlatform/rpc/social/social" "context" "net/http" "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/svc" "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/types" "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter" "github.com/zeromicro/go-zero/core/logx" ) type FindMessageLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext r *http.Request } func NewFindMessageLogic(ctx context.Context, svcCtx *svc.ServiceContext, r *http.Request) *FindMessageLogic { return &FindMessageLogic{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx, r: r, } } func (l *FindMessageLogic) FindMessage(req *types.MessageReq) (resp *types.CommonRes, err error) { resp = &types.CommonRes{} if req.NewUserId == 0 { sessionId, trustedId, stErr := util.GetTouristCookieInfo(l.r) if stErr != nil { resp.Error_code = 1 resp.Error_msg = stErr.Error() return resp, nil } result, rErr := l.svcCtx.Social.TouristInfo(l.ctx, &social.TouristInfoReq{ SessionId: sessionId, Ip: entity.GetIp(l.r), TrustedId: trustedId, }) if rErr != nil || req.NewUserId == 0 { resp.Error_code = 1 resp.Error_msg = "当用户信息有误" logx.Error("获取当前游客信息有误:", rErr.Error()) return resp, rErr } req.NewUserId = result.Data.BaseUserId } var res *messagecenter.MessageResp res, err = l.svcCtx.Message.FindMessage(l.ctx, &messagecenter.MessageReq{ UserType: req.UserType, MsgType: req.MsgType, SendId: quitl.Int64All(encrypt.SE.Decode4Hex(req.SendId)), LastId: quitl.Int64All(encrypt.SE.Decode4Hex(req.LastId)), EntId: req.EntId, PageSize: req.PageSize, EntUserId: req.EntUserId, NewUserId: req.NewUserId, Sort: req.Sort, ChatGroupId: quitl.Int64All(encrypt.SE.Decode4Hex(req.ChatGroupId)), PositionId: req.PositionId, }) if err != nil { return nil, err } resp = &types.CommonRes{ Error_msg: res.ErrorMsg, Error_code: int(res.ErrorCode), Data: res.Data, Count: res.Count, } return resp, nil }