package crm

import (
	"context"

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

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

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

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

func (l *DoneFollowUpLogic) DoneFollowUp(req *types.FollowUpIdReq) (*types.FollowUpPublic, error) {
	uid, err := ownerUID(l.ctx)
	if err != nil {
		return nil, err
	}
	f, err := l.svcCtx.Crm.DoneFollowUp(l.ctx, uid, req.Id)
	if err != nil {
		return nil, err
	}
	return crmmap.FollowUp(f), nil
}
