package pdks

import (
	"context"
	"time"
)

// repository.go: kalicilik sozlesmesi.
//
// Neden arayuz? Proje deseni (bkz. tool/contract.go, notify/repository.go):
// uretim Mongo, test bellek ici. RepositoryContract URETIM KODUNDA olmali —
// `_test.go` icinde olursa dis paketler erisemez.

// AttendFilter, devam olayi sorgusudur.
type AttendFilter struct {
	EmpID string
	From  string         // "YYYY-MM-DD" (dahil); bos = sinirsiz
	To    string         // "YYYY-MM-DD" (dahil)
	Type  AttendanceType // bos = tum turler
	Limit int            // 0 = varsayilan
}

// Repository, PDKS kayitlarinin deposudur.
//
// TASARIM: Sure hesabi DEPOYA YAZILMAZ; olaylar sirayla saklanir, hesap
// Service'te yapilir. Boylece gecmise eklenen/duzeltilen bir olay gecmis
// raporlarini da dogru gosterir.
type Repository interface {
	// ---- Bolum ----
	CreateDepartment(ctx context.Context, d Department) (Department, error)
	UpdateDepartment(ctx context.Context, d Department) (Department, error)
	DeleteDepartment(ctx context.Context, id string) error
	GetDepartment(ctx context.Context, id string) (Department, error)
	ListDepartments(ctx context.Context) ([]Department, error)

	// ---- Personel ----
	CreateEmployee(ctx context.Context, e Employee) (Employee, error)
	UpdateEmployee(ctx context.Context, e Employee) (Employee, error)
	DeleteEmployee(ctx context.Context, id string) error
	GetEmployee(ctx context.Context, id string) (Employee, error)
	GetEmployeeByUser(ctx context.Context, userID string) (Employee, error)
	ListEmployees(ctx context.Context) ([]Employee, error)

	// ---- Vardiya ----
	CreateShift(ctx context.Context, s Shift) (Shift, error)
	UpdateShift(ctx context.Context, s Shift) (Shift, error)
	DeleteShift(ctx context.Context, id string) error
	ListShifts(ctx context.Context) ([]Shift, error)

	// ---- Devam olaylari ----
	//
	// CreateAttendance cakisma denetimi YAPMAZ (Service yapar); depo yalniz yazar.
	CreateAttendance(ctx context.Context, a Attendance) (Attendance, error)
	DeleteAttendance(ctx context.Context, id string) error
	GetAttendance(ctx context.Context, id string) (Attendance, error)
	// ListAttendance, filtreye uyan olaylari ZAMAN SIRASIYLA dondurur.
	ListAttendance(ctx context.Context, f AttendFilter) ([]Attendance, error)

	// ---- Izin ----
	CreateLeave(ctx context.Context, l Leave) (Leave, error)
	UpdateLeave(ctx context.Context, l Leave) (Leave, error)
	DeleteLeave(ctx context.Context, id string) error
	GetLeave(ctx context.Context, id string) (Leave, error)
	// ListLeave, personelin izinlerini tarih araligina gore dondurur
	// (aralikla KESISEN kayitlar: izin gunleri rapor araliginin icinde olmali).
	ListLeave(ctx context.Context, empID, from, to string) ([]Leave, error)

	// Now, depo saat kaynagini bildirir (gun siniri hesabi icin).
	Now() time.Time
}
