86 lines
1.9 KiB
Go
86 lines
1.9 KiB
Go
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().UpsertEx(
|
|
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) {
|
|
cb(err, lastInsertId, rowsAffected)
|
|
this.updateAddFriendTask(accountId1, accountId2, nowTime)
|
|
},
|
|
func (ds *f5.DataSet) bool {
|
|
return true
|
|
})
|
|
}
|
|
|
|
func (this *friend) DeleteSoft(accountId1 string, accountId2 string,
|
|
cb func (error, int64, int64)) {
|
|
f5.GetJsStyleDb().Update(
|
|
constant.FRIEND_DB,
|
|
"t_friend_relationship",
|
|
[][]string{
|
|
{"account_id1", accountId1},
|
|
{"account_id2", accountId2},
|
|
},
|
|
[][]string{
|
|
{"deleted", q5.ToString(1)},
|
|
{"del_time", q5.ToString(f5.GetApp().GetNowSeconds())},
|
|
},
|
|
cb)
|
|
}
|
|
|
|
func (this *friend) updateAddFriendTask(accountId1 string, accountId2 string, nowTime int64) {
|
|
{
|
|
f5.GetJsStyleDb().Upsert(
|
|
constant.GAME_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) {
|
|
})
|
|
}
|
|
}
|