Files
juwan-backend/app/player/api/internal/logic/player/createServiceLogic.go
T
2026-02-28 05:33:16 +08:00

49 lines
1.1 KiB
Go

// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.2
package player
import (
"context"
"errors"
"juwan-backend/app/player/rpc/playerservice"
"juwan-backend/app/player/api/internal/svc"
"juwan-backend/app/player/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type CreateServiceLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
// 创建服务
func NewCreateServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateServiceLogic {
return &CreateServiceLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *CreateServiceLogic) CreateService(req *types.CreateServiceReq) (resp *types.PlayerService, err error) {
_, err = l.svcCtx.PlayerRpc.AddPlayerServices(l.ctx, &playerservice.AddPlayerServicesReq{
GameId: req.GameId,
Title: req.Title,
Description: req.Description,
Price: req.Price,
Unit: req.Unit,
RankRange: req.RankRange,
Availability: req.Availability,
})
if err != nil {
logx.Errorf("failed to create player service: " + err.Error())
return nil, errors.New("failed to create player service")
}
return
}