57 lines
1.4 KiB
Go
57 lines
1.4 KiB
Go
// Code scaffolded by goctl. Safe to edit.
|
|
// goctl 1.9.2
|
|
|
|
package player
|
|
|
|
import (
|
|
"context"
|
|
"juwan-backend/app/player/rpc/playerservice"
|
|
|
|
"juwan-backend/app/player/api/internal/svc"
|
|
"juwan-backend/app/player/api/internal/types"
|
|
|
|
"github.com/jinzhu/copier"
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type ListPlayerServicesLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
// 获取指定打手的服务列表
|
|
func NewListPlayerServicesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListPlayerServicesLogic {
|
|
return &ListPlayerServicesLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *ListPlayerServicesLogic) ListPlayerServices(req *types.ListPlayerServicesReq) (resp *types.PlayerServiceListResp, err error) {
|
|
resp = &types.PlayerServiceListResp{}
|
|
page := int64(0)
|
|
if req.Limit > 0 {
|
|
page = req.Offset / req.Limit
|
|
}
|
|
s, err := l.svcCtx.PlayerRpc.SearchPlayerServices(l.ctx, &playerservice.SearchPlayerServicesReq{
|
|
Page: page,
|
|
Limit: req.Limit,
|
|
PlayerId: req.Id,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
for _, v := range s.PlayerServices {
|
|
temp := types.PlayerService{}
|
|
err = copier.Copy(&temp, &v)
|
|
if err != nil {
|
|
logx.Errorf("ListPlayerServicesLogic.ListPlayerServices copier.Copy err: %v", err)
|
|
continue
|
|
}
|
|
resp.Items = append(resp.Items, temp)
|
|
}
|
|
return
|
|
}
|