package placement_topic

import (
	"context"

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

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

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

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

func (l *ListPlacementTopicsLogic) ListPlacementTopics() (*types.ListPlacementTopicsData, error) {
	tenantID, uid, err := actorFrom(l.ctx)
	if err != nil {
		return nil, err
	}
	result, err := l.svcCtx.PlacementTopic.List(l.ctx, tenantID, uid)
	if err != nil {
		return nil, err
	}
	return toListData(result), nil
}
