Adding a data class
The getNotes()
method, for now, returns just a string with the value Work in progress
. This is not the list of notes we expect. To be able to return notes, we must define it. Create a new package called data
with a Note
member class. Make sure it is defined as follows:
package com.journaler.api.data data class Note( var id: String = ,"" var title: String, var message: String, var location: String = "" )
This is an ordinary Kotlin data class. We defined the Note
class as the class with three mandatory fields and one optional field. Update NoteController
so that it returns us two hardcoded notes:
@RestController @RequestMapping("/notes") class NoteController { @GetMapping( value = "/obtain", produces = arrayOf(MediaType.APPLICATION_JSON_VALUE) ) fun getNotes(): List<Note> { return listOf( Note( UUID.randomUUID().toString(), ...