73 lines
1.5 KiB
Go
73 lines
1.5 KiB
Go
package friend
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/utils"
|
|
|
|
"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.moduleFriend.GetType()), FriendSubTypeList, Resp)
|
|
if err != nil {
|
|
code = pb.ErrorCode_SystemError
|
|
return
|
|
}
|
|
}()
|
|
|
|
self = this.moduleFriend.modelFriend.GetFriend(session.GetUserId())
|
|
if self == nil {
|
|
code = pb.ErrorCode_FriendSelfNoData
|
|
return
|
|
}
|
|
|
|
// 我的好友
|
|
for _, userId := range self.FriendIds {
|
|
// 获取好友详情
|
|
base := this.setDefaultFriendUserBaseInfo(userId)
|
|
if base == nil {
|
|
continue
|
|
}
|
|
|
|
// 判断用户在线状态
|
|
us := this.moduleFriend.ModuleUser.GetUserSession(userId)
|
|
if us != nil {
|
|
base.OfflineTime = 0 //在线
|
|
}
|
|
|
|
// 判断是否已点赞
|
|
target := this.moduleFriend.modelFriend.GetFriend(userId)
|
|
if target == nil {
|
|
continue
|
|
}
|
|
if _, ok := utils.Findx(target.ZanIds, self.Uid); ok {
|
|
base.IsZaned = true
|
|
}
|
|
|
|
//判断是否已接收获赞
|
|
if _, ok := utils.Findx(self.ZanIds, userId); ok {
|
|
base.IsGetZaned = true
|
|
}
|
|
|
|
list = append(list, base)
|
|
}
|
|
|
|
return
|
|
}
|