package models

import "time"

type User struct {
	ID           uint      `gorm:"primaryKey" json:"id"`
	Name         string    `gorm:"type:varchar(120);not null" json:"name"`
	Username     string    `gorm:"type:varchar(80);not null;uniqueIndex" json:"username"`
	PasswordHash string    `gorm:"type:varchar(255);not null" json:"-"`
	CreatedAt    time.Time `json:"createdAt"`
}

type Attendance struct {
	ID        uint      `gorm:"primaryKey" json:"id"`
	UserID    uint      `gorm:"uniqueIndex:idx_user_date" json:"userId"`
	Date      time.Time `gorm:"type:date;uniqueIndex:idx_user_date" json:"date"`
	Status    string    `gorm:"type:varchar(20);not null" json:"status"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

type SavedPeriod struct {
	ID           uint      `gorm:"primaryKey" json:"id"`
	UserID       uint      `gorm:"uniqueIndex:idx_user_period_start" json:"userId"`
	StartDate    time.Time `gorm:"type:date;uniqueIndex:idx_user_period_start" json:"startDate"`
	EndDate      time.Time `gorm:"type:date" json:"endDate"`
	Label        string    `gorm:"type:varchar(120);not null" json:"label"`
	TotalPresent int       `gorm:"not null" json:"totalPresent"`
	TotalAbsent  int       `gorm:"not null" json:"totalAbsent"`
	TotalLeave   int       `gorm:"not null" json:"totalLeave"`
	DailyRate    int64     `gorm:"not null" json:"dailyRate"`
	TotalSalary  int64     `gorm:"not null" json:"totalSalary"`
	SavedAt      time.Time `json:"savedAt"`
	CreatedAt    time.Time `json:"createdAt"`
	UpdatedAt    time.Time `json:"updatedAt"`
}

