package friend import ( "go_dreamfactory/comm" "go_dreamfactory/pb" ) func (this *ApiComp) List_Check(session comm.IUserSession, req *pb.Friend_List_Req) (chk map[string]interface{}, code comm.ErrorCode) { chk = make(map[string]interface{}) self := &pb.DB_FriendData{UserId: session.GetUserId()} err := this.module.model_friend.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.Friend_List_Req) (code pb.ErrorCode) { var ( self *pb.DB_FriendData rsp *pb.Friend_List_Rsp list []*pb.FriendBase ) defer func() { rsp = &pb.Friend_List_Rsp{ List: list, } err := session.SendMsg(string(this.module.GetType()), Friend_SubType_List, rsp) if err != nil { code = pb.ErrorCode_SystemError return } }() if v, ok := chk["self"]; ok { self = v.(*pb.DB_FriendData) for _, userId := range self.FriendIds { list = append(list, &pb.FriendBase{ UserId: userId, }) } } return }