Separating code into independent entities
Before we start with the implementation, we will separate our code into independent entities. Each entity will cover a single responsibility and therefore will be implemented when we cover a certain Spring functionality.
We will start with the main classes that will represent the data we will actually handle: Notes and TODOs. Then we will describe user-related stuff: the users themselves and the roles we plan to assign to them. Later, when we actually implement most of them, we will introduce some new entities to cover additional responsibilities. This will be explained in Chapter 3, Building Your First Spring RESTful Service with Kotlin.
Describing entities
The main entities that we will use and that will hold the data are Notes and TODOs. We can consider each of them as an entry that will be stored and that has common attributes:
ID
: Universally Unique IDentifier (UUID) StringTitle
: StringMessage
: StringLocation
: String value that represents serialized Location class into JSON.
Here are all the entities that we use:
Note
: TheNote
entity will represent Notes in the system with all common attributes.TODO
: TheTODO
entity will represent TODOs in the system with all common attributes and timestamps for a scheduled time.User
: TheUser
entity will be completely independent of the main data entities. The user will represent the user and all the attributes that the user of the system can have, including assigned roles. The user will have the following attributes:ID
: UUID StringEmail
: StringPassword
: StringFirst name
: StringLast name
: StringRoles
: String
Enabled
: Boolean representing whether the user has activated the account or whether it has been activated by the user from a higher user hierarchyCreated on
: Long representing UTC timestamp when the user was createdUpdated on
: Long representing UTC timestamp when the user was updated
In later stages, we can introduce additional attributes if there is a need. For now, we will stick to the most important ones we just described.