Defining DTOs for the user

We will need DTOs to achieve maximal flexibility for all user-related operations that we will define. The first DTO will be the one we use when it returns a list of available users in the system. Define a new class called UserDetailsDTO:

package com.journaler.api.security 
 
import java.util.* 
 
data class UserDetailsDTO( 
        val id: String, 
        var email: String, 
        var firstName: String, 
        var lastName: String, 
        var roles: String, 
        var enabled: Boolean, 
        var accountNonExpired: Boolean, 
        var accountNonLocked: Boolean, 
        var credentialsNonExpired: Boolean, 
        var created: Date, 
        var modified: Date 
) 

UserDetailsDTO is a simple data class containing only mandatory fields. As you can see, we will not return back the password value. For saving ...

Get Building Applications with Spring 5 and Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.