Files
juwan-backend/app/game/api/internal/logic/game/createGameLogic.go
T
2026-03-31 22:12:06 +08:00

47 lines
995 B
Go

// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.2
package game
import (
"context"
"errors"
"juwan-backend/app/game/rpc/pb"
"juwan-backend/app/game/api/internal/svc"
"juwan-backend/app/game/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type CreateGameLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
// 创建游戏
func NewCreateGameLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateGameLogic {
return &CreateGameLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *CreateGameLogic) CreateGame(req *types.Game) (resp *types.Game, err error) {
// todo: add your logic here and delete this line
_, err = l.svcCtx.GameRpc.AddGames(l.ctx, &pb.AddGamesReq{
Name: req.Name,
Icon: req.Icon,
Category: req.Category,
IsActive: false,
})
if err != nil {
logx.Errorf("add game err: %v", err)
return nil, errors.New("add game err")
}
return &types.Game{}, nil
}