1
This commit is contained in:
parent
d1621300ff
commit
cef671daf1
@ -190,8 +190,10 @@ func (this *friendMgr) AsyncGetApplyList(lastIdx int64, accountId string,
|
|||||||
panic(fmt.Sprintf("AsyncGetApply idx error:%s %s", idx, lastSinceId))
|
panic(fmt.Sprintf("AsyncGetApply idx error:%s %s", idx, lastSinceId))
|
||||||
}
|
}
|
||||||
if this.IsFriend(accountId, senderId) {
|
if this.IsFriend(accountId, senderId) {
|
||||||
this.asyncSetApplyStatus(senderId, accountId,
|
model.FriendApply.SetStatus(senderId, accountId, constant.FRIEND_APPLY_STATUS_ACCEPT,
|
||||||
constant.FRIEND_APPLY_STATUS_ACCEPT)
|
func (error, int64, int64) {
|
||||||
|
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
*q5.NewSliceElement(&users) = senderId
|
*q5.NewSliceElement(&users) = senderId
|
||||||
}
|
}
|
||||||
@ -227,38 +229,24 @@ func (this *friendMgr) AsyncAcceptApply(senderId string, targetId string, cb fun
|
|||||||
accountId1, accountId2 := this.sortAccounts(senderId, targetId)
|
accountId1, accountId2 := this.sortAccounts(senderId, targetId)
|
||||||
func () {
|
func () {
|
||||||
if this.IsFriend(senderId, targetId) {
|
if this.IsFriend(senderId, targetId) {
|
||||||
this.asyncSetApplyStatus(senderId, targetId, 1)
|
model.FriendApply.SetStatus(senderId, targetId, constant.FRIEND_APPLY_STATUS_ACCEPT,
|
||||||
|
func (error, int64, int64) {
|
||||||
|
|
||||||
|
})
|
||||||
cb(0, "")
|
cb(0, "")
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
nowTime := f5.GetApp().GetNowSeconds()
|
nowTime := f5.GetApp().GetNowSeconds()
|
||||||
f5.GetJsStyleDb().Upsert(
|
model.Friend.Force(accountId1, accountId2, nowTime,
|
||||||
constant.FRIEND_DB,
|
|
||||||
"t_friend_relationship",
|
|
||||||
[][]string{
|
|
||||||
{"account_id1", accountId1},
|
|
||||||
{"account_id2", accountId2},
|
|
||||||
},
|
|
||||||
[][]string{
|
|
||||||
{"add_time", q5.ToString(nowTime)},
|
|
||||||
{"deleted", "0"},
|
|
||||||
},
|
|
||||||
[][]string{
|
|
||||||
{"account_id1", accountId1},
|
|
||||||
{"account_id2", accountId2},
|
|
||||||
{"add_time", q5.ToString(nowTime)},
|
|
||||||
{"deleted", "0"},
|
|
||||||
{"createtime", q5.ToString(nowTime)},
|
|
||||||
{"modifytime", q5.ToString(nowTime)},
|
|
||||||
},
|
|
||||||
func (err error, lastInsertId int64, rowsAffected int64) {
|
func (err error, lastInsertId int64, rowsAffected int64) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cb(1, "")
|
cb(1, "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.asyncSetApplyStatus(senderId,
|
model.FriendApply.SetStatus(senderId, targetId, constant.FRIEND_APPLY_STATUS_ACCEPT,
|
||||||
targetId,
|
func (error, int64, int64) {
|
||||||
constant.FRIEND_APPLY_STATUS_ACCEPT)
|
|
||||||
|
})
|
||||||
this.addFriendShip(accountId1, accountId2, int32(nowTime))
|
this.addFriendShip(accountId1, accountId2, int32(nowTime))
|
||||||
cb(0, "")
|
cb(0, "")
|
||||||
})
|
})
|
||||||
@ -271,7 +259,10 @@ func (this *friendMgr) AsyncRejectApply(senderId string, targetId string, cb fun
|
|||||||
cb(1, "")
|
cb(1, "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.asyncSetApplyStatus(senderId, targetId, constant.FRIEND_APPLY_STATUS_REJECT)
|
model.FriendApply.SetStatus(senderId, targetId, constant.FRIEND_APPLY_STATUS_REJECT,
|
||||||
|
func (error, int64, int64) {
|
||||||
|
|
||||||
|
})
|
||||||
cb(0, "")
|
cb(0, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -429,20 +420,3 @@ func (this *friendMgr) sortAccounts(senderId string, targetId string) (string, s
|
|||||||
return targetId, senderId
|
return targetId, senderId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *friendMgr) asyncSetApplyStatus(senderId string, targetId string, status int32) {
|
|
||||||
f5.GetJsStyleDb().Update(
|
|
||||||
constant.FRIEND_DB,
|
|
||||||
"t_friend_apply",
|
|
||||||
[][]string{
|
|
||||||
{"status", q5.ToString(status)},
|
|
||||||
{"modifytime", q5.ToString(f5.GetApp().GetNowSeconds())},
|
|
||||||
},
|
|
||||||
[][]string{
|
|
||||||
{"sender_id", senderId},
|
|
||||||
{"target_id", targetId},
|
|
||||||
},
|
|
||||||
func (err error, lastInsertId int64, rowsAffected int64) {
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
@ -1,14 +1,37 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
/*
|
|
||||||
import (
|
import (
|
||||||
"q5"
|
"q5"
|
||||||
"f5"
|
"f5"
|
||||||
"main/constant"
|
"main/constant"
|
||||||
)*/
|
)
|
||||||
|
|
||||||
type friend struct {
|
type friend struct {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var Friend = new (friend)
|
var Friend = new (friend)
|
||||||
|
|
||||||
|
func (this *friend) Force(accountId1 string, accountId2 string, nowTime int64,
|
||||||
|
cb func (error, int64, int64)) {
|
||||||
|
f5.GetJsStyleDb().Upsert(
|
||||||
|
constant.FRIEND_DB,
|
||||||
|
"t_friend_relationship",
|
||||||
|
[][]string{
|
||||||
|
{"account_id1", accountId1},
|
||||||
|
{"account_id2", accountId2},
|
||||||
|
},
|
||||||
|
[][]string{
|
||||||
|
{"add_time", q5.ToString(nowTime)},
|
||||||
|
{"deleted", "0"},
|
||||||
|
},
|
||||||
|
[][]string{
|
||||||
|
{"account_id1", accountId1},
|
||||||
|
{"account_id2", accountId2},
|
||||||
|
{"add_time", q5.ToString(nowTime)},
|
||||||
|
{"deleted", "0"},
|
||||||
|
{"createtime", q5.ToString(nowTime)},
|
||||||
|
{"modifytime", q5.ToString(nowTime)},
|
||||||
|
},
|
||||||
|
cb)
|
||||||
|
}
|
||||||
|
@ -36,3 +36,21 @@ func (this *friendApply) Force(senderId string, targetId string,
|
|||||||
},
|
},
|
||||||
cb)
|
cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *friendApply) SetStatus(senderId string, targetId string, status int32,
|
||||||
|
cb func (error, int64, int64)) {
|
||||||
|
f5.GetJsStyleDb().Update(
|
||||||
|
constant.FRIEND_DB,
|
||||||
|
"t_friend_apply",
|
||||||
|
[][]string{
|
||||||
|
{"status", q5.ToString(status)},
|
||||||
|
{"modifytime", q5.ToString(f5.GetApp().GetNowSeconds())},
|
||||||
|
},
|
||||||
|
[][]string{
|
||||||
|
{"sender_id", senderId},
|
||||||
|
{"target_id", targetId},
|
||||||
|
},
|
||||||
|
func (err error, lastInsertId int64, rowsAffected int64) {
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user