67 lines
1.5 KiB
Go
67 lines
1.5 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
|
|
}
|
|
|
|
func RemoveByFaceBookId(faceBookId string) error {
|
|
if rpcCli == nil {
|
|
return errors.New("rpc client is nil")
|
|
}
|
|
|
|
if faceBookId == "" {
|
|
return nil
|
|
}
|
|
|
|
ret := false
|
|
err := rpcCli.CallWithTimeout("AccountLogSvc.RemoveByFaceBookId", &faceBookId, &ret, time.Second*30)
|
|
if err != nil {
|
|
logger.Logger.Errorf("RemoveByFaceBookId err:%v", err)
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|