// Code scaffolded by goctl. Safe to edit.
// goctl 1.10.1

package persona

import (
	"context"

	contentops "haixun-backend/internal/model/content_ops/domain/usecase"
	"haixun-backend/internal/svc"
	"haixun-backend/internal/types"

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

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

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

func (l *CreateFeedbackEventLogic) CreateFeedbackEvent(req *types.CreateFeedbackEventHandlerReq) (resp *types.FeedbackEventData, err error) {
	tenantID, uid, err := actorFrom(l.ctx)
	if err != nil {
		return nil, err
	}
	item, err := l.svcCtx.ContentOps.CreateFeedbackEvent(l.ctx, contentops.FeedbackEventInput{TenantID: tenantID, OwnerUID: uid, PersonaID: req.ID, ContentPlanID: req.ContentPlanID, DraftID: req.DraftID, Decision: req.Decision, Note: req.Note, Snapshot: req.Snapshot})
	if err != nil {
		return nil, err
	}
	data := toFeedbackEventData(*item)
	return &data, nil
}
