package repository

import (
	"github.com/zs/InsightReply/internal/model"
	"gorm.io/gorm"
)

type ProductProfileRepository struct {
	db *gorm.DB
}

func NewProductProfileRepository(db *gorm.DB) *ProductProfileRepository {
	return &ProductProfileRepository{db: db}
}

func (r *ProductProfileRepository) GetByUserID(userID string) (*model.UserProductProfile, error) {
	var profile model.UserProductProfile
	err := r.db.Where("user_id = ?", userID).First(&profile).Error
	return &profile, err
}

func (r *ProductProfileRepository) Save(profile *model.UserProductProfile) error {
	// Use Save to either create or update based on primary key
	return r.db.Save(profile).Error
}
