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 ResumeWatchLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

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

func (l *ResumeWatchLogic) ResumeWatch(req *types.WatchIdReq) (resp *types.RadarWatchPublic, err error) {
	uid, err := ownerUID(l.ctx)
	if err != nil {
		return nil, err
	}
	w, err := l.svcCtx.Radar.ResumeWatch(l.ctx, uid, req.Id)
	if err != nil {
		return nil, err
	}
	return radarmap.Watch(w), nil
}
