(Spring Boot)Responseオブジェクト
Spring Bootは結構独力で学んできたので、どう返すのが正解かわからない。
今回は Response というクラスを返すことにした。
コントローラからこれを返しJSONとしてクライアントに送信する。
AuthorResponse
package webapp.response; import java.util.Date; import java.util.List; import webapp.entity.Book; public class AuthorResponse { private int id; private String name; private Date birthDay; private List<Book> books; public AuthorResponse(int id, String name, Date birthDay, List<Book> books) { this.id = id; this.name = name; this.birthDay = birthDay; this.books = books; } public int getId() { return id; } public String getName() { return name; } public Date getBirthDay() { return birthDay; } public List<Book> getBooks() { return books; } }