package repository

import (
    "context"
	"github.com/go-nunu/nunu-layout-advanced/internal/model"
)

type LogRepository interface {
	GetLog(ctx context.Context, id int64) (*model.Log, error)
	AddLog(ctx context.Context, log *model.Log) error
	EditLog(ctx context.Context, log *model.Log) error
}

func NewLogRepository(
	repository *Repository,
) LogRepository {
	return &logRepository{
		Repository: repository,
	}
}

type logRepository struct {
	*Repository
}

func (r *logRepository) GetLog(ctx context.Context, id int64) (*model.Log, error) {
	var log model.Log

	return &log, nil
}

func (r *logRepository) AddLog(ctx context.Context, log *model.Log) error {
	return r.DBWithName(ctx,"admin").Create(log).Error
}

func (r *logRepository) EditLog(ctx context.Context, log *model.Log) error {
	return r.DBWithName(ctx,"admin").Updates(log).Error
}
