47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package friend
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/sys/log"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/utils"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
func (this *apiComp) DelCheck(session comm.IUserSession, req *pb.FriendDelReq) (code pb.ErrorCode) {
|
|
if req.FriendId == "" {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
}
|
|
return
|
|
}
|
|
|
|
//删除好友
|
|
func (this *apiComp) Del(session comm.IUserSession, req *pb.FriendDelReq) (code pb.ErrorCode, data proto.Message) {
|
|
if code = this.DelCheck(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
|
|
self := this.moduleFriend.modelFriend.GetFriend(session.GetUserId())
|
|
if self == nil {
|
|
code = pb.ErrorCode_FriendSelfNoData
|
|
return
|
|
}
|
|
|
|
friendIds := utils.DeleteString(self.FriendIds, req.FriendId)
|
|
|
|
if err := this.moduleFriend.modelFriend.Change(self.Uid, map[string]interface{}{
|
|
"friendIds": friendIds,
|
|
}); err != nil {
|
|
log.Errorf("Del friend err:%v", err)
|
|
code = pb.ErrorCode_FriendApplyError
|
|
return
|
|
}
|
|
|
|
if err := session.SendMsg(string(this.moduleFriend.GetType()), FriendSubTypeDel, &pb.FriendDelResp{FriendId: req.FriendId, UserId: self.Uid}); err != nil {
|
|
code = pb.ErrorCode_SystemError
|
|
}
|
|
|
|
return
|
|
}
|