package dutyroster

import (
	"context"
	"time"
)

type TxRepository interface {
	GetRosterByID(ctx context.Context, id []byte) (*DutyRoster, error)
	LockRosterByID(ctx context.Context, id []byte) (*DutyRoster, error)
	CreateHeader(ctx context.Context, row *DutyRoster) error
	UpdateHeader(ctx context.Context, row *DutyRoster) error
	SoftDeleteHeader(ctx context.Context, id []byte, deletedBy []byte) error
	SoftDeleteCrewsByRosterID(ctx context.Context, rosterID []byte, deletedBy []byte) error
	ListActiveCrewsByRosterID(ctx context.Context, rosterID []byte) ([]DutyRosterCrew, error)
	InsertCrew(ctx context.Context, row *DutyRosterCrew) error
	CrewExists(ctx context.Context, row DutyRosterCrew) (bool, error)
	SoftDeleteCrewByUser(ctx context.Context, rosterID []byte, roleCode, crewType string, userID, updatedBy []byte) error
	FindRosterIDByBaseDate(ctx context.Context, baseID []byte, dutyDate time.Time) ([]byte, error)
	FindRosterIDsByBaseDate(ctx context.Context, baseID []byte, dutyDate time.Time) ([][]byte, error)
	MatchCrewByFilter(ctx context.Context, rosterIDs [][]byte, crew DutyRosterCrew) ([]DeletedCrewResult, error)
	SoftDeleteCrewRows(ctx context.Context, rows []DeletedCrewResult, deletedBy []byte) error
	SoftDeleteCrewForDate(ctx context.Context, baseID []byte, dutyDate time.Time, crew DutyRosterCrew, updatedBy []byte) error
	HardDeleteHeader(ctx context.Context, id []byte) error
	HardDeleteCrewsByRosterID(ctx context.Context, rosterID []byte) error
}

type Repository interface {
	InTx(ctx context.Context, fn func(txRepo TxRepository) error) error
	GetBaseDefaultShift(ctx context.Context, baseID []byte, baseType string) (string, error)
	GetHeaderByID(ctx context.Context, id []byte) (*HeaderView, error)
	GetHeaderByIDByBaseType(ctx context.Context, id []byte, baseType string) (*HeaderView, error)
	GetCrewsByRosterIDs(ctx context.Context, rosterIDs [][]byte) ([]CrewView, error)
	ListHeadersByRange(ctx context.Context, baseID []byte, from, to time.Time) ([]HeaderView, error)
	ListHeadersByRangeByBaseType(ctx context.Context, baseID []byte, from, to time.Time, baseType string) ([]HeaderView, error)
	ListHEMSBases(ctx context.Context, baseID []byte) ([]BaseView, error)
	ListBasesByType(ctx context.Context, baseID []byte, baseType string) ([]BaseView, error)
}
