game_sync/model/accountlog.go

48 lines
1.1 KiB
Go

package model
import (
"errors"
"go.mongodb.org/mongo-driver/bson/primitive"
"mongo.games.com/goserver/core/logger"
"time"
)
// AccountLog 账号日志
// 根据facebookId查询账号信息
//go:generate mongoctl -model-dir=. -model-names=AccountLog -dao-dir=../dao/
type AccountLog struct {
ID primitive.ObjectID `bson:"_id" gen:"autoFill"`
Platform string `bson:"platform"`
SnId int32 `bson:"snid"`
AccountType int32 `bson:"accounttype"`
FaceBookId string `bson:"facebookid"`
}
func (a *AccountLog) DatabaseName() string {
return "log"
}
func (a *AccountLog) CollectionName() string {
return "log_account"
}
func GetByFaceBookId(faceBookId string) (*AccountLog, error) {
if rpcCli == nil {
return nil, errors.New("rpc client is nil")
}
if faceBookId == "" {
return nil, nil
}
accountLog := &AccountLog{}
err := rpcCli.CallWithTimeout("AccountLogSvc.GetByFaceBookId", &faceBookId, accountLog, time.Second*30)
if err != nil {
logger.Logger.Errorf("GetByFaceBookId err:%v", err)
return nil, err
}
return accountLog, nil
}