diff --git a/modules/friend/api_cross_addblack.go b/modules/friend/api_cross_addblack.go index f05e1ab75..89d519fb7 100644 --- a/modules/friend/api_cross_addblack.go +++ b/modules/friend/api_cross_addblack.go @@ -112,6 +112,19 @@ func (this *apiComp) Addblack(session comm.IUserSession, req *pb.FriendAddBlackR return } + target.Beblackids = append(target.Beblackids, session.GetUserId()) + //更新 + err = this.module.modelFriend.Change(target.Uid, map[string]interface{}{ + "beblackids": self.Beblackids, + }) + if err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_DBError, + Title: pb.ErrorCode_DBError.ToString(), + Message: err.Error(), + } + return + } Resp = &pb.FriendAddBlackResp{ FriendId: req.FriendId, UserId: session.GetUserId(), diff --git a/modules/friend/api_cross_delblack.go b/modules/friend/api_cross_delblack.go index bdc025ebd..2dab9572a 100644 --- a/modules/friend/api_cross_delblack.go +++ b/modules/friend/api_cross_delblack.go @@ -24,8 +24,9 @@ func (this *apiComp) Delblack(session comm.IUserSession, req *pb.FriendDelBlackR return } var ( - err error - self *pb.DBFriend + err error + self *pb.DBFriend + target *pb.DBFriend ) uid := session.GetUserId() self, err = this.module.modelFriend.GetFriend(session.GetUserId()) @@ -36,7 +37,14 @@ func (this *apiComp) Delblack(session comm.IUserSession, req *pb.FriendDelBlackR } return } - + target, err = this.module.modelFriend.GetFriend(req.FriendId) + if err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_FriendTargetNoData, + Title: pb.ErrorCode_FriendTargetNoData.ToString(), + } + return + } //从黑名单列表中删除目标 self.BlackIds = utils.DeleteString(self.BlackIds, req.FriendId) //更新黑名单 @@ -54,7 +62,17 @@ func (this *apiComp) Delblack(session comm.IUserSession, req *pb.FriendDelBlackR ) return } - + target.Beblackids = utils.DeleteString(target.Beblackids, session.GetUserId()) + if err = this.module.modelFriend.Change(target.Uid, map[string]interface{}{ + "beblackids": target.Beblackids, + }); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_DBError, + Title: pb.ErrorCode_DBError.ToString(), + Message: err.Error(), + } + return + } resp := &pb.FriendDelBlackResp{ FriendId: req.FriendId, UserId: session.GetUserId(), diff --git a/pb/friend_db.pb.go b/pb/friend_db.pb.go index ca971dbc9..b888f32e0 100644 --- a/pb/friend_db.pb.go +++ b/pb/friend_db.pb.go @@ -42,6 +42,7 @@ type DBFriend struct { Weapplyids []string `protobuf:"bytes,15,rep,name=weapplyids,proto3" json:"weapplyids" bson:"weapplyids"` //我申请的用户ID CleanTime int64 `protobuf:"varint,16,opt,name=cleanTime,proto3" json:"cleanTime" bson:"cleanTime"` //清理申请列表时间 RefreshNum int32 `protobuf:"varint,17,opt,name=refreshNum,proto3" json:"refreshNum" bson:"refreshNum"` // 每日刷新次数 + Beblackids []string `protobuf:"bytes,18,rep,name=beblackids,proto3" json:"beblackids"` //被黑名单 } func (x *DBFriend) Reset() { @@ -195,6 +196,13 @@ func (x *DBFriend) GetRefreshNum() int32 { return 0 } +func (x *DBFriend) GetBeblackids() []string { + if x != nil { + return x.Beblackids + } + return nil +} + //助战记录 type AssistRecord struct { state protoimpl.MessageState @@ -408,7 +416,7 @@ var file_friend_friend_db_proto_rawDesc = []byte{ 0x0a, 0x16, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x2f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x68, 0x65, 0x72, 0x6f, 0x2f, 0x68, 0x65, 0x72, 0x6f, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0a, 0x63, 0x6f, - 0x6d, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x81, 0x04, 0x0a, 0x08, 0x44, 0x42, 0x46, + 0x6d, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa1, 0x04, 0x0a, 0x08, 0x44, 0x42, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x21, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, @@ -440,7 +448,9 @@ var file_friend_friend_db_proto_rawDesc = []byte{ 0x0a, 0x09, 0x63, 0x6c, 0x65, 0x61, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x10, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x6c, 0x65, 0x61, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x4e, 0x75, 0x6d, 0x18, 0x11, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x0a, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x4e, 0x75, 0x6d, 0x22, 0x64, 0x0a, 0x0c, + 0x52, 0x0a, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x4e, 0x75, 0x6d, 0x12, 0x1e, 0x0a, 0x0a, + 0x62, 0x65, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x69, 0x64, 0x73, 0x18, 0x12, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x0a, 0x62, 0x65, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x69, 0x64, 0x73, 0x22, 0x64, 0x0a, 0x0c, 0x41, 0x73, 0x73, 0x69, 0x73, 0x74, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x73, 0x73, 0x69, 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01,