6.4 產生一個 Data Entity

我們需於 edume.microservice.model 套件目錄下,產生一個 Book Data Enity 來保存書籍的屬性,如書名 (Book name)、作者 (Author)、ISBN (isbn) 及出版社 (Publisher)。

程式源碼列示如下:

package edume.microservice.model;

import org.springframework.data.annotation.Id;

public class Book
{
    //Book Identification
    @Id
    private String id = null;

    //Book Name
    private String name = null;

    //Book ISBN
    private String isbn = null;

    //Book Author
    private String author = null;

    //Book total pages
    private int pages = 0;

    public Book()
    {
    }

    public Book(String name, String isbn, String author, int pages)
    {
        this.name = name;
        this.isbn = isbn;
        this.author = author;
        this.pages = pages;
    }

    public String getId()
    {
        return this.id;
    }

    public void setId(String id)
    {
        this.id = id;
    }

    public String getName()
    {
        return this.name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public String getIsbn()
    {
        return this.isbn;
    }

    public void setIsbn(String isbn)
    {
        this.isbn = isbn;
    }

    public String getAuthor()
    {
        return this.author;
    }

    public void setAuthor(String author)
    {
        this.author = author;
    }

    public int getPages()
    {
        return this.pages;
    }

    public void setPages(int pages)
    {
        this.pages = pages;
    }
}

results matching ""

    No results matching ""