fix: api descript

This commit is contained in:
wwweww
2026-02-28 05:33:16 +08:00
parent 5930fb0dde
commit d2f33b4b96
243 changed files with 37065 additions and 780 deletions
@@ -0,0 +1,54 @@
package logic
import (
"context"
"errors"
"juwan-backend/app/player/rpc/internal/svc"
"juwan-backend/app/player/rpc/pb"
"juwan-backend/app/snowflake/rpc/snowflake"
"github.com/shopspring/decimal"
"github.com/zeromicro/go-zero/core/logx"
)
type AddPlayerServicesLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewAddPlayerServicesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddPlayerServicesLogic {
return &AddPlayerServicesLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// -----------------------playerServices-----------------------
func (l *AddPlayerServicesLogic) AddPlayerServices(in *pb.AddPlayerServicesReq) (*pb.AddPlayerServicesResp, error) {
idResp, err := l.svcCtx.Snowflake.NextId(l.ctx, &snowflake.NextIdReq{})
if err != nil {
logx.Errorf("addPlayerServices err:%v", err)
return nil, errors.New("create player service id failed")
}
_, err = l.svcCtx.PlayerModelRW.PlayerServices.Create().
SetID(idResp.Id).
SetPlayerID(in.PlayerId).
SetGameID(in.GameId).
SetTitle(in.Title).
SetDescription(in.Description).
SetPrice(decimal.NewFromFloat(in.Price)).
SetUnit(in.Unit).
SetRankRange(in.RankRange).
SetAvailability(in.Availability).
SetRating(decimal.NewFromFloat(in.Rating)).
SetIsActive(in.IsActive).
Save(l.ctx)
if err != nil {
logx.Errorf("addPlayerServices err:%v", err)
return nil, errors.New("add player service failed")
}
return &pb.AddPlayerServicesResp{}, nil
}