go_dreamfactory/modules/friend/api_list.go
2022-06-15 17:36:09 +08:00

41 lines
779 B
Go

package friend
import (
"context"
"go_dreamfactory/comm"
"go_dreamfactory/pb"
)
//好友列表
func (this *ApiComp) List(ctx context.Context, session comm.IUserSession, req *pb.FriendListReq) (err error) {
var (
code pb.ErrorCode
self *pb.DB_FriendData
rsp *pb.FriendListRsp
list []*pb.FriendBase
)
defer func() {
if code == pb.ErrorCode_Success {
rsp = &pb.FriendListRsp{
List: list,
}
}
session.SendMsg(string(this.module.GetType()), Friend_SubType_List, code, rsp)
}()
err = this.module.model_friend.GetObj(session.GetUserId(), self)
if self == nil || err != nil {
code = pb.ErrorCode_FriendSelfNoData
return
}
for _, userId := range self.FriendIds {
list = append(list, &pb.FriendBase{
UserId: userId,
})
}
return nil
}