1
This commit is contained in:
parent
ed4769cfd6
commit
3e90315b75
@ -41,7 +41,9 @@ CREATE TABLE `t_friend_relationship` (
|
||||
`idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`account_id1` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT '账号1',
|
||||
`account_id2` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT '账号2',
|
||||
`add_time` int(11) NOT NULL DEFAULT '0' COMMENT '成为好友时间',
|
||||
`deleted` int(11) NOT NULL DEFAULT '0' COMMENT '是否已删除',
|
||||
`del_time` int(11) NOT NULL DEFAULT '0' COMMENT '删除时间',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
|
@ -8,15 +8,15 @@ import (
|
||||
)
|
||||
|
||||
type friendMgr struct {
|
||||
friendHash map[string]*map[string]int32
|
||||
blackHash map[string]*map[string]int32
|
||||
byBlackHash map[string]*map[string]int32
|
||||
friendHash map[string]map[string]int32
|
||||
blackHash map[string]map[string]int32
|
||||
byBlackHash map[string]map[string]int32
|
||||
}
|
||||
|
||||
func (this *friendMgr) Init() {
|
||||
this.friendHash = make(map[string]*map[string]int32)
|
||||
this.blackHash = make(map[string]*map[string]int32)
|
||||
this.byBlackHash = make(map[string]*map[string]int32)
|
||||
this.friendHash = make(map[string]map[string]int32)
|
||||
this.blackHash = make(map[string]map[string]int32)
|
||||
this.byBlackHash = make(map[string]map[string]int32)
|
||||
this.loadFromDB()
|
||||
}
|
||||
|
||||
@ -42,11 +42,15 @@ func (this *friendMgr) loadFriendships() {
|
||||
}
|
||||
for ds.Next() {
|
||||
idx := q5.ToInt64(ds.GetByName("idx"))
|
||||
accountId1 := ds.GetByName("account_id1")
|
||||
accountId2 := ds.GetByName("account_id2")
|
||||
addTime := q5.ToInt32(ds.GetByName("add_time"))
|
||||
if idx > lastIdx {
|
||||
lastIdx = idx
|
||||
} else {
|
||||
panic(fmt.Sprintf("friendMgr.loadFriendships idxerror:%s %s", idx, lastIdx))
|
||||
}
|
||||
this.addFriendShip(accountId1, accountId2, addTime)
|
||||
}
|
||||
if ds.NumOfReaded() <= 0 {
|
||||
done = true
|
||||
@ -124,7 +128,7 @@ func (this *friendMgr) GetBlackList(accountId string) []string {
|
||||
|
||||
func (this *friendMgr) getFriends(accountId string) *map[string]int32 {
|
||||
if friends, ok := this.friendHash[accountId]; ok {
|
||||
return friends
|
||||
return &friends
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -156,3 +160,13 @@ func (this *friendMgr) AsyncAddBlack(senderId string, targetId string, cb func(i
|
||||
func (this *friendMgr) AsyncRemoveBlack(senderId string, targetId string, cb func(int32, string)) {
|
||||
|
||||
}
|
||||
|
||||
func (this *friendMgr) addFriendShip(accountId1 string, accountId2 string, addTime int32) {
|
||||
{
|
||||
friends := this.getFriends(accountId1)
|
||||
if friends != nil {
|
||||
this.friendHash[accountId1] = make(map[string]int32)
|
||||
friends = this.getFriends(accountId1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user