package de.effigenix.infrastructure.usermanagement.web.dto;

import de.effigenix.domain.usermanagement.RoleName;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

import java.util.Set;

/**
 * Request DTO for creating a new user.
 *
 * Used by POST /api/users endpoint (ADMIN only).
 */
@Schema(description = "Request to create a new user")
public record CreateUserRequest(
        @Schema(description = "Username (unique)", example = "john.doe", required = true)
        @NotBlank(message = "Username is required")
        @Size(min = 3, max = 50, message = "Username must be between 3 and 50 characters")
        String username,

        @Schema(description = "Email address (unique)", example = "john.doe@example.com", required = true)
        @NotBlank(message = "Email is required")
        @Email(message = "Email must be valid")
        String email,

        @Schema(description = "Password (min 8 characters)", example = "SecurePass123", required = true)
        @NotBlank(message = "Password is required")
        @Size(min = 8, message = "Password must be at least 8 characters")
        String password,

        @Schema(description = "Role names to assign", example = "[\"USER\", \"MANAGER\"]", required = true)
        @NotNull(message = "Roles are required")
        Set<RoleName> roleNames,

        @Schema(description = "Branch ID (optional)", example = "BRANCH-001")
        String branchId
) {
}
