35 lines
691 B
Go
35 lines
691 B
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
|
|
"mongo.games.com/game/db/dao"
|
|
"mongo.games.com/game/db/model"
|
|
"mongo.games.com/game/db/proto/user"
|
|
"mongo.games.com/game/db/rpc/svc"
|
|
)
|
|
|
|
type UserLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserLogic {
|
|
return &UserLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *UserLogic) Save(in *user.SaveReq) (*user.SaveRsp, error) {
|
|
u, err := svc.GetUserCollection(in.GetPlatform(), model.User{}, dao.NewUser)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
_, err = u.InsertOne(l.ctx, &model.User{})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &user.SaveRsp{}, nil
|
|
}
|