// Code scaffolded by goctl. Safe to edit.
// goctl 1.10.1

package threads_account

import (
	"context"

	"haixun-backend/internal/svc"
	"haixun-backend/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ListThreadsPostPerformanceLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewListThreadsPostPerformanceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListThreadsPostPerformanceLogic {
	return &ListThreadsPostPerformanceLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ListThreadsPostPerformanceLogic) ListThreadsPostPerformance(req *types.ListThreadsPostPerformanceHandlerReq) (*types.ThreadsPostPerformanceData, error) {
	tenantID, uid, err := actorFrom(l.ctx)
	if err != nil {
		return nil, err
	}
	result, err := l.svcCtx.ThreadsAccount.ListPostPerformance(l.ctx, tenantID, uid, req.ID, req.Limit)
	if err != nil {
		return nil, err
	}
	return toPostPerformanceData(result), nil
}
