package radar

import (
	"context"

	"apps/backend/internal/logic/radarmap"
	"apps/backend/internal/svc"
	"apps/backend/internal/types"

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

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

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

func (l *ListOpportunityRepliesLogic) ListOpportunityReplies(req *types.ListRepliesReq) (*types.ReplyListData, error) {
	uid, err := ownerUID(l.ctx)
	if err != nil {
		return nil, err
	}
	list, err := l.svcCtx.Radar.ListReplies(l.ctx, uid, req.Id)
	if err != nil {
		return nil, err
	}
	return &types.ReplyListData{List: radarmap.ReplyList(list)}, nil
}
