package logic import ( "app.yhyue.com/moapp/MessageCenter/service" "app.yhyue.com/moapp/MessageCenter/util" "context" "app.yhyue.com/moapp/MessageCenter/rpc/internal/svc" "app.yhyue.com/moapp/MessageCenter/rpc/type/message" "github.com/zeromicro/go-zero/core/logx" ) type UserMsgListLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewUserMsgListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserMsgListLogic { return &UserMsgListLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } // new用户消息列表 func (l *UserMsgListLogic) UserMsgList(in *message.UserMsgListReq) (*message.UserMsgListRes, error) { // todo: add your logic here and delete this line data := new(message.UserMsgListRes) res1 := service.UserMsgList(in) //具体信息 res2 := service.MessageGetLast(in) //最新信息 if res2 != nil || res1.Data != nil { var finalData []*message.Messages if res1.Data != nil { for _, v := range res1.Data { link3, androidUrl3, iosUrl3, weChatUrl3 := util.LinkSplit(v.Link) v.Link = link3 v.Url = map[string]string{ "androidUrl": androidUrl3, "iosUrl": iosUrl3, "weChatUrl": weChatUrl3, } finalData = append(finalData, v) } } lastMsg := new(message.Messages) if res2 != nil { lastMsg = res2 links4 := lastMsg.Link link4, androidUrl4, iosUrl4, weChatUrl4 := util.LinkSplit(links4) lastMsg.Link = link4 lastMsg.Url = map[string]string{ "androidUrl": androidUrl4, "iosUrl": iosUrl4, "weChatUrl": weChatUrl4, } } data.Column = res1.SortData data.List = finalData data.Last = lastMsg data.Count = res1.Count } return data, nil }