package crm

import (
	"context"

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

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

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

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

func (l *DeleteContactConversionLogic) DeleteContactConversion(req *types.DeleteCrmConversionReq) (*types.OkData, error) {
	uid, err := ownerUID(l.ctx)
	if err != nil {
		return nil, err
	}
	if err := l.svcCtx.Crm.DeleteConversion(l.ctx, uid, req.Id); err != nil {
		return nil, err
	}
	return &types.OkData{Ok: true}, nil
}
