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))
|
||||
}
|
||||
if this.IsFriend(accountId, senderId) {
|
||||
this.asyncSetApplyStatus(senderId, accountId,
|
||||
constant.FRIEND_APPLY_STATUS_ACCEPT)
|
||||
model.FriendApply.SetStatus(senderId, accountId, constant.FRIEND_APPLY_STATUS_ACCEPT,
|
||||
func (error, int64, int64) {
|
||||
|
||||
})
|
||||
} else {
|
||||
*q5.NewSliceElement(&users) = senderId
|
||||
}
|
||||
@ -227,38 +229,24 @@ func (this *friendMgr) AsyncAcceptApply(senderId string, targetId string, cb fun
|
||||
accountId1, accountId2 := this.sortAccounts(senderId, targetId)
|
||||
func () {
|
||||
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, "")
|
||||
return
|
||||
} else {
|
||||
nowTime := f5.GetApp().GetNowSeconds()
|
||||
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)},
|
||||
},
|
||||
model.Friend.Force(accountId1, accountId2, nowTime,
|
||||
func (err error, lastInsertId int64, rowsAffected int64) {
|
||||
if err != nil {
|
||||
cb(1, "")
|
||||
return
|
||||
}
|
||||
this.asyncSetApplyStatus(senderId,
|
||||
targetId,
|
||||
constant.FRIEND_APPLY_STATUS_ACCEPT)
|
||||
model.FriendApply.SetStatus(senderId, targetId, constant.FRIEND_APPLY_STATUS_ACCEPT,
|
||||
func (error, int64, int64) {
|
||||
|
||||
})
|
||||
this.addFriendShip(accountId1, accountId2, int32(nowTime))
|
||||
cb(0, "")
|
||||
})
|
||||
@ -271,7 +259,10 @@ func (this *friendMgr) AsyncRejectApply(senderId string, targetId string, cb fun
|
||||
cb(1, "")
|
||||
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, "")
|
||||
}
|
||||
|
||||
@ -429,20 +420,3 @@ func (this *friendMgr) sortAccounts(senderId string, targetId string) (string, s
|
||||
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
|
||||
|
||||
/*
|
||||
import (
|
||||
"q5"
|
||||
"f5"
|
||||
"main/constant"
|
||||
)*/
|
||||
)
|
||||
|
||||
type friend struct {
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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