package friend import ( "go_dreamfactory/comm" "go_dreamfactory/pb" ) func (this *apiComp) ListCheck(session comm.IUserSession, req *pb.FriendListReq) (chk map[string]interface{}, code comm.ErrorCode) { chk = make(map[string]interface{}) self := &pb.DBFriend{UId: session.GetUserId()} err := this.module.modelFriend.Get(session.GetUserId(), self) if self == nil || err != nil { code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData} return } chk["self"] = self return } //好友列表 func (this *apiComp) List(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendListReq) (code pb.ErrorCode) { var ( self *pb.DBFriend rsp *pb.FriendListRsp list []*pb.FriendBase ) defer func() { rsp = &pb.FriendListRsp{ List: list, } err := session.SendMsg(string(this.module.GetType()), FriendSubTypeList, rsp) if err != nil { code = pb.ErrorCode_SystemError return } }() if v, ok := chk["self"]; ok { self = v.(*pb.DBFriend) for _, userId := range self.FriendIds { list = append(list, &pb.FriendBase{ UserId: userId, }) } } return }