Files
juwan-backend/app/shop/rpc/internal/logic/addShopPlayersLogic.go
T
2026-04-04 07:05:11 +08:00

41 lines
950 B
Go

package logic
import (
"context"
"errors"
"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) {
_, err := l.svcCtx.ShopModelRW.ShopPlayers.Create().
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
}