42 lines
803 B
Go
42 lines
803 B
Go
package friend
|
|
|
|
import (
|
|
"context"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/sys/cache"
|
|
)
|
|
|
|
//好友列表
|
|
func (this *ApiComp) List(ctx context.Context, session comm.IUserSession, req *pb.FriendListReq) (err error) {
|
|
var (
|
|
code pb.ErrorCode
|
|
self *pb.Cache_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)
|
|
}()
|
|
|
|
self, err = cache.Defsys.Friend_Get(session.GetUserId())
|
|
if self == nil || err != nil {
|
|
code = pb.ErrorCode_FriendSelfNoData
|
|
return
|
|
}
|
|
|
|
for _, userId := range self.FriendIds {
|
|
list = append(list, &pb.FriendBase{
|
|
UserId: userId,
|
|
})
|
|
}
|
|
|
|
return nil
|
|
}
|