package contract

import (
	"time"

	"github.com/google/uuid"
)

type PermissionResponse struct {
	ID          uuid.UUID `json:"id"`
	Code        string    `json:"code"`
	Description *string   `json:"description,omitempty"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

type CreatePermissionRequest struct {
	Code        string  `json:"code"` // unique
	Description *string `json:"description,omitempty"`
}

type UpdatePermissionRequest struct {
	Code        *string `json:"code,omitempty"`
	Description *string `json:"description,omitempty"`
}

type ListPermissionsResponse struct {
	Permissions []PermissionResponse `json:"permissions"`
}

type RoleWithPermissionsResponse struct {
	ID          uuid.UUID            `json:"id"`
	Name        string               `json:"name"`
	Code        string               `json:"code"`
	Description *string              `json:"description,omitempty"`
	Permissions []PermissionResponse `json:"permissions"`
	CreatedAt   time.Time            `json:"created_at"`
	UpdatedAt   time.Time            `json:"updated_at"`
}

type CreateRoleRequest struct {
	Name            string   `json:"name"`
	Code            string   `json:"code"`
	Description     *string  `json:"description,omitempty"`
	PermissionCodes []string `json:"permission_codes,omitempty"`
}

type UpdateRoleRequest struct {
	Name            *string   `json:"name,omitempty"`
	Code            *string   `json:"code,omitempty"`
	Description     *string   `json:"description,omitempty"`
	PermissionCodes *[]string `json:"permission_codes,omitempty"`
}

type ListRolesResponse struct {
	Roles []RoleWithPermissionsResponse `json:"roles"`
}
