feat(user): add users controller
Signed-off-by: Alan Brault <alan.brault@visus.io>
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
||||
package io.visus.demos.kotlinapi.api.dto
|
||||
package io.visus.demos.kotlinapi.api.contracts
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
package io.visus.demos.kotlinapi.api.dto
|
||||
package io.visus.demos.kotlinapi.api.contracts
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
|
||||
@Schema(description = "Health status of an individual component")
|
||||
data class ComponentHealthDto(
|
||||
data class ComponentHealthResponse(
|
||||
@Schema(description = "Component status", example = "UP")
|
||||
val status: String,
|
||||
@Schema(description = "Optional message with additional details", example = "MongoDB connection is active")
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package io.visus.demos.kotlinapi.api.dto
|
||||
package io.visus.demos.kotlinapi.api.contracts
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
import java.time.Instant
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package io.visus.demos.kotlinapi.api.dto
|
||||
package io.visus.demos.kotlinapi.api.contracts
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
import java.time.Instant
|
||||
@@ -10,5 +10,5 @@ data class HealthResponse(
|
||||
@Schema(description = "Timestamp of the health check", example = "2024-01-01T12:00:00Z")
|
||||
val timestamp: Instant,
|
||||
@Schema(description = "Status of individual components")
|
||||
val components: Map<String, ComponentHealthDto>? = null,
|
||||
val components: Map<String, ComponentHealthResponse>? = null,
|
||||
)
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package io.visus.demos.kotlinapi.api.dto
|
||||
package io.visus.demos.kotlinapi.api.contracts
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
import jakarta.validation.constraints.Email
|
||||
@@ -11,6 +11,6 @@ data class LoginRequest(
|
||||
@Schema(description = "User email address", example = "user@example.com")
|
||||
val email: String,
|
||||
@field:NotBlank(message = "Password is required")
|
||||
@Schema(description = "User password", example = "P@ssw0rd!")
|
||||
@Schema(description = "User password", example = "user12345")
|
||||
val password: String,
|
||||
)
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package io.visus.demos.kotlinapi.api.dto
|
||||
package io.visus.demos.kotlinapi.api.contracts
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
import jakarta.validation.constraints.NotBlank
|
||||
@@ -0,0 +1,18 @@
|
||||
package io.visus.demos.kotlinapi.api.contracts
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
import jakarta.validation.constraints.Email
|
||||
import jakarta.validation.constraints.NotBlank
|
||||
import jakarta.validation.constraints.Size
|
||||
|
||||
@Schema(description = "User registration request")
|
||||
data class RegisterRequest(
|
||||
@field:Email(message = "Invalid email address")
|
||||
@field:NotBlank(message = "Email address cannot be blank")
|
||||
@Schema(description = "User's email address", example = "newuser@example.com")
|
||||
val email: String,
|
||||
@field:NotBlank(message = "Password cannot be blank")
|
||||
@field:Size(min = 8, message = "Password must be at least 8 characters")
|
||||
@Schema(description = "User password (minimum 8 characters)", example = "SecurePass123!")
|
||||
val password: String,
|
||||
)
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
package io.visus.demos.kotlinapi.api.dto
|
||||
package io.visus.demos.kotlinapi.api.contracts
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
|
||||
@Schema(description = "User information")
|
||||
data class UserDto(
|
||||
@Schema(description = "Registered user information")
|
||||
data class RegisterResponse(
|
||||
@Schema(description = "Unique identifier of the user", example = "507f1f77bcf86cd799439011")
|
||||
val id: String,
|
||||
@Schema(description = "User email address", example = "user@example.com")
|
||||
@@ -0,0 +1,15 @@
|
||||
package io.visus.demos.kotlinapi.api.contracts
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
|
||||
@Schema(description = "User information")
|
||||
data class UserResponse(
|
||||
@Schema(description = "Unique identifier of the user", example = "507f1f77bcf86cd799439011")
|
||||
val id: String,
|
||||
@Schema(description = "User email address", example = "user@example.com")
|
||||
val email: String,
|
||||
@Schema(description = "User role", example = "ROLE_USER")
|
||||
val role: String,
|
||||
@Schema(description = "Active sessions", example = "0")
|
||||
val activeSessions: List<String>,
|
||||
)
|
||||
@@ -1,12 +1,12 @@
|
||||
package io.visus.demos.kotlinapi.api.mappers
|
||||
|
||||
import io.visus.demos.kotlinapi.api.dto.ComponentHealthDto
|
||||
import io.visus.demos.kotlinapi.api.contracts.ComponentHealthResponse
|
||||
import io.visus.demos.kotlinapi.domain.model.ComponentHealth
|
||||
import tech.mappie.api.ObjectMappie
|
||||
|
||||
object ComponentHealthDtoMapper : ObjectMappie<ComponentHealth, ComponentHealthDto>() {
|
||||
override fun map(from: ComponentHealth): ComponentHealthDto =
|
||||
object ComponentHealthDtoMapper : ObjectMappie<ComponentHealth, ComponentHealthResponse>() {
|
||||
override fun map(from: ComponentHealth): ComponentHealthResponse =
|
||||
mapping {
|
||||
ComponentHealthDto::status fromProperty ComponentHealth::status transform { it.name }
|
||||
ComponentHealthResponse::status fromProperty ComponentHealth::status transform { it.name }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.visus.demos.kotlinapi.api.mappers
|
||||
|
||||
import io.visus.demos.kotlinapi.api.dto.HealthResponse
|
||||
import io.visus.demos.kotlinapi.api.contracts.HealthResponse
|
||||
import io.visus.demos.kotlinapi.domain.model.HealthStatus
|
||||
import tech.mappie.api.ObjectMappie
|
||||
|
||||
|
||||
Reference in New Issue
Block a user