fix: api descript
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"juwan-backend/app/snowflake/rpc/snowflake"
|
||||
|
||||
"juwan-backend/app/shop/rpc/internal/svc"
|
||||
"juwan-backend/app/shop/rpc/pb"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AddShopPlayersLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewAddShopPlayersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddShopPlayersLogic {
|
||||
return &AddShopPlayersLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------shopPlayers-----------------------
|
||||
func (l *AddShopPlayersLogic) AddShopPlayers(in *pb.AddShopPlayersReq) (*pb.AddShopPlayersResp, 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.ShopModelRW.ShopPlayers.Create().
|
||||
SetID(idResp.Id).
|
||||
SetShopID(in.ShopId).
|
||||
SetPlayerID(in.PlayerId).
|
||||
SetIsPrimary(in.IsPrimary).
|
||||
Save(l.ctx)
|
||||
if err != nil {
|
||||
logx.Errorf("addPlayerServices err:%v", err)
|
||||
return nil, errors.New("add player service failed")
|
||||
}
|
||||
|
||||
return &pb.AddShopPlayersResp{}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user