package contract

import (
	"time"

	"github.com/google/uuid"
)

type ListFilesQuery struct {
	OrganizationID string `form:"organization_id"`
	UserID         string `form:"user_id"`
	FileType       string `form:"file_type"`
	IsPublic       string `form:"is_public"`
	DateFrom       string `form:"date_from"`
	DateTo         string `form:"date_to"`
	Search         string `form:"search"`
	Page           int    `form:"page,default=1"`
	Limit          int    `form:"limit,default=10"`
}

// Request DTOs
type UploadFileRequest struct {
	FileType string                 `json:"file_type" validate:"required"`
	IsPublic *bool                  `json:"is_public,omitempty"`
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

type UpdateFileRequest struct {
	IsPublic *bool                  `json:"is_public,omitempty"`
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

type ListFilesRequest struct {
	OrganizationID *uuid.UUID `json:"organization_id,omitempty"`
	UserID         *uuid.UUID `json:"user_id,omitempty"`
	FileType       *string    `json:"file_type,omitempty"`
	IsPublic       *bool      `json:"is_public,omitempty"`
	DateFrom       *time.Time `json:"date_from,omitempty"`
	DateTo         *time.Time `json:"date_to,omitempty"`
	Search         string     `json:"search,omitempty"`
	Page           int        `json:"page" validate:"required,min=1"`
	Limit          int        `json:"limit" validate:"required,min=1,max=100"`
}

// Response DTOs
type FileResponse struct {
	ID             uuid.UUID              `json:"id"`
	OrganizationID uuid.UUID              `json:"organization_id"`
	UserID         uuid.UUID              `json:"user_id"`
	FileName       string                 `json:"file_name"`
	OriginalName   string                 `json:"original_name"`
	FileURL        string                 `json:"file_url"`
	FileSize       int64                  `json:"file_size"`
	MimeType       string                 `json:"mime_type"`
	FileType       string                 `json:"file_type"`
	UploadPath     string                 `json:"upload_path"`
	IsPublic       bool                   `json:"is_public"`
	Metadata       map[string]interface{} `json:"metadata,omitempty"`
	CreatedAt      time.Time              `json:"created_at"`
	UpdatedAt      time.Time              `json:"updated_at"`
}

type ListFilesResponse struct {
	Files      []*FileResponse `json:"files"`
	TotalCount int             `json:"total_count"`
	Page       int             `json:"page"`
	Limit      int             `json:"limit"`
	TotalPages int             `json:"total_pages"`
}

type UploadFileResponse struct {
	File FileResponse `json:"file"`
}
