package crm

import (
	"context"

	"apps/backend/internal/svc"
	"apps/backend/internal/types"

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

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

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

func (l *GenerateFollowUpMessageLogic) GenerateFollowUpMessage(req *types.GenerateFollowUpMessageReq) (*types.GenerateFollowUpMessageData, error) {
	uid, err := ownerUID(l.ctx)
	if err != nil {
		return nil, err
	}
	text, err := l.svcCtx.Crm.GenerateFollowUpMessage(l.ctx, uid, req.Id)
	if err != nil {
		return nil, err
	}
	return &types.GenerateFollowUpMessageData{Text: text}, nil
}
