52 lines
1017 B
Go
52 lines
1017 B
Go
package friend
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
func (this *apiComp) ListCheck(session comm.IUserSession, req *pb.FriendListReq) (code pb.ErrorCode) {
|
|
return
|
|
}
|
|
|
|
//好友列表
|
|
func (this *apiComp) List(session comm.IUserSession, req *pb.FriendListReq) (code pb.ErrorCode, data proto.Message) {
|
|
var (
|
|
self *pb.DBFriend
|
|
Resp *pb.FriendListResp
|
|
list []*pb.FriendBase
|
|
)
|
|
|
|
defer func() {
|
|
Resp = &pb.FriendListResp{
|
|
List: list,
|
|
}
|
|
err := session.SendMsg(string(this.module.GetType()), FriendSubTypeList, Resp)
|
|
if err != nil {
|
|
code = pb.ErrorCode_SystemError
|
|
return
|
|
}
|
|
}()
|
|
|
|
self = this.module.modelFriend.GetFriend(session.GetUserId())
|
|
if self == nil {
|
|
code = pb.ErrorCode_FriendSelfNoData
|
|
return
|
|
}
|
|
|
|
for _, userId := range self.FriendIds {
|
|
user := this.module.ModuleUser.GetUser(userId)
|
|
if user == nil {
|
|
continue
|
|
}
|
|
list = append(list, &pb.FriendBase{
|
|
UserId: userId,
|
|
NickName: user.Name,
|
|
})
|
|
}
|
|
|
|
return
|
|
}
|