package publicreport

import (
	"context"
	"time"

	"source.gleipnir.technology/Gleipnir/nidus-sync/db"
	"source.gleipnir.technology/Gleipnir/nidus-sync/db/gen/nidus-sync/publicreport/model"
	"source.gleipnir.technology/Gleipnir/nidus-sync/db/gen/nidus-sync/publicreport/table"
	//"github.com/Gleipnir-Technology/jet/postgres"
)

func NotifyEmailInsert(ctx context.Context, txn db.Ex, m model.NotifyEmail) (model.NotifyEmail, error) {
	statement := table.NotifyEmail.INSERT(table.NotifyEmail.MutableColumns).
		MODEL(m).
		RETURNING(table.NotifyEmail.AllColumns)
	return db.ExecuteOneTx[model.NotifyEmail](ctx, txn, statement)
}
func NotifyEmailCreate(ctx context.Context, txn db.Ex, report_id int32, destination string) (model.NotifyEmail, error) {
	return NotifyEmailInsert(ctx, txn, model.NotifyEmail{
		Created:      time.Now(),
		Deleted:      nil,
		EmailAddress: destination,
		ReportID:     report_id,
	})
}
